Message ID | 6083cbff-0896-46af-bd76-1e0f173538b7@redhat.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | md bitmap writes random memory over disks' bitmap sectors | expand |
Context | Check | Description |
---|---|---|
mdraidci/vmtest-md-6_14-PR | fail | merge-conflict |
Hi, 在 2025/02/25 23:32, Nigel Croxon 写道: > - md_super_write(mddev, rdev, sboff + ps, (int) size, page); > + md_super_write(mddev, rdev, sboff + ps, (int)min(size, > bitmap_limit), page); > return 0; > > This patch still will attempt to send writes greater than a page using > only a single page pointer for multi-page bitmaps. The bitmap uses an > array (the filemap) of pages when the bitmap cannot fit in a single > page. These pages are allocated separately and not guaranteed to be > contiguous. So this patch will keep writes in a multi-page bitmap from > trashing data beyond the bitmap, but can create writes which corrupt > other parts of the bitmap with random memory. Is this problem introduced by: 8745faa95611 ("md: Use optimal I/O size for last bitmap page") > > The opt using logic in this function is fundamentally flawed as > __write_sb_page should never send a write bigger than a page at a time. > It would need to use a new interface which can build multi-page bio and > not md_super_write() if it wanted to send multi-page I/Os. I argree. And I don't understand that patch yet, it said: If the bitmap space has enough room, size the I/O for the last bitmap page write to the optimal I/O size for the storage device. Does this mean, for example, if bitmap space is 128k, while there is only one page, means 124k is not used. In this case, if device opt io size is 128k, this patch will choose to issue 128k IO instead of just 4k IO? And how can this improve performance ... Thanks, Kuai
On Fri, Feb 28, 2025 at 10:07 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: > > Hi, > > 在 2025/02/25 23:32, Nigel Croxon 写道: > > - md_super_write(mddev, rdev, sboff + ps, (int) size, page); > > + md_super_write(mddev, rdev, sboff + ps, (int)min(size, > > bitmap_limit), page); > > return 0; > > > > This patch still will attempt to send writes greater than a page using > > only a single page pointer for multi-page bitmaps. The bitmap uses an > > array (the filemap) of pages when the bitmap cannot fit in a single > > page. These pages are allocated separately and not guaranteed to be > > contiguous. So this patch will keep writes in a multi-page bitmap from > > trashing data beyond the bitmap, but can create writes which corrupt > > other parts of the bitmap with random memory. > > Is this problem introduced by: > > 8745faa95611 ("md: Use optimal I/O size for last bitmap page") I think so. > > > > > The opt using logic in this function is fundamentally flawed as > > __write_sb_page should never send a write bigger than a page at a time. > > It would need to use a new interface which can build multi-page bio and > > not md_super_write() if it wanted to send multi-page I/Os. > > I argree. And I don't understand that patch yet, it said: > > If the bitmap space has enough room, size the I/O for the last bitmap > page write to the optimal I/O size for the storage device. > > Does this mean, for example, if bitmap space is 128k, while there is > only one page, means 124k is not used. In this case, if device opt io > size is 128k, this patch will choose to issue 128k IO instead of just > 4k IO? And how can this improve performance ... It looks like it does as you mentioned above. Through the commit 8745faa95611 message, the io size(3584 bytes, 7 sectors) is smaller than 4K. Without the patch 8745faa95611, the io size is round up with bdev_logical_block_size(bdev). If we round up io size with PAGE_SIZE, can it fix the performance problem? Because bitmap space is 4K/64K/128K, if it doesn't affect performance only changing the round up value to PAGE_SIZE, it'll easy to fix this problem. Best Regards Xiao > Thanks, > Kuai > >
On Fri, Feb 28, 2025 at 10:07 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: > > Hi, > > 在 2025/02/25 23:32, Nigel Croxon 写道: > > - md_super_write(mddev, rdev, sboff + ps, (int) size, page); > > + md_super_write(mddev, rdev, sboff + ps, (int)min(size, > > bitmap_limit), page); > > return 0; > > > > This patch still will attempt to send writes greater than a page using > > only a single page pointer for multi-page bitmaps. The bitmap uses an > > array (the filemap) of pages when the bitmap cannot fit in a single > > page. These pages are allocated separately and not guaranteed to be > > contiguous. So this patch will keep writes in a multi-page bitmap from > > trashing data beyond the bitmap, but can create writes which corrupt > > other parts of the bitmap with random memory. > > Is this problem introduced by: > > 8745faa95611 ("md: Use optimal I/O size for last bitmap page") > > > > > The opt using logic in this function is fundamentally flawed as > > __write_sb_page should never send a write bigger than a page at a time. > > It would need to use a new interface which can build multi-page bio and > > not md_super_write() if it wanted to send multi-page I/Os. > > I argree. And I don't understand that patch yet, it said: > > If the bitmap space has enough room, size the I/O for the last bitmap > page write to the optimal I/O size for the storage device. > > Does this mean, for example, if bitmap space is 128k, while there is > only one page, means 124k is not used. In this case, if device opt io > size is 128k, this patch will choose to issue 128k IO instead of just > 4k IO? And how can this improve performance ... This problem should already be fixed by patch commit ab99a87542f194f28e2364a42afbf9fb48b1c724 Author: Ofir Gal <ofir.gal@volumez.com> Date: Fri Jun 7 10:27:44 2024 +0300 md/md-bitmap: fix writing non bitmap pages Regards Xiao > > Thanks, > Kuai > >
On Fri 28 Feb 2025 at 15:46, Xiao Ni <xni@redhat.com> wrote: > On Fri, Feb 28, 2025 at 10:07 AM Yu Kuai > <yukuai1@huaweicloud.com> wrote: >> >> Hi, >> >> 在 2025/02/25 23:32, Nigel Croxon 写道: >> > - md_super_write(mddev, rdev, sboff + ps, (int) size, >> > page); >> > + md_super_write(mddev, rdev, sboff + ps, >> > (int)min(size, >> > bitmap_limit), page); >> > return 0; >> > >> > This patch still will attempt to send writes greater than a >> > page using >> > only a single page pointer for multi-page bitmaps. The bitmap >> > uses an >> > array (the filemap) of pages when the bitmap cannot fit in a >> > single >> > page. These pages are allocated separately and not guaranteed >> > to be >> > contiguous. So this patch will keep writes in a multi-page >> > bitmap from >> > trashing data beyond the bitmap, but can create writes which >> > corrupt >> > other parts of the bitmap with random memory. >> >> Is this problem introduced by: >> >> 8745faa95611 ("md: Use optimal I/O size for last bitmap page") > > I think so. > >> >> > >> > The opt using logic in this function is fundamentally flawed >> > as >> > __write_sb_page should never send a write bigger than a page >> > at a time. >> > It would need to use a new interface which can build >> > multi-page bio and >> > not md_super_write() if it wanted to send multi-page I/Os. >> >> I argree. And I don't understand that patch yet, it said: >> >> If the bitmap space has enough room, size the I/O for the last >> bitmap >> page write to the optimal I/O size for the storage device. >> >> Does this mean, for example, if bitmap space is 128k, while >> there is >> only one page, means 124k is not used. In this case, if device >> opt io >> size is 128k, this patch will choose to issue 128k IO instead >> of just >> 4k IO? And how can this improve performance ... > > It looks like it does as you mentioned above. Through the commit > 8745faa95611 message, the io size(3584 bytes, 7 sectors) is > smaller > than 4K. Without the patch 8745faa95611, the io size is round > up with > bdev_logical_block_size(bdev). If we round up io size with > PAGE_SIZE, > can it fix the performance problem? Because bitmap space is > 4K/64K/128K, if it doesn't affect performance only changing the > round > up value to PAGE_SIZE, it'll easy to fix this problem. > I'm afiraid that the perf will drop if rounding up io size to 4K for devices optimal I/O size smaller than 4K. IMO better version of md_super_write to is necessary to handle bitmap pages as Nigel said. -- Su > Best Regards > Xiao > >> Thanks, >> Kuai >> >>
On Mon, Mar 3, 2025 at 11:16 PM Su Yue <l@damenly.org> wrote: > > On Fri 28 Feb 2025 at 15:46, Xiao Ni <xni@redhat.com> wrote: > > > On Fri, Feb 28, 2025 at 10:07 AM Yu Kuai > > <yukuai1@huaweicloud.com> wrote: > >> > >> Hi, > >> > >> 在 2025/02/25 23:32, Nigel Croxon 写道: > >> > - md_super_write(mddev, rdev, sboff + ps, (int) size, > >> > page); > >> > + md_super_write(mddev, rdev, sboff + ps, > >> > (int)min(size, > >> > bitmap_limit), page); > >> > return 0; > >> > > >> > This patch still will attempt to send writes greater than a > >> > page using > >> > only a single page pointer for multi-page bitmaps. The bitmap > >> > uses an > >> > array (the filemap) of pages when the bitmap cannot fit in a > >> > single > >> > page. These pages are allocated separately and not guaranteed > >> > to be > >> > contiguous. So this patch will keep writes in a multi-page > >> > bitmap from > >> > trashing data beyond the bitmap, but can create writes which > >> > corrupt > >> > other parts of the bitmap with random memory. > >> > >> Is this problem introduced by: > >> > >> 8745faa95611 ("md: Use optimal I/O size for last bitmap page") > > > > I think so. > > > >> > >> > > >> > The opt using logic in this function is fundamentally flawed > >> > as > >> > __write_sb_page should never send a write bigger than a page > >> > at a time. > >> > It would need to use a new interface which can build > >> > multi-page bio and > >> > not md_super_write() if it wanted to send multi-page I/Os. > >> > >> I argree. And I don't understand that patch yet, it said: > >> > >> If the bitmap space has enough room, size the I/O for the last > >> bitmap > >> page write to the optimal I/O size for the storage device. > >> > >> Does this mean, for example, if bitmap space is 128k, while > >> there is > >> only one page, means 124k is not used. In this case, if device > >> opt io > >> size is 128k, this patch will choose to issue 128k IO instead > >> of just > >> 4k IO? And how can this improve performance ... > > > > It looks like it does as you mentioned above. Through the commit > > 8745faa95611 message, the io size(3584 bytes, 7 sectors) is > > smaller > > than 4K. Without the patch 8745faa95611, the io size is round > > up with > > bdev_logical_block_size(bdev). If we round up io size with > > PAGE_SIZE, > > can it fix the performance problem? Because bitmap space is > > 4K/64K/128K, if it doesn't affect performance only changing the > > round > > up value to PAGE_SIZE, it'll easy to fix this problem. > > > > I'm afiraid that the perf will drop if rounding up io size to 4K > for devices > optimal I/O size smaller than 4K. IMO better version of > md_super_write to is > necessary to handle bitmap pages as Nigel said. > > -- > Su Hi Su You're right. Thanks for pointing out this. Best Regards Xiao > > > Best Regards > > Xiao > > > >> Thanks, > >> Kuai > >> > >> >
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 0a2d37eb38ef..08232d8dc815 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -227,6 +227,8 @@ static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap, struct block_device *bdev; struct mddev *mddev = bitmap->mddev; struct bitmap_storage *store = &bitmap->storage; + unsigned int bitmap_limit = (bitmap->storage.file_pages - pg_index) << + PAGE_SHIFT; loff_t sboff, offset = mddev->bitmap_info.offset;