block: remove bdev_nonrot()
Subsystems (8)
PATCH 1/1 block: remove bdev_nonrot()
bdev_nonrot() is simply the negative return value of bdev_rot(). So replace all call sites of bdev_nonrot() with calls to bdev_rot() and remove bdev_nonrot().
--- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 2 +- drivers/md/raid5.c | 2 +- drivers/target/target_core_file.c | 2 +- drivers/target/target_core_iblock.c | 2 +- fs/btrfs/volumes.c | 4 ++-- fs/ext4/mballoc-test.c | 2 +- fs/ext4/mballoc.c | 2 +- include/linux/blkdev.h | 5 ----- mm/swapfile.c | 2 +- 10 files changed, 10 insertions(+), 15 deletions(-)
drivers/md/raid1.c +1 -1
@@ -1878,7 +1878,7 @@ static bool raid1_add_conf(struct r1conf *conf, struct md_rdev *rdev, int disk,if (info->rdev)return false; -if (bdev_nonrot (rdev->bdev)) { +if (!bdev_rot (rdev->bdev)) {set_bit (Nonrot, &rdev->flags);WRITE_ONCE (conf->nonrot_disks, conf->nonrot_disks +1 ); }
drivers/md/raid10.c +1 -1
@@ -806,7 +806,7 @@ static struct md_rdev *read_balance(struct r10conf *conf,if (!do_balance)break ; - nonrot =bdev_nonrot (rdev->bdev); + nonrot = !bdev_rot (rdev->bdev); has_nonrot_disk |= nonrot; pending =atomic_read (&rdev->nr_pending);if (min_pending > pending && nonrot) {
drivers/md/raid5.c +1 -1
@@ -7541,7 +7541,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)rdev_for_each (rdev, mddev) {if (test_bit (Journal, &rdev->flags))continue ; -if (bdev_nonrot (rdev->bdev)) { +if (!bdev_rot (rdev->bdev)) { conf->batch_bio_dispatch = false;break ; }
drivers/target/target_core_file.c +1 -1
@@ -173,7 +173,7 @@ static int fd_configure_device(struct se_device *dev)*/ dev->dev_attrib.max_write_same_len =0xFFFF ; -if (bdev_nonrot (bdev)) +if (!bdev_rot (bdev)) dev->dev_attrib.is_nonrot =1 ; }else {if (!(fd_dev->fbd_flags &FBDF_HAS_SIZE )) {
drivers/target/target_core_iblock.c +1 -1
@@ -148,7 +148,7 @@ static int iblock_configure_device(struct se_device *dev)else dev->dev_attrib.max_write_same_len =0xFFFF ; -if (bdev_nonrot (bd)) +if (!bdev_rot (bd)) dev->dev_attrib.is_nonrot =1 ;target_configure_write_atomic_from_bdev (&dev->dev_attrib, bd);
fs/btrfs/volumes.c +2 -2
@@ -694,7 +694,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,set_bit (BTRFS_DEV_STATE_WRITEABLE , &device->dev_state); } -if (!bdev_nonrot (file_bdev (bdev_file))) +if (bdev_rot (file_bdev (bdev_file))) fs_devices->rotating = true;if (bdev_max_discard_sectors (file_bdev (bdev_file)))
@@ -2919,7 +2919,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_pathatomic64_add (device->total_bytes, &fs_info->free_chunk_space); -if (!bdev_nonrot (device->bdev)) +if (bdev_rot (device->bdev)) fs_devices->rotating = true; orig_super_total_bytes =btrfs_super_total_bytes (fs_info->super_copy);
fs/ext4/mballoc-test.c +1 -1
@@ -72,7 +72,7 @@ static int mbt_mb_init(struct super_block *sb)ext4_fsblk_t block;int ret; -/* needed by ext4_mb_init->bdev_nonrot(sb->s_bdev) */ +/* needed by ext4_mb_init->bdev_rot(sb->s_bdev) */ sb->s_bdev =kzalloc_obj (*sb->s_bdev);if (sb->s_bdev ==NULL )return -ENOMEM ;
fs/ext4/mballoc.c +1 -1
@@ -3836,7 +3836,7 @@ int ext4_mb_init(struct super_block *sb)spin_lock_init (&lg->lg_prealloc_lock); } -if (bdev_nonrot (sb->s_bdev)) +if (!bdev_rot (sb->s_bdev)) sbi->s_mb_max_linear_groups =0 ;else sbi->s_mb_max_linear_groups =MB_DEFAULT_LINEAR_LIMIT ;
include/linux/blkdev.h +0 -5
@@ -1467,11 +1467,6 @@ static inline bool bdev_rot(struct block_device *bdev)return blk_queue_rot (bdev_get_queue (bdev)); } -static inline bool bdev_nonrot (struct block_device *bdev) -{ -return !bdev_rot (bdev); -} -static inline bool bdev_synchronous (struct block_device *bdev) {return bdev->bd_disk->queue->limits.features &BLK_FEAT_SYNCHRONOUS ;
mm/swapfile.c +1 -1
@@ -3460,7 +3460,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)if (si->bdev &&bdev_synchronous (si->bdev)) si->flags |=SWP_SYNCHRONOUS_IO ; -if (si->bdev &&bdev_nonrot (si->bdev)) { +if (si->bdev && !bdev_rot (si->bdev)) { si->flags |=SWP_SOLIDSTATE ; }else {atomic_inc (&nr_rotate_swap);
Signature · 1 line
2.53.0
Dear Damien,
Thank you for your patch.
Am 26.02.26 um 08:54 schrieb Damien Le Moal:
Quoted 3 lines
bdev_nonrot()is simply the negative return value ofbdev_rot(). So replace all call sites ofbdev_nonrot()with calls tobdev_rot()and removebdev_nonrot().
Is the generated code different now?
Is it worth the change, as it looks quite subjective if you prefer the one or the other way?
Quoted 148 lines
Signed-off-by Damien Le Moal <[email protected]>--- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 2 +- drivers/md/raid5.c | 2 +- drivers/target/target_core_file.c | 2 +- drivers/target/target_core_iblock.c | 2 +- fs/btrfs/volumes.c | 4 ++-- fs/ext4/mballoc-test.c | 2 +- fs/ext4/mballoc.c | 2 +- include/linux/blkdev.h | 5 ----- mm/swapfile.c | 2 +- 10 files changed, 10 insertions(+), 15 deletions(-)drivers/md/raid1.c +1
-1@@ -1878,7 +1878,7 @@ static bool raid1_add_conf(struct r1conf *conf, struct md_rdev *rdev, int disk,if (info->rdev)return false; -if (bdev_nonrot (rdev->bdev)) { +if (!bdev_rot (rdev->bdev)) {set_bit (Nonrot, &rdev->flags);WRITE_ONCE (conf->nonrot_disks, conf->nonrot_disks +1 ); }drivers/md/raid10.c +1
-1@@ -806,7 +806,7 @@ static struct md_rdev *read_balance(struct r10conf *conf,if (!do_balance)break ; - nonrot =bdev_nonrot (rdev->bdev); + nonrot = !bdev_rot (rdev->bdev); has_nonrot_disk |= nonrot; pending =atomic_read (&rdev->nr_pending);if (min_pending > pending && nonrot) {drivers/md/raid5.c +1
-1@@ -7541,7 +7541,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)rdev_for_each (rdev, mddev) {if (test_bit (Journal, &rdev->flags))continue ; -if (bdev_nonrot (rdev->bdev)) { +if (!bdev_rot (rdev->bdev)) { conf->batch_bio_dispatch = false;break ; }drivers/target/target_core_file.c +1
-1@@ -173,7 +173,7 @@ static int fd_configure_device(struct se_device *dev)*/ dev->dev_attrib.max_write_same_len =0xFFFF ; -if (bdev_nonrot (bdev)) +if (!bdev_rot (bdev)) dev->dev_attrib.is_nonrot =1 ; }else {if (!(fd_dev->fbd_flags &FBDF_HAS_SIZE )) {drivers/target/target_core_iblock.c +1
-1@@ -148,7 +148,7 @@ static int iblock_configure_device(struct se_device *dev)else dev->dev_attrib.max_write_same_len =0xFFFF ; -if (bdev_nonrot (bd)) +if (!bdev_rot (bd)) dev->dev_attrib.is_nonrot =1 ;target_configure_write_atomic_from_bdev (&dev->dev_attrib, bd);fs/btrfs/volumes.c +2
-2@@ -694,7 +694,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,set_bit (BTRFS_DEV_STATE_WRITEABLE , &device->dev_state); } -if (!bdev_nonrot (file_bdev (bdev_file))) +if (bdev_rot (file_bdev (bdev_file))) fs_devices->rotating = true;if (bdev_max_discard_sectors (file_bdev (bdev_file)))@@ -2919,7 +2919,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_pathatomic64_add (device->total_bytes, &fs_info->free_chunk_space); -if (!bdev_nonrot (device->bdev)) +if (bdev_rot (device->bdev)) fs_devices->rotating = true; orig_super_total_bytes =btrfs_super_total_bytes (fs_info->super_copy);fs/ext4/mballoc-test.c +1
-1@@ -72,7 +72,7 @@ static int mbt_mb_init(struct super_block *sb)ext4_fsblk_t block;int ret; -/* needed by ext4_mb_init->bdev_nonrot(sb->s_bdev) */ +/* needed by ext4_mb_init->bdev_rot(sb->s_bdev) */ sb->s_bdev =kzalloc_obj (*sb->s_bdev);if (sb->s_bdev ==NULL )return -ENOMEM ;fs/ext4/mballoc.c +1
-1@@ -3836,7 +3836,7 @@ int ext4_mb_init(struct super_block *sb)spin_lock_init (&lg->lg_prealloc_lock); } -if (bdev_nonrot (sb->s_bdev)) +if (!bdev_rot (sb->s_bdev)) sbi->s_mb_max_linear_groups =0 ;else sbi->s_mb_max_linear_groups =MB_DEFAULT_LINEAR_LIMIT ;include/linux/blkdev.h +0
-5@@ -1467,11 +1467,6 @@ static inline bool bdev_rot(struct block_device *bdev)return blk_queue_rot (bdev_get_queue (bdev)); } -static inline bool bdev_nonrot (struct block_device *bdev) -{ -return !bdev_rot (bdev); -} -static inline bool bdev_synchronous (struct block_device *bdev) {return bdev->bd_disk->queue->limits.features &BLK_FEAT_SYNCHRONOUS ;mm/swapfile.c +0
-0
mm/swapfile.c SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) · line 3466
Quoted 8 lines
mm/swapfile.c +1
-1@@ -3460,7 +3460,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)if (si->bdev &&bdev_synchronous (si->bdev)) si->flags |=SWP_SYNCHRONOUS_IO ; -if (si->bdev &&bdev_nonrot (si->bdev)) { +if (si->bdev && !bdev_rot (si->bdev)) { si->flags |=SWP_SOLIDSTATE ; }else {atomic_inc (&nr_rotate_swap);
My point above aside, the diff looks good.
Kind regards,
Paul
Quoted 6 lines · Paul Menzel
Dear Damien,
Thank you for your patch.
Quoted 6 lines
Am 26.02.26 um 08:54 schrieb Damien Le Moal:
Quoted 3 lines
bdev_nonrot()is simply the negative return value ofbdev_rot(). So replace all call sites ofbdev_nonrot()with calls tobdev_rot()and removebdev_nonrot().Is the generated code different now?
I did not check but I doubt there is any difference at all.
This is more about having a single helper function for bdevs that is consistent with the helper for request queues (blk_queue_rot()) which directly reflects the setting of a block device BLK_FEAT_ROTATIONAL queue feature. This way is also in my opinion simpler as you do not get your brain overheating when seeing things like "!bdev_nonrot()" :)
Quoted 2 lines
Is it worth the change, as it looks quite subjective if you prefer the one or the other way?
I think it is a nice cleanup, but I will let Jens and other maintainers decide on the worth of this patch.
Quoted 3 lines
My point above aside, the diff looks good.
Reviewed-by Paul Menzel <[email protected]>
Thanks.
Signature · 2 lines
Damien Le Moal Western Digital Research
Jens Axboe
maintainerQuoted 5 lines · Damien Le Moal
Quoted 2 lines
Is it worth the change, as it looks quite subjective if you prefer the one or the other way?
I think it is a nice cleanup, but I will let Jens and other maintainers decide on the worth of this patch.
It's a bit of pointless churn, but I kind of suspected this was coming when we added the bdev_rot() helper and now had both of them. So I guess we may as well finish it, as we're half-way there anyway.
Signature · 1 line
Jens Axboe
Damien,
Quoted 3 lines
bdev_nonrot()is simply the negative return value ofbdev_rot(). So replace all call sites ofbdev_nonrot()with calls tobdev_rot()and removebdev_nonrot().
Signature · 1 line
Martin K. Petersen
Quoted 5 lines · Damien Le Moal
bdev_nonrot()is simply the negative return value ofbdev_rot(). So replace all call sites ofbdev_nonrot()with calls tobdev_rot()and removebdev_nonrot().
Applied, thanks!
[1/1] block: remove bdev_nonrot()
commit: d47f7c173262bbeb09645ec72bf91755eed6b1b3
Best regards,
Signature · 1 line
Jens Axboe
Quoted 5 lines · Damien Le Moal
bdev_nonrot()is simply the negative return value ofbdev_rot(). So replace all call sites ofbdev_nonrot()with calls tobdev_rot()and removebdev_nonrot().Signed-off-by Damien Le Moal <[email protected]>
Quoted 13 lines
--- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 2 +- drivers/md/raid5.c | 2 +- drivers/target/target_core_file.c | 2 +- drivers/target/target_core_iblock.c | 2 +- fs/btrfs/volumes.c | 4 ++-- fs/ext4/mballoc-test.c | 2 +- fs/ext4/mballoc.c | 2 +- include/linux/blkdev.h | 5 ----- mm/swapfile.c | 2 +- 10 files changed, 10 insertions(+), 15 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich