From: Li Nan Date: Tue, 25 Jun 2024 11:55:17 +0000 (+0800) Subject: block: clean up the check in blkdev_iomap_begin() X-Git-Tag: v6.11-rc1~80^2~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e269537e491da6336776b5548a3c73f62273aa15;p=thirdparty%2Flinux.git 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 Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/20240625115517.1472120-1-linan666@huaweicloud.com Signed-off-by: Jens Axboe --- diff --git a/block/fops.c b/block/fops.c index be36c9fbd500b..9825c1713a49a 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;