[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240625115517.1472120-1-linan666@huaweicloud.com>
Date: Tue, 25 Jun 2024 19:55:17 +0800
From: linan666@...weicloud.com
To: axboe@...nel.dk
Cc: linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org,
hch@....de,
linan666@...weicloud.com,
yukuai3@...wei.com,
yi.zhang@...wei.com,
houtao1@...wei.com,
yangerkun@...wei.com
Subject: [PATCH] block: clean up the check in blkdev_iomap_begin()
From: Li Nan <linan122@...wei.com>
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 <linan122@...wei.com>
---
block/fops.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/block/fops.c b/block/fops.c
index 376265935714..bc5ad3e6197f 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -383,10 +383,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;
--
2.39.2
Powered by blists - more mailing lists