Commit 0c3ea5cc authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Song Liu

md-bitmap: cleanup read_sb_page

Convert read_sb_page to the normal kernel coding style, calculate the
target sector only once, and add a local iosize variable to make the call
to sync_page_io more readable.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: default avatarSong Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230615064840.629492-8-hch@lst.de
parent 844dc669
...@@ -139,26 +139,25 @@ static void md_bitmap_checkfree(struct bitmap_counts *bitmap, unsigned long page ...@@ -139,26 +139,25 @@ static void md_bitmap_checkfree(struct bitmap_counts *bitmap, unsigned long page
*/ */
/* IO operations when bitmap is stored near all superblocks */ /* IO operations when bitmap is stored near all superblocks */
/* choose a good rdev and read the page from there */
static int read_sb_page(struct mddev *mddev, loff_t offset, static int read_sb_page(struct mddev *mddev, loff_t offset,
struct page *page, struct page *page, unsigned long index, int size)
unsigned long index, int size)
{ {
/* choose a good rdev and read the page from there */
sector_t sector = offset + index * (PAGE_SIZE / SECTOR_SIZE);
struct md_rdev *rdev; struct md_rdev *rdev;
sector_t target;
rdev_for_each(rdev, mddev) { rdev_for_each(rdev, mddev) {
if (! test_bit(In_sync, &rdev->flags) u32 iosize = roundup(size, bdev_logical_block_size(rdev->bdev));
|| test_bit(Faulty, &rdev->flags)
|| test_bit(Bitmap_sync, &rdev->flags))
continue;
target = offset + index * (PAGE_SIZE/512); if (!test_bit(In_sync, &rdev->flags) ||
test_bit(Faulty, &rdev->flags) ||
test_bit(Bitmap_sync, &rdev->flags))
continue;
if (sync_page_io(rdev, target, if (sync_page_io(rdev, sector, iosize, page, REQ_OP_READ,
roundup(size, bdev_logical_block_size(rdev->bdev)), true)) {
page, REQ_OP_READ, true)) {
page->index = index; page->index = index;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment