Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: introduce bdev_rot()

Introduce the helper function bdev_rot() to test if a block device is a
rotational one. The existing function bdev_nonrot() which tests for the
opposite condition is redefined using this new helper.
This avoids the double negation (operator and name) that appears when
testing if a block device is a rotational device, thus making the code a
little easier to read.

Call sites of bdev_nonrot() in the block layer are updated to use this
new helper. Remaining users in other subsystems are left unchanged for
now.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Damien Le Moal and committed by
Jens Axboe
da562d92 ad5f2e29

+10 -5
+1 -1
block/ioctl.c
··· 692 692 queue_max_sectors(bdev_get_queue(bdev))); 693 693 return put_ushort(argp, max_sectors); 694 694 case BLKROTATIONAL: 695 - return put_ushort(argp, !bdev_nonrot(bdev)); 695 + return put_ushort(argp, bdev_rot(bdev)); 696 696 case BLKRASET: 697 697 case BLKFRASET: 698 698 if(!capable(CAP_SYS_ADMIN))
+1 -1
drivers/block/loop.c
··· 969 969 lim->features &= ~(BLK_FEAT_WRITE_CACHE | BLK_FEAT_ROTATIONAL); 970 970 if (file->f_op->fsync && !(lo->lo_flags & LO_FLAGS_READ_ONLY)) 971 971 lim->features |= BLK_FEAT_WRITE_CACHE; 972 - if (backing_bdev && !bdev_nonrot(backing_bdev)) 972 + if (backing_bdev && bdev_rot(backing_bdev)) 973 973 lim->features |= BLK_FEAT_ROTATIONAL; 974 974 lim->max_hw_discard_sectors = max_discard_sectors; 975 975 lim->max_write_zeroes_sectors = max_discard_sectors;
+2 -2
drivers/nvme/target/admin-cmd.c
··· 298 298 if (status) 299 299 goto out; 300 300 301 - if (!req->ns->bdev || bdev_nonrot(req->ns->bdev)) { 301 + if (!req->ns->bdev || !bdev_rot(req->ns->bdev)) { 302 302 status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR; 303 303 goto out; 304 304 } ··· 1084 1084 id->nmic = NVME_NS_NMIC_SHARED; 1085 1085 if (req->ns->readonly) 1086 1086 id->nsattr |= NVME_NS_ATTR_RO; 1087 - if (req->ns->bdev && !bdev_nonrot(req->ns->bdev)) 1087 + if (req->ns->bdev && bdev_rot(req->ns->bdev)) 1088 1088 id->nsfeat |= NVME_NS_ROTATIONAL; 1089 1089 /* 1090 1090 * We need flush command to flush the file's metadata,
+6 -1
include/linux/blkdev.h
··· 1461 1461 return bdev_limits(bdev)->max_wzeroes_unmap_sectors; 1462 1462 } 1463 1463 1464 + static inline bool bdev_rot(struct block_device *bdev) 1465 + { 1466 + return blk_queue_rot(bdev_get_queue(bdev)); 1467 + } 1468 + 1464 1469 static inline bool bdev_nonrot(struct block_device *bdev) 1465 1470 { 1466 - return !blk_queue_rot(bdev_get_queue(bdev)); 1471 + return !bdev_rot(bdev); 1467 1472 } 1468 1473 1469 1474 static inline bool bdev_synchronous(struct block_device *bdev)