Skip to contentSkip to conversation

md: Fix bitmap offset type in sb writer

PATCH In review Jonathan Derrick 3 participants 8 messages Apr 25, 2023 – Apr 28, 2023 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md: Fix bitmap offset type in sb writer

Bitmap offset is allowed to be negative, indicating that bitmap precedes metadata. Change the type back from sector_t to loff_t to satisfy conditionals and calculations.

---
 drivers/md/md-bitmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/md-bitmap.c +2 -2
index 920bb68156d2..29ae7f7015e4 100644
@@ -237,8 +237,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;
-	sector_t offset = mddev->bitmap_info.offset;
-	sector_t ps, sboff, doff;
+	loff_t sboff, offset = mddev->bitmap_info.offset;
+	sector_t ps, doff;
 	unsigned int size = PAGE_SIZE;
 	unsigned int opt_size = PAGE_SIZE;
 
Signature · 1 line
2.40.0
maintainer
#1 lore raw
Quoted 6 lines · Jonathan Derrick

Bitmap offset is allowed to be negative, indicating that bitmap precedes metadata. Change the type back from sector_t to loff_t to satisfy conditionals and calculations.

I added the following to the patch and applied it to md-next.

Thanks,
Song

Fixes 10172f200b67 ("md: Fix types in sb writer")
Quoted 22 lines
---
 drivers/md/md-bitmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/md-bitmap.c +2 -3
index 920bb68156d2..29ae7f7015e4 100644
@@ -237,8 +237,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;
-       sector_t offset = mddev->bitmap_info.offset;
-       sector_t ps, sboff, doff;
+       loff_t sboff, offset = mddev->bitmap_info.offset;
+       sector_t ps, doff;
        unsigned int size = PAGE_SIZE;
        unsigned int opt_size = PAGE_SIZE;
 
--

2.40.0

maintainer
#2 lore raw

Hi Jonathan,

Quoted 7 lines · Song Liu
Quoted 4 lines · Jonathan Derrick

Bitmap offset is allowed to be negative, indicating that bitmap precedes metadata. Change the type back from sector_t to loff_t to satisfy conditionals and calculations.

This actually breaks the following tests from mdadm:

05r1-add-internalbitmap-v1a
05r1-internalbitmap-v1a
05r1-remove-internalbitmap-v1a

Please look into these.

Thanks,
Song

Quoted 33 lines
Quoted 2 lines

I added the following to the patch and applied it to md-next.

Thanks,
Song

Fixes 10172f200b67 ("md: Fix types in sb writer")
Quoted 22 lines
---
 drivers/md/md-bitmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/md-bitmap.c +2 -3
index 920bb68156d2..29ae7f7015e4 100644
@@ -237,8 +237,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;
-       sector_t offset = mddev->bitmap_info.offset;
-       sector_t ps, sboff, doff;
+       loff_t sboff, offset = mddev->bitmap_info.offset;
+       sector_t ps, doff;
        unsigned int size = PAGE_SIZE;
        unsigned int opt_size = PAGE_SIZE;
 
--

2.40.0

#3 lore raw

Hi Song,

Quoted 11 lines · Song Liu

Hi Jonathan,

Quoted 7 lines · Song Liu
Quoted 4 lines · Jonathan Derrick

Bitmap offset is allowed to be negative, indicating that bitmap precedes metadata. Change the type back from sector_t to loff_t to satisfy conditionals and calculations.

Quoted 8 lines

This actually breaks the following tests from mdadm:

05r1-add-internalbitmap-v1a
05r1-internalbitmap-v1a
05r1-remove-internalbitmap-v1a

Please look into these.

I no longer work for Solidigm and don't have access to equipment that can test this. I'm CCing Sushma and Michael who should be able to test and report back.

Thanks,
Jon

Quoted 36 lines

Thanks,
Song

Quoted 33 lines
Quoted 2 lines

I added the following to the patch and applied it to md-next.

Thanks,
Song

Fixes 10172f200b67 ("md: Fix types in sb writer")
Quoted 22 lines
---
  drivers/md/md-bitmap.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/md-bitmap.c +2 -3
index 920bb68156d2..29ae7f7015e4 100644
@@ -237,8 +237,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;
-       sector_t offset = mddev->bitmap_info.offset;
-       sector_t ps, sboff, doff;
+       loff_t sboff, offset = mddev->bitmap_info.offset;
+       sector_t ps, doff;
         unsigned int size = PAGE_SIZE;
         unsigned int opt_size = PAGE_SIZE;
 
--

2.40.0

#4 lore raw
In reply to Song Liu

Hi,

Quoted 7 lines · Song Liu

Hi Jonathan,

Quoted 4 lines · Song Liu
Quoted 1 line · Jonathan Derrick
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

Bitmap offset is allowed to be negative, indicating that bitmap precedes metadata. Change the type back from sector_t to loff_t to satisfy conditionals and calculations.

This actually breaks the following tests from mdadm:

05r1-add-internalbitmap-v1a

After a quick look of this test, I think the root cause is another patch:

commit 8745faa95611 ("md: Use optimal I/O size for last bitmap page")

This patch add a new helper bitmap_io_size(), which breaks the condition that 'negative value < 0'.

And following patch should fix this problem:

drivers/md/md-bitmap.c +0 -0
index adbe95e03852..b1b521837156 100644
@@ -219,8 +219,9 @@ static unsigned int optimal_io_size(struct block_device *bdev,
 }
 
 static unsigned int bitmap_io_size(unsigned int io_size, unsigned int 

opt_size,
- sector_t start, sector_t boundary)
+ loff_t start, loff_t boundary)
{

Quoted 3 lines

05r1-internalbitmap-v1a
05r1-remove-internalbitmap-v1a

The patch is not tested yet, and I don't have time to look other tests yet...

Thanks,
Kuai

Quoted 4 lines

Please look into these.

Thanks,
Song

maintainer
#5 lore raw
Quoted 47 lines · Yu Kuai

Hi,

Quoted 7 lines · Song Liu

Hi Jonathan,

Quoted 4 lines · Song Liu
Quoted 1 line · Jonathan Derrick
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

Bitmap offset is allowed to be negative, indicating that bitmap precedes metadata. Change the type back from sector_t to loff_t to satisfy conditionals and calculations.

This actually breaks the following tests from mdadm:

05r1-add-internalbitmap-v1a

After a quick look of this test, I think the root cause is another patch:

commit 8745faa95611 ("md: Use optimal I/O size for last bitmap page")

This patch add a new helper bitmap_io_size(), which breaks the condition that 'negative value < 0'.

And following patch should fix this problem:

drivers/md/md-bitmap.c +1 -1
index adbe95e03852..b1b521837156 100644
@@ -219,8 +219,9 @@ static unsigned int optimal_io_size(struct
 block_device *bdev,
  }
 
  static unsigned int bitmap_io_size(unsigned int io_size, unsigned int
 opt_size,
-                                  sector_t start, sector_t boundary)
+                                  loff_t start, loff_t boundary)
  {
 
Quoted 3 lines

05r1-internalbitmap-v1a
05r1-remove-internalbitmap-v1a

Quoted 2 lines

The patch is not tested yet, and I don't have time to look other tests yet...

Thanks Kuai! This fixed the test.

I will add your Signed-off-by to the patch. Please let me know if you prefer not to have it.

Song

#6 lore raw

Hi,

Quoted 44 lines · Song Liu
Quoted 43 lines · Yu Kuai

Hi,

Quoted 7 lines · Song Liu

Hi Jonathan,

Quoted 4 lines · Song Liu
Quoted 1 line · Jonathan Derrick
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

Bitmap offset is allowed to be negative, indicating that bitmap precedes metadata. Change the type back from sector_t to loff_t to satisfy conditionals and calculations.

This actually breaks the following tests from mdadm:

05r1-add-internalbitmap-v1a

After a quick look of this test, I think the root cause is another patch:

commit 8745faa95611 ("md: Use optimal I/O size for last bitmap page")

This patch add a new helper bitmap_io_size(), which breaks the condition that 'negative value < 0'.

And following patch should fix this problem:

drivers/md/md-bitmap.c +1 -1
index adbe95e03852..b1b521837156 100644
@@ -219,8 +219,9 @@ static unsigned int optimal_io_size(struct
 block_device *bdev,
   }
 
   static unsigned int bitmap_io_size(unsigned int io_size, unsigned int
 opt_size,
-                                  sector_t start, sector_t boundary)
+                                  loff_t start, loff_t boundary)
   {
 
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

05r1-internalbitmap-v1a
05r1-remove-internalbitmap-v1a

The patch is not tested yet, and I don't have time to look other tests yet...

Thanks Kuai! This fixed the test.

Thanks for the test, I'll check more details and try tests myself later.

Kuai

Quoted 7 lines

I will add your Signed-off-by to the patch. Please let me know if you prefer not to have it.

Song
.

#7 lore raw

Hi,

Quoted 51 lines · Yu Kuai

Hi,

Quoted 48 lines · Song Liu
Quoted 47 lines · Yu Kuai

Hi,

Quoted 7 lines · Song Liu

Hi Jonathan,

Quoted 4 lines · Song Liu
Quoted 1 line · Jonathan Derrick
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

Bitmap offset is allowed to be negative, indicating that bitmap precedes metadata. Change the type back from sector_t to loff_t to satisfy conditionals and calculations.

This actually breaks the following tests from mdadm:

05r1-add-internalbitmap-v1a

After a quick look of this test, I think the root cause is another patch:

commit 8745faa95611 ("md: Use optimal I/O size for last bitmap page")

This patch add a new helper bitmap_io_size(), which breaks the condition that 'negative value < 0'.

And following patch should fix this problem:

drivers/md/md-bitmap.c +0 -0
index adbe95e03852..b1b521837156 100644
@@ -219,8 +219,9 @@ static unsigned int optimal_io_size(struct
 block_device *bdev,
    }
 

   static unsigned int bitmap_io_size(unsigned int io_size, unsigned int opt_size,
-                                  sector_t start, sector_t boundary) +                                  loff_t start, loff_t boundary) {

Quoted 3 lines

05r1-internalbitmap-v1a
05r1-remove-internalbitmap-v1a

Quoted 11 lines
Quoted 4 lines
Quoted 2 lines

The patch is not tested yet, and I don't have time to look other tests yet...

Thanks Kuai! This fixed the test.

Thanks for the test, I'll check more details and try tests myself later.

Kuai

Quoted 3 lines

I will add your Signed-off-by to the patch. Please let me know if you prefer not to have it.

I just reviewed realted patches and tested myself, perhaps it'll be better to use Suggested-and-reviewed-by, anyway, I'm good with either way.

Thanks,
Kuai

Quoted 7 lines
Quoted 4 lines

Song
.

.