* [PATCH v3 0/3] md/bitmap: Optimal last page size
@ 2023-02-22 21:58 Jonathan Derrick
2023-02-22 21:58 ` [PATCH v3 1/3] md: Move sb writer loop to its own function Jonathan Derrick
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Jonathan Derrick @ 2023-02-22 21:58 UTC (permalink / raw)
To: Song Liu, linux-raid
Cc: Xiao Ni, Christoph Hellwig, Paul Menzel, Sushma Kalakota, Jon Derrick
From: Jon Derrick <jonathan.derrick@linux.dev>
Currently the last bitmap page write will size itself down to the logical block
size. This could cause less performance for devices which have atomic write
units larger than the block size, such as many NVMe devices with 4kB write
units and 512B block sizes. There is usually a large amount of space after the
bitmap and using the optimal I/O size could favor speed over size.
This was tested on an Intel/Solidigm P5520 drive with lba format 512B,
optimal I/O size of 4kB, resulting in a > 10x IOPS increase.
See patch 3 log for results.
v2->v3: Prep patch added and types fixed
Added helpers for optimal I/O sizes
Jon Derrick (3):
md: Move sb writer loop to its own function
md: Fix types in sb writer
md: Use optimal I/O size for last bitmap page
drivers/md/md-bitmap.c | 142 ++++++++++++++++++++++++-----------------
1 file changed, 82 insertions(+), 60 deletions(-)
--
2.27.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 1/3] md: Move sb writer loop to its own function
2023-02-22 21:58 [PATCH v3 0/3] md/bitmap: Optimal last page size Jonathan Derrick
@ 2023-02-22 21:58 ` Jonathan Derrick
2023-02-22 23:39 ` Christoph Hellwig
2023-02-23 4:05 ` kernel test robot
2023-02-22 21:58 ` [PATCH v3 2/3] md: Fix types in sb writer Jonathan Derrick
2023-02-22 21:58 ` [PATCH v3 3/3] md: Use optimal I/O size for last bitmap page Jonathan Derrick
2 siblings, 2 replies; 10+ messages in thread
From: Jonathan Derrick @ 2023-02-22 21:58 UTC (permalink / raw)
To: Song Liu, linux-raid
Cc: Xiao Ni, Christoph Hellwig, Paul Menzel, Sushma Kalakota, Jon Derrick
From: Jon Derrick <jonathan.derrick@linux.dev>
Preparatory patch for optimal I/O size calculation. Move the sb writer
loop routine into its own function for clarity.
Signed-off-by: Jon Derrick <jonathan.derrick@linux.dev>
---
drivers/md/md-bitmap.c | 123 +++++++++++++++++++++--------------------
1 file changed, 63 insertions(+), 60 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index e7cc6ba1b657..5c65268a2d97 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -209,76 +209,79 @@ static struct md_rdev *next_active_rdev(struct md_rdev *rdev, struct mddev *mdde
return NULL;
}
-static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
+static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap,
+ struct page *page)
{
- struct md_rdev *rdev;
struct block_device *bdev;
struct mddev *mddev = bitmap->mddev;
struct bitmap_storage *store = &bitmap->storage;
+ loff_t offset = mddev->bitmap_info.offset;
+ int size = PAGE_SIZE;
+
+ bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev;
+ if (page->index == store->file_pages - 1) {
+ int last_page_size = store->bytes & (PAGE_SIZE - 1);
+ if (last_page_size == 0)
+ last_page_size = PAGE_SIZE;
+ size = roundup(last_page_size,
+ bdev_logical_block_size(bdev));
+ }
+
+ /* Just make sure we aren't corrupting data or metadata */
+ if (mddev->external) {
+ /* Bitmap could be anywhere. */
+ if (rdev->sb_start + offset
+ + (page->index * (PAGE_SIZE / SECTOR_SIZE))
+ > rdev->data_offset &&
+ rdev->sb_start + offset
+ < (rdev->data_offset + mddev->dev_sectors
+ + (PAGE_SIZE / SECTOR_SIZE)))
+ return -EINVAL;
+ } else if (offset < 0) {
+ /* DATA BITMAP METADATA */
+ if (offset
+ + (long)(page->index * (PAGE_SIZE / SECTOR_SIZE))
+ + size / SECTOR_SIZE > 0)
+ /* bitmap runs in to metadata */
+ return -EINVAL;
+
+ if (rdev->data_offset + mddev->dev_sectors
+ > rdev->sb_start + offset)
+ /* data runs in to bitmap */
+ return -EINVAL;
+ } else if (rdev->sb_start < rdev->data_offset) {
+ /* METADATA BITMAP DATA */
+ if (rdev->sb_start + offset
+ + page->index * (PAGE_SIZE / SECTOR_SIZE)
+ + size / SECTOR_SIZE > rdev->data_offset)
+ /* bitmap runs in to data */
+ return -EINVAL;
+ } else {
+ /* DATA METADATA BITMAP - no problems */
+ }
-restart:
- rdev = NULL;
- while ((rdev = next_active_rdev(rdev, mddev)) != NULL) {
- int size = PAGE_SIZE;
- loff_t offset = mddev->bitmap_info.offset;
+ md_super_write(mddev, rdev,
+ rdev->sb_start + offset
+ + page->index * (PAGE_SIZE / SECTOR_SIZE),
+ size, page);
+ return 0;
+}
- bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev;
+static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
+{
+ struct md_rdev *rdev;
+ struct mddev *mddev = bitmap->mddev;
+ int ret;
- if (page->index == store->file_pages-1) {
- int last_page_size = store->bytes & (PAGE_SIZE-1);
- if (last_page_size == 0)
- last_page_size = PAGE_SIZE;
- size = roundup(last_page_size,
- bdev_logical_block_size(bdev));
- }
- /* Just make sure we aren't corrupting data or
- * metadata
- */
- if (mddev->external) {
- /* Bitmap could be anywhere. */
- if (rdev->sb_start + offset + (page->index
- * (PAGE_SIZE/512))
- > rdev->data_offset
- &&
- rdev->sb_start + offset
- < (rdev->data_offset + mddev->dev_sectors
- + (PAGE_SIZE/512)))
- goto bad_alignment;
- } else if (offset < 0) {
- /* DATA BITMAP METADATA */
- if (offset
- + (long)(page->index * (PAGE_SIZE/512))
- + size/512 > 0)
- /* bitmap runs in to metadata */
- goto bad_alignment;
- if (rdev->data_offset + mddev->dev_sectors
- > rdev->sb_start + offset)
- /* data runs in to bitmap */
- goto bad_alignment;
- } else if (rdev->sb_start < rdev->data_offset) {
- /* METADATA BITMAP DATA */
- if (rdev->sb_start
- + offset
- + page->index*(PAGE_SIZE/512) + size/512
- > rdev->data_offset)
- /* bitmap runs in to data */
- goto bad_alignment;
- } else {
- /* DATA METADATA BITMAP - no problems */
+ do {
+ while ((rdev = next_active_rdev(rdev, mddev)) != NULL) {
+ ret = __write_sb_page(rdev, bitmap, page);
+ if (ret)
+ return ret;
}
- md_super_write(mddev, rdev,
- rdev->sb_start + offset
- + page->index * (PAGE_SIZE/512),
- size,
- page);
- }
+ } while (wait && md_super_wait(mddev) < 0);
- if (wait && md_super_wait(mddev) < 0)
- goto restart;
return 0;
-
- bad_alignment:
- return -EINVAL;
}
static void md_bitmap_file_kick(struct bitmap *bitmap);
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 2/3] md: Fix types in sb writer
2023-02-22 21:58 [PATCH v3 0/3] md/bitmap: Optimal last page size Jonathan Derrick
2023-02-22 21:58 ` [PATCH v3 1/3] md: Move sb writer loop to its own function Jonathan Derrick
@ 2023-02-22 21:58 ` Jonathan Derrick
2023-02-22 23:41 ` Christoph Hellwig
2023-02-22 21:58 ` [PATCH v3 3/3] md: Use optimal I/O size for last bitmap page Jonathan Derrick
2 siblings, 1 reply; 10+ messages in thread
From: Jonathan Derrick @ 2023-02-22 21:58 UTC (permalink / raw)
To: Song Liu, linux-raid
Cc: Xiao Ni, Christoph Hellwig, Paul Menzel, Sushma Kalakota, Jon Derrick
From: Jon Derrick <jonathan.derrick@linux.dev>
Page->index is a pgoff_t and multiplying could cause overflows on a
32-bit architecture. In the sb writer, this is used to calculate and
verify the sector being used, and is multiplied by a sector value. Using
sector_t will cast it to a u64 type and is the more appropriate type for
the unit. Additionally, the integer size unit is converted to a sector
unit in later calculations, and is now corrected to be an unsigned type.
Finally, clean up the calculations using variable aliases to improve
readabiliy.
Signed-off-by: Jon Derrick <jonathan.derrick@linux.dev>
---
drivers/md/md-bitmap.c | 36 +++++++++++++++---------------------
1 file changed, 15 insertions(+), 21 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 5c65268a2d97..11f4453775ee 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -215,55 +215,49 @@ 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;
- loff_t offset = mddev->bitmap_info.offset;
- int size = PAGE_SIZE;
+ sector_t offset = mddev->bitmap_info.offset;
+ sector_t ps, sboff, doff;
+ unsigned int size = PAGE_SIZE;
bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev;
if (page->index == store->file_pages - 1) {
- int last_page_size = store->bytes & (PAGE_SIZE - 1);
+ unsigned int last_page_size = store->bytes & (PAGE_SIZE - 1);
if (last_page_size == 0)
last_page_size = PAGE_SIZE;
size = roundup(last_page_size,
bdev_logical_block_size(bdev));
}
+ ps = page->index * (PAGE_SIZE / SECTOR_SIZE);
+ sboff = rdev->sb_start + offset;
+ doff = rdev->data_offset;
+
/* Just make sure we aren't corrupting data or metadata */
if (mddev->external) {
/* Bitmap could be anywhere. */
- if (rdev->sb_start + offset
- + (page->index * (PAGE_SIZE / SECTOR_SIZE))
- > rdev->data_offset &&
- rdev->sb_start + offset
- < (rdev->data_offset + mddev->dev_sectors
- + (PAGE_SIZE / SECTOR_SIZE)))
+ if (sboff + ps > doff &&
+ sboff < (doff + mddev->dev_sectors + (PAGE_SIZE / SECTOR_SIZE)))
return -EINVAL;
} else if (offset < 0) {
/* DATA BITMAP METADATA */
- if (offset
- + (long)(page->index * (PAGE_SIZE / SECTOR_SIZE))
- + size / SECTOR_SIZE > 0)
+ if (offset + ps + size / SECTOR_SIZE > 0)
/* bitmap runs in to metadata */
return -EINVAL;
- if (rdev->data_offset + mddev->dev_sectors
- > rdev->sb_start + offset)
+ if (doff + mddev->dev_sectors > sboff)
/* data runs in to bitmap */
return -EINVAL;
} else if (rdev->sb_start < rdev->data_offset) {
/* METADATA BITMAP DATA */
- if (rdev->sb_start + offset
- + page->index * (PAGE_SIZE / SECTOR_SIZE)
- + size / SECTOR_SIZE > rdev->data_offset)
+ if (sboff + ps + size / SECTOR_SIZE > doff)
/* bitmap runs in to data */
return -EINVAL;
} else {
/* DATA METADATA BITMAP - no problems */
}
- md_super_write(mddev, rdev,
- rdev->sb_start + offset
- + page->index * (PAGE_SIZE / SECTOR_SIZE),
- size, page);
+ md_super_write(mddev, rdev, sboff + ps,
+ (int) size, page);
return 0;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 3/3] md: Use optimal I/O size for last bitmap page
2023-02-22 21:58 [PATCH v3 0/3] md/bitmap: Optimal last page size Jonathan Derrick
2023-02-22 21:58 ` [PATCH v3 1/3] md: Move sb writer loop to its own function Jonathan Derrick
2023-02-22 21:58 ` [PATCH v3 2/3] md: Fix types in sb writer Jonathan Derrick
@ 2023-02-22 21:58 ` Jonathan Derrick
2023-02-22 23:42 ` Christoph Hellwig
2 siblings, 1 reply; 10+ messages in thread
From: Jonathan Derrick @ 2023-02-22 21:58 UTC (permalink / raw)
To: Song Liu, linux-raid
Cc: Xiao Ni, Christoph Hellwig, Paul Menzel, Sushma Kalakota, Jon Derrick
From: Jon Derrick <jonathan.derrick@linux.dev>
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. The expanded
write is checked that it won't overrun the data or metadata.
The drive this was tested against has higher latencies when there are
sub-4k writes due to device-side read-mod-writes of its atomic 4k write
unit. This change helps increase performance by sizing the last bitmap
page I/O for the device's preferred write unit, if it is given.
Example Intel/Solidigm P5520
Raid10, Chunk-size 64M, bitmap-size 57228 bits
$ mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/nvme{0,1,2,3}n1
--assume-clean --bitmap=internal --bitmap-chunk=64M
$ fio --name=test --direct=1 --filename=/dev/md0 --rw=randwrite --bs=4k --runtime=60
Without patch:
write: IOPS=1676, BW=6708KiB/s (6869kB/s)(393MiB/60001msec); 0 zone resets
With patch:
write: IOPS=15.7k, BW=61.4MiB/s (64.4MB/s)(3683MiB/60001msec); 0 zone resets
Biosnoop:
Without patch:
Time Process PID Device LBA Size Lat
1.410377 md0_raid10 6900 nvme0n1 W 16 4096 0.02
1.410387 md0_raid10 6900 nvme2n1 W 16 4096 0.02
1.410374 md0_raid10 6900 nvme3n1 W 16 4096 0.01
1.410381 md0_raid10 6900 nvme1n1 W 16 4096 0.02
1.410411 md0_raid10 6900 nvme1n1 W 115346512 4096 0.01
1.410418 md0_raid10 6900 nvme0n1 W 115346512 4096 0.02
1.410915 md0_raid10 6900 nvme2n1 W 24 3584 0.43 <--
1.410935 md0_raid10 6900 nvme3n1 W 24 3584 0.45 <--
1.411124 md0_raid10 6900 nvme1n1 W 24 3584 0.64 <--
1.411147 md0_raid10 6900 nvme0n1 W 24 3584 0.66 <--
1.411176 md0_raid10 6900 nvme3n1 W 2019022184 4096 0.01
1.411189 md0_raid10 6900 nvme2n1 W 2019022184 4096 0.02
With patch:
Time Process PID Device LBA Size Lat
5.747193 md0_raid10 727 nvme0n1 W 16 4096 0.01
5.747192 md0_raid10 727 nvme1n1 W 16 4096 0.02
5.747195 md0_raid10 727 nvme3n1 W 16 4096 0.01
5.747202 md0_raid10 727 nvme2n1 W 16 4096 0.02
5.747229 md0_raid10 727 nvme3n1 W 1196223704 4096 0.02
5.747224 md0_raid10 727 nvme0n1 W 1196223704 4096 0.01
5.747279 md0_raid10 727 nvme0n1 W 24 4096 0.01 <--
5.747279 md0_raid10 727 nvme1n1 W 24 4096 0.02 <--
5.747284 md0_raid10 727 nvme3n1 W 24 4096 0.02 <--
5.747291 md0_raid10 727 nvme2n1 W 24 4096 0.02 <--
5.747314 md0_raid10 727 nvme2n1 W 2234636712 4096 0.01
5.747317 md0_raid10 727 nvme1n1 W 2234636712 4096 0.02
Signed-off-by: Jon Derrick <jonathan.derrick@linux.dev>
---
drivers/md/md-bitmap.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 11f4453775ee..196984fc3776 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -209,6 +209,28 @@ static struct md_rdev *next_active_rdev(struct md_rdev *rdev, struct mddev *mdde
return NULL;
}
+static unsigned int optimal_io_size(struct block_device *bdev,
+ unsigned int last_page_size,
+ unsigned int io_size)
+{
+ if (bdev_io_opt(bdev) > bdev_logical_block_size(bdev))
+ return roundup(last_page_size, bdev_io_opt(bdev));
+ return io_size;
+}
+
+static unsigned int bitmap_io_size(unsigned int io_size, unsigned int opt_size,
+ sector_t start, sector_t boundary)
+{
+ if (io_size != opt_size &&
+ start + opt_size / SECTOR_SIZE <= boundary)
+ return opt_size;
+ else if (start + io_size / SECTOR_SIZE <= boundary)
+ return io_size;
+
+ /* Overflows boundary */
+ return 0;
+}
+
static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap,
struct page *page)
{
@@ -218,14 +240,15 @@ static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap,
sector_t offset = mddev->bitmap_info.offset;
sector_t ps, sboff, doff;
unsigned int size = PAGE_SIZE;
+ unsigned int opt_size = PAGE_SIZE;
bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev;
if (page->index == store->file_pages - 1) {
unsigned int last_page_size = store->bytes & (PAGE_SIZE - 1);
if (last_page_size == 0)
last_page_size = PAGE_SIZE;
- size = roundup(last_page_size,
- bdev_logical_block_size(bdev));
+ size = roundup(last_page_size, bdev_logical_block_size(bdev));
+ opt_size = optimal_io_size(bdev, last_page_size, size);
}
ps = page->index * (PAGE_SIZE / SECTOR_SIZE);
@@ -240,7 +263,8 @@ static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap,
return -EINVAL;
} else if (offset < 0) {
/* DATA BITMAP METADATA */
- if (offset + ps + size / SECTOR_SIZE > 0)
+ size = bitmap_io_size(size, opt_size, offset + ps, 0);
+ if (size == 0)
/* bitmap runs in to metadata */
return -EINVAL;
@@ -249,7 +273,8 @@ static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap,
return -EINVAL;
} else if (rdev->sb_start < rdev->data_offset) {
/* METADATA BITMAP DATA */
- if (sboff + ps + size / SECTOR_SIZE > doff)
+ size = bitmap_io_size(size, opt_size, sboff + ps, doff);
+ if (size == 0)
/* bitmap runs in to data */
return -EINVAL;
} else {
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/3] md: Move sb writer loop to its own function
2023-02-22 21:58 ` [PATCH v3 1/3] md: Move sb writer loop to its own function Jonathan Derrick
@ 2023-02-22 23:39 ` Christoph Hellwig
2023-02-23 4:05 ` kernel test robot
1 sibling, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2023-02-22 23:39 UTC (permalink / raw)
To: Jonathan Derrick
Cc: Song Liu, linux-raid, Xiao Ni, Christoph Hellwig, Paul Menzel,
Sushma Kalakota
I was going to complain about the formatting, but as that gets
fixed up in the next patch:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 2/3] md: Fix types in sb writer
2023-02-22 21:58 ` [PATCH v3 2/3] md: Fix types in sb writer Jonathan Derrick
@ 2023-02-22 23:41 ` Christoph Hellwig
0 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2023-02-22 23:41 UTC (permalink / raw)
To: Jonathan Derrick
Cc: Song Liu, linux-raid, Xiao Ni, Christoph Hellwig, Paul Menzel,
Sushma Kalakota
On Wed, Feb 22, 2023 at 02:58:27PM -0700, Jonathan Derrick wrote:
> From: Jon Derrick <jonathan.derrick@linux.dev>
>
> Page->index is a pgoff_t and multiplying could cause overflows on a
> 32-bit architecture. In the sb writer, this is used to calculate and
> verify the sector being used, and is multiplied by a sector value. Using
> sector_t will cast it to a u64 type and is the more appropriate type for
> the unit. Additionally, the integer size unit is converted to a sector
> unit in later calculations, and is now corrected to be an unsigned type.
>
> Finally, clean up the calculations using variable aliases to improve
> readabiliy.
>
> Signed-off-by: Jon Derrick <jonathan.derrick@linux.dev>
> ---
> drivers/md/md-bitmap.c | 36 +++++++++++++++---------------------
> 1 file changed, 15 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> index 5c65268a2d97..11f4453775ee 100644
> --- a/drivers/md/md-bitmap.c
> +++ b/drivers/md/md-bitmap.c
> @@ -215,55 +215,49 @@ 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;
> - loff_t offset = mddev->bitmap_info.offset;
> - int size = PAGE_SIZE;
> + sector_t offset = mddev->bitmap_info.offset;
> + sector_t ps, sboff, doff;
> + unsigned int size = PAGE_SIZE;
>
> bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev;
> if (page->index == store->file_pages - 1) {
> - int last_page_size = store->bytes & (PAGE_SIZE - 1);
> + unsigned int last_page_size = store->bytes & (PAGE_SIZE - 1);
> if (last_page_size == 0)
This should probably grow an empty line after the variable
declaration (here or in the previous patch).
> + sboff < (doff + mddev->dev_sectors + (PAGE_SIZE / SECTOR_SIZE)))
No need for either pair of braces here.
> - rdev->sb_start + offset
> - + page->index * (PAGE_SIZE / SECTOR_SIZE),
> - size, page);
> + md_super_write(mddev, rdev, sboff + ps,
> + (int) size, page);
This easily fits into a single line now.
Otherwise looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 3/3] md: Use optimal I/O size for last bitmap page
2023-02-22 21:58 ` [PATCH v3 3/3] md: Use optimal I/O size for last bitmap page Jonathan Derrick
@ 2023-02-22 23:42 ` Christoph Hellwig
2023-02-22 23:48 ` Reindl Harald
0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2023-02-22 23:42 UTC (permalink / raw)
To: Jonathan Derrick
Cc: Song Liu, linux-raid, Xiao Ni, Christoph Hellwig, Paul Menzel,
Sushma Kalakota
On Wed, Feb 22, 2023 at 02:58:28PM -0700, Jonathan Derrick wrote:
> + if (io_size != opt_size &&
> + start + opt_size / SECTOR_SIZE <= boundary)
> + return opt_size;
> + else if (start + io_size / SECTOR_SIZE <= boundary)
No need for an else after a return.
Otherwise looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 3/3] md: Use optimal I/O size for last bitmap page
2023-02-22 23:42 ` Christoph Hellwig
@ 2023-02-22 23:48 ` Reindl Harald
2023-02-22 23:53 ` Christoph Hellwig
0 siblings, 1 reply; 10+ messages in thread
From: Reindl Harald @ 2023-02-22 23:48 UTC (permalink / raw)
To: Christoph Hellwig, Jonathan Derrick
Cc: Song Liu, linux-raid, Xiao Ni, Paul Menzel, Sushma Kalakota
Am 23.02.23 um 00:42 schrieb Christoph Hellwig:
> On Wed, Feb 22, 2023 at 02:58:28PM -0700, Jonathan Derrick wrote:
>> + if (io_size != opt_size &&
>> + start + opt_size / SECTOR_SIZE <= boundary)
>> + return opt_size;
>> + else if (start + io_size / SECTOR_SIZE <= boundary)
>
> No need for an else after a return.
>
> Otherwise looks good:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
the "return" is within the if-condition and has nothing to do with the
else - with {} it would be clearly visible
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 3/3] md: Use optimal I/O size for last bitmap page
2023-02-22 23:48 ` Reindl Harald
@ 2023-02-22 23:53 ` Christoph Hellwig
0 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2023-02-22 23:53 UTC (permalink / raw)
To: Reindl Harald
Cc: Christoph Hellwig, Jonathan Derrick, Song Liu, linux-raid,
Xiao Ni, Paul Menzel, Sushma Kalakota
On Thu, Feb 23, 2023 at 12:48:58AM +0100, Reindl Harald wrote:
> > > + if (io_size != opt_size &&
> > > + start + opt_size / SECTOR_SIZE <= boundary)
> > > + return opt_size;
> > > + else if (start + io_size / SECTOR_SIZE <= boundary)
> >
> > No need for an else after a return.
> >
> > Otherwise looks good:
> >
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
>
> the "return" is within the if-condition and has nothing to do with the else
> - with {} it would be clearly visible
That doesn't change the fact that it's not actually needed.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/3] md: Move sb writer loop to its own function
2023-02-22 21:58 ` [PATCH v3 1/3] md: Move sb writer loop to its own function Jonathan Derrick
2023-02-22 23:39 ` Christoph Hellwig
@ 2023-02-23 4:05 ` kernel test robot
1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-02-23 4:05 UTC (permalink / raw)
To: Jonathan Derrick, Song Liu, linux-raid
Cc: oe-kbuild-all, Xiao Ni, Christoph Hellwig, Paul Menzel,
Sushma Kalakota, Jon Derrick
Hi Jonathan,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on song-md/md-next]
[also build test WARNING on linus/master v6.2 next-20230222]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jonathan-Derrick/md-Move-sb-writer-loop-to-its-own-function/20230223-060300
base: git://git.kernel.org/pub/scm/linux/kernel/git/song/md.git md-next
patch link: https://lore.kernel.org/r/20230222215828.225-2-jonathan.derrick%40linux.dev
patch subject: [PATCH v3 1/3] md: Move sb writer loop to its own function
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230223/202302231124.oHGZxi0D-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/17d8d09a65e91fada0801ca9bf4e3560780bb543
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Jonathan-Derrick/md-Move-sb-writer-loop-to-its-own-function/20230223-060300
git checkout 17d8d09a65e91fada0801ca9bf4e3560780bb543
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash drivers/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202302231124.oHGZxi0D-lkp@intel.com/
All warnings (new ones prefixed by >>):
In function 'next_active_rdev',
inlined from 'write_sb_page' at drivers/md/md-bitmap.c:277:18:
>> drivers/md/md-bitmap.c:192:12: warning: 'rdev' is used uninitialized [-Wuninitialized]
192 | if (rdev == NULL)
| ^
drivers/md/md-bitmap.c: In function 'write_sb_page':
drivers/md/md-bitmap.c:272:25: note: 'rdev' was declared here
272 | struct md_rdev *rdev;
| ^~~~
vim +/rdev +192 drivers/md/md-bitmap.c
a654b9d8f851f4 drivers/md/bitmap.c NeilBrown 2005-06-21 175
fd01b88c75a718 drivers/md/bitmap.c NeilBrown 2011-10-11 176 static struct md_rdev *next_active_rdev(struct md_rdev *rdev, struct mddev *mddev)
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 177 {
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 178 /* Iterate the disks of an mddev, using rcu to protect access to the
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 179 * linked list, and raising the refcount of devices we return to ensure
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 180 * they don't disappear while in use.
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 181 * As devices are only added or removed when raid_disk is < 0 and
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 182 * nr_pending is 0 and In_sync is clear, the entries we return will
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 183 * still be in the same position on the list when we re-enter
fd177481b440c3 drivers/md/bitmap.c Michael Wang 2012-10-11 184 * list_for_each_entry_continue_rcu.
8532e3439087de drivers/md/bitmap.c NeilBrown 2015-05-20 185 *
8532e3439087de drivers/md/bitmap.c NeilBrown 2015-05-20 186 * Note that if entered with 'rdev == NULL' to start at the
8532e3439087de drivers/md/bitmap.c NeilBrown 2015-05-20 187 * beginning, we temporarily assign 'rdev' to an address which
8532e3439087de drivers/md/bitmap.c NeilBrown 2015-05-20 188 * isn't really an rdev, but which can be used by
8532e3439087de drivers/md/bitmap.c NeilBrown 2015-05-20 189 * list_for_each_entry_continue_rcu() to find the first entry.
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 190 */
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 191 rcu_read_lock();
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 @192 if (rdev == NULL)
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 193 /* start at the beginning */
8532e3439087de drivers/md/bitmap.c NeilBrown 2015-05-20 194 rdev = list_entry(&mddev->disks, struct md_rdev, same_set);
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 195 else {
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 196 /* release the previous rdev and start from there. */
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 197 rdev_dec_pending(rdev, mddev);
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 198 }
fd177481b440c3 drivers/md/bitmap.c Michael Wang 2012-10-11 199 list_for_each_entry_continue_rcu(rdev, &mddev->disks, same_set) {
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 200 if (rdev->raid_disk >= 0 &&
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 201 !test_bit(Faulty, &rdev->flags)) {
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 202 /* this is a usable devices */
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 203 atomic_inc(&rdev->nr_pending);
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 204 rcu_read_unlock();
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 205 return rdev;
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 206 }
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 207 }
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 208 rcu_read_unlock();
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 209 return NULL;
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 210 }
b2d2c4ceaddc30 drivers/md/bitmap.c NeilBrown 2008-09-01 211
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 212 static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap,
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 213 struct page *page)
a654b9d8f851f4 drivers/md/bitmap.c NeilBrown 2005-06-21 214 {
a6ff7e089c7fca drivers/md/bitmap.c Jonathan Brassow 2011-01-14 215 struct block_device *bdev;
fd01b88c75a718 drivers/md/bitmap.c NeilBrown 2011-10-11 216 struct mddev *mddev = bitmap->mddev;
1ec885cdd01a9a drivers/md/bitmap.c NeilBrown 2012-05-22 217 struct bitmap_storage *store = &bitmap->storage;
f6af949c567211 drivers/md/bitmap.c NeilBrown 2009-12-14 218 loff_t offset = mddev->bitmap_info.offset;
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 219 int size = PAGE_SIZE;
a6ff7e089c7fca drivers/md/bitmap.c Jonathan Brassow 2011-01-14 220
a6ff7e089c7fca drivers/md/bitmap.c Jonathan Brassow 2011-01-14 221 bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev;
9b1215c102d4b1 drivers/md/bitmap.c NeilBrown 2012-05-22 222 if (page->index == store->file_pages - 1) {
9b1215c102d4b1 drivers/md/bitmap.c NeilBrown 2012-05-22 223 int last_page_size = store->bytes & (PAGE_SIZE - 1);
9b1215c102d4b1 drivers/md/bitmap.c NeilBrown 2012-05-22 224 if (last_page_size == 0)
9b1215c102d4b1 drivers/md/bitmap.c NeilBrown 2012-05-22 225 last_page_size = PAGE_SIZE;
9b1215c102d4b1 drivers/md/bitmap.c NeilBrown 2012-05-22 226 size = roundup(last_page_size,
a6ff7e089c7fca drivers/md/bitmap.c Jonathan Brassow 2011-01-14 227 bdev_logical_block_size(bdev));
9b1215c102d4b1 drivers/md/bitmap.c NeilBrown 2012-05-22 228 }
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 229
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 230 /* Just make sure we aren't corrupting data or metadata */
f6af949c567211 drivers/md/bitmap.c NeilBrown 2009-12-14 231 if (mddev->external) {
f6af949c567211 drivers/md/bitmap.c NeilBrown 2009-12-14 232 /* Bitmap could be anywhere. */
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 233 if (rdev->sb_start + offset
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 234 + (page->index * (PAGE_SIZE / SECTOR_SIZE))
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 235 > rdev->data_offset &&
ac2f40be46ce6a drivers/md/bitmap.c NeilBrown 2010-06-01 236 rdev->sb_start + offset
ac2f40be46ce6a drivers/md/bitmap.c NeilBrown 2010-06-01 237 < (rdev->data_offset + mddev->dev_sectors
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 238 + (PAGE_SIZE / SECTOR_SIZE)))
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 239 return -EINVAL;
f6af949c567211 drivers/md/bitmap.c NeilBrown 2009-12-14 240 } else if (offset < 0) {
f0d76d70bc77b9 drivers/md/bitmap.c NeilBrown 2007-07-17 241 /* DATA BITMAP METADATA */
42a04b5078ce73 drivers/md/bitmap.c NeilBrown 2009-12-14 242 if (offset
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 243 + (long)(page->index * (PAGE_SIZE / SECTOR_SIZE))
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 244 + size / SECTOR_SIZE > 0)
f0d76d70bc77b9 drivers/md/bitmap.c NeilBrown 2007-07-17 245 /* bitmap runs in to metadata */
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 246 return -EINVAL;
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 247
58c0fed400603a drivers/md/bitmap.c Andre Noll 2009-03-31 248 if (rdev->data_offset + mddev->dev_sectors
42a04b5078ce73 drivers/md/bitmap.c NeilBrown 2009-12-14 249 > rdev->sb_start + offset)
f0d76d70bc77b9 drivers/md/bitmap.c NeilBrown 2007-07-17 250 /* data runs in to bitmap */
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 251 return -EINVAL;
0f420358e3a2ab drivers/md/bitmap.c Andre Noll 2008-07-11 252 } else if (rdev->sb_start < rdev->data_offset) {
f0d76d70bc77b9 drivers/md/bitmap.c NeilBrown 2007-07-17 253 /* METADATA BITMAP DATA */
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 254 if (rdev->sb_start + offset
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 255 + page->index * (PAGE_SIZE / SECTOR_SIZE)
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 256 + size / SECTOR_SIZE > rdev->data_offset)
f0d76d70bc77b9 drivers/md/bitmap.c NeilBrown 2007-07-17 257 /* bitmap runs in to data */
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 258 return -EINVAL;
f0d76d70bc77b9 drivers/md/bitmap.c NeilBrown 2007-07-17 259 } else {
f0d76d70bc77b9 drivers/md/bitmap.c NeilBrown 2007-07-17 260 /* DATA METADATA BITMAP - no problems */
f0d76d70bc77b9 drivers/md/bitmap.c NeilBrown 2007-07-17 261 }
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 262
a654b9d8f851f4 drivers/md/bitmap.c NeilBrown 2005-06-21 263 md_super_write(mddev, rdev,
42a04b5078ce73 drivers/md/bitmap.c NeilBrown 2009-12-14 264 rdev->sb_start + offset
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 265 + page->index * (PAGE_SIZE / SECTOR_SIZE),
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 266 size, page);
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 267 return 0;
ab6085c795a71b drivers/md/bitmap.c NeilBrown 2007-05-23 268 }
a654b9d8f851f4 drivers/md/bitmap.c NeilBrown 2005-06-21 269
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 270 static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 271 {
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 272 struct md_rdev *rdev;
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 273 struct mddev *mddev = bitmap->mddev;
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 274 int ret;
4b80991c6cb9ef drivers/md/bitmap.c NeilBrown 2008-07-21 275
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 276 do {
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 @277 while ((rdev = next_active_rdev(rdev, mddev)) != NULL) {
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 278 ret = __write_sb_page(rdev, bitmap, page);
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 279 if (ret)
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 280 return ret;
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 281 }
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 282 } while (wait && md_super_wait(mddev) < 0);
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 283
17d8d09a65e91f drivers/md/md-bitmap.c Jon Derrick 2023-02-22 284 return 0;
a654b9d8f851f4 drivers/md/bitmap.c NeilBrown 2005-06-21 285 }
a654b9d8f851f4 drivers/md/bitmap.c NeilBrown 2005-06-21 286
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-02-23 4:05 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22 21:58 [PATCH v3 0/3] md/bitmap: Optimal last page size Jonathan Derrick
2023-02-22 21:58 ` [PATCH v3 1/3] md: Move sb writer loop to its own function Jonathan Derrick
2023-02-22 23:39 ` Christoph Hellwig
2023-02-23 4:05 ` kernel test robot
2023-02-22 21:58 ` [PATCH v3 2/3] md: Fix types in sb writer Jonathan Derrick
2023-02-22 23:41 ` Christoph Hellwig
2023-02-22 21:58 ` [PATCH v3 3/3] md: Use optimal I/O size for last bitmap page Jonathan Derrick
2023-02-22 23:42 ` Christoph Hellwig
2023-02-22 23:48 ` Reindl Harald
2023-02-22 23:53 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.