md: change bitmap offset verification in write_sb_page
PATCH 1/1 md: change bitmap offset verification in write_sb_page
From: Jakub Radtke <[email protected]>
Removes the code that is correct only for the native metadata. Write-intent bitmap support for the other metadata formats is blocked.
rdev->sb_start is used in the calculations.
The sb_start is only set and used for native metadata format, and the bitmap offset check will always fail if it is not set.
In the case of external metadata, the bitmap can be placed in various places e.g. like the PPL between two volumes (the boundary checks are performed on the sysfs level and in the mdadm).
--- drivers/md/md-bitmap.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/md/md-bitmap.c +0 -8
@@ -236,14 +236,6 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)*/ 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
Signature · 1 line
2.17.1
Song Liu
maintainerQuoted 9 lines · Jakub Radtke
From: Jakub Radtke <[email protected]>
Removes the code that is correct only for the native metadata. Write-intent bitmap support for the other metadata formats is blocked.
rdev->sb_startis used in the calculations.
Thesb_startis only set and used for native metadata format, and the bitmap offset check will always fail if it is not set.
Can we use different logic for native and other metadata, so that we can keep the check for native metadata? Maybe we can use the combination of mddev->major_version, mddev->minor_version, and rdev->sb_start?
Thanks,
Song
Quoted 32 lines
In the case of external metadata, the bitmap can be placed in various places e.g. like the PPL between two volumes (the boundary checks are performed on the sysfs level and in the mdadm).
Signed-off-by Jakub Radtke <[email protected]>--- drivers/md/md-bitmap.c | 8 -------- 1 file changed, 8 deletions(-)drivers/md/md-bitmap.c +0
-9@@ -236,14 +236,6 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)*/ 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 --2.17.1
Please ignore the patch.
I see that the calculation is working for the other metadata formats too.
The problem was related to my environment, and I misinterpret the calculation in write_sb_page, which correctly reports the error.
Quoted 48 lines
Quoted 8 lines · Jakub Radtke
From: Jakub Radtke <[email protected]>
Removes the code that is correct only for the native metadata. Write-intent bitmap support for the other metadata formats is blocked.
rdev->sb_startis used in the calculations.
Thesb_startis only set and used for native metadata format, and the bitmap offset check will always fail if it is not set.Can we use different logic for native and other metadata, so that we can keep the check for native metadata? Maybe we can use the combination of
mddev->major_version,mddev->minor_version, andrdev->sb_start?Thanks,
SongQuoted 31 lines
In the case of external metadata, the bitmap can be placed in various places e.g. like the PPL between two volumes (the boundary checks are performed on the sysfs level and in the mdadm).
Signed-off-by Jakub Radtke <[email protected]>--- drivers/md/md-bitmap.c | 8 -------- 1 file changed, 8 deletions(-)drivers/md/md-bitmap.c +0
-9@@ -236,14 +236,6 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)*/ 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 --2.17.1