diff mbox series

[04/21] btrfs: zoned: it's pointless to check for REQ_OP_ZONE_APPEND and btrfs_is_zoned

Message ID 2a77d18e249ace733422771b05d48a883c4e5b07.1637745470.git.johannes.thumshirn@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs: first batch of zoned cleanups | expand

Commit Message

Johannes Thumshirn Nov. 24, 2021, 9:30 a.m. UTC
REQ_OP_ZONE_APPEND can only work on zoned devices, so it is redundant to
check if the filesystem is zoned when REQ_OP_ZONE_APPEND is set as the
bio's bio_op.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/extent_io.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

David Sterba Nov. 24, 2021, 5:33 p.m. UTC | #1
On Wed, Nov 24, 2021 at 01:30:30AM -0800, Johannes Thumshirn wrote:
> REQ_OP_ZONE_APPEND can only work on zoned devices, so it is redundant to
> check if the filesystem is zoned when REQ_OP_ZONE_APPEND is set as the
> bio's bio_op.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  fs/btrfs/extent_io.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 96c2e40887772..d5eb31306c448 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -3282,8 +3282,7 @@ static int calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl,
>  	else
>  		bio_ctrl->len_to_stripe_boundary = (u32)geom.len;
>  
> -	if (!btrfs_is_zoned(fs_info) ||
> -	    bio_op(bio_ctrl->bio) != REQ_OP_ZONE_APPEND) {
> +	if (bio_op(bio_ctrl->bio) != REQ_OP_ZONE_APPEND) {

As for this style of open coded conditions, I think it's fine in
functions that handle bios or the REQ_OPs anyway, so like here. Removing
redundant conditions is correct too.

>  		bio_ctrl->len_to_oe_boundary = U32_MAX;
>  		return 0;
>  	}
diff mbox series

Patch

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 96c2e40887772..d5eb31306c448 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3282,8 +3282,7 @@  static int calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl,
 	else
 		bio_ctrl->len_to_stripe_boundary = (u32)geom.len;
 
-	if (!btrfs_is_zoned(fs_info) ||
-	    bio_op(bio_ctrl->bio) != REQ_OP_ZONE_APPEND) {
+	if (bio_op(bio_ctrl->bio) != REQ_OP_ZONE_APPEND) {
 		bio_ctrl->len_to_oe_boundary = U32_MAX;
 		return 0;
 	}
@@ -3338,7 +3337,7 @@  static int alloc_new_bio(struct btrfs_inode *inode,
 		bio_set_dev(bio, bdev);
 		wbc_init_bio(wbc, bio);
 	}
-	if (btrfs_is_zoned(fs_info) && bio_op(bio) == REQ_OP_ZONE_APPEND) {
+	if (bio_op(bio) == REQ_OP_ZONE_APPEND) {
 		struct btrfs_device *device;
 
 		device = btrfs_zoned_get_device(fs_info, disk_bytenr,