Skip to content

Commit 6549a87

Browse files
isilenceaxboe
authored andcommitted
block: convert fops.c magic constants to SHIFT_SECTOR
Don't use shifting by a magic number 9 but replace with a more descriptive SHIFT_SECTOR. Signed-off-by: Pavel Begunkov <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/068782b9f7e97569fb59a99529b23bb17ea4c5e2.1634755800.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 179ae84 commit 6549a87

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

block/fops.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb,
7676

7777
bio_init(&bio, vecs, nr_pages);
7878
bio_set_dev(&bio, bdev);
79-
bio.bi_iter.bi_sector = pos >> 9;
79+
bio.bi_iter.bi_sector = pos >> SECTOR_SHIFT;
8080
bio.bi_write_hint = iocb->ki_hint;
8181
bio.bi_private = current;
8282
bio.bi_end_io = blkdev_bio_end_io_simple;
@@ -225,7 +225,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
225225

226226
for (;;) {
227227
bio_set_dev(bio, bdev);
228-
bio->bi_iter.bi_sector = pos >> 9;
228+
bio->bi_iter.bi_sector = pos >> SECTOR_SHIFT;
229229
bio->bi_write_hint = iocb->ki_hint;
230230
bio->bi_private = dio;
231231
bio->bi_end_io = blkdev_bio_end_io;
@@ -565,16 +565,18 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
565565
switch (mode) {
566566
case FALLOC_FL_ZERO_RANGE:
567567
case FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE:
568-
error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9,
569-
GFP_KERNEL, BLKDEV_ZERO_NOUNMAP);
568+
error = blkdev_issue_zeroout(bdev, start >> SECTOR_SHIFT,
569+
len >> SECTOR_SHIFT, GFP_KERNEL,
570+
BLKDEV_ZERO_NOUNMAP);
570571
break;
571572
case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE:
572-
error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9,
573-
GFP_KERNEL, BLKDEV_ZERO_NOFALLBACK);
573+
error = blkdev_issue_zeroout(bdev, start >> SECTOR_SHIFT,
574+
len >> SECTOR_SHIFT, GFP_KERNEL,
575+
BLKDEV_ZERO_NOFALLBACK);
574576
break;
575577
case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE:
576-
error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
577-
GFP_KERNEL, 0);
578+
error = blkdev_issue_discard(bdev, start >> SECTOR_SHIFT,
579+
len >> SECTOR_SHIFT, GFP_KERNEL, 0);
578580
break;
579581
default:
580582
error = -EOPNOTSUPP;

0 commit comments

Comments
 (0)