aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Nan <[email protected]>2024-06-25 19:55:17 +0800
committerJens Axboe <[email protected]>2024-06-27 05:56:35 -0600
commite269537e491da6336776b5548a3c73f62273aa15 (patch)
tree3c1e130b5d8c331d33ca76b0117d13e9f5ae8639
parent69b6517687a4b1fb250bd8c9c193a0a304c8ba17 (diff)
block: clean up the check in blkdev_iomap_begin()
It is odd to check the offset amidst a series of assignments. Moving this check to the beginning of the function makes the code look better. Signed-off-by: Li Nan <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
-rw-r--r--block/fops.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/block/fops.c b/block/fops.c
index be36c9fbd500..9825c1713a49 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -394,10 +394,11 @@ static int blkdev_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
struct block_device *bdev = I_BDEV(inode);
loff_t isize = i_size_read(inode);
- iomap->bdev = bdev;
- iomap->offset = ALIGN_DOWN(offset, bdev_logical_block_size(bdev));
if (offset >= isize)
return -EIO;
+
+ iomap->bdev = bdev;
+ iomap->offset = ALIGN_DOWN(offset, bdev_logical_block_size(bdev));
iomap->type = IOMAP_MAPPED;
iomap->addr = iomap->offset;
iomap->length = isize - iomap->offset;