[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250109015704.216128-10-yukuai1@huaweicloud.com>
Date: Thu, 9 Jan 2025 09:57:01 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: song@...nel.org,
yukuai3@...wei.com,
agk@...hat.com,
snitzer@...nel.org,
mpatocka@...hat.com
Cc: linux-raid@...r.kernel.org,
dm-devel@...ts.linux.dev,
linux-kernel@...r.kernel.org,
yukuai1@...weicloud.com,
yi.zhang@...wei.com,
yangerkun@...wei.com
Subject: [PATCH v2 md-6.14 09/12] md/raid10: check before deferencing mddev->bitmap_ops
From: Yu Kuai <yukuai3@...wei.com>
Prepare to support building bitmap as kernel module.
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
---
drivers/md/raid10.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index f448b5d9faf3..ed5e6a49523a 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3254,7 +3254,8 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
}
conf->fullsync = 0;
}
- mddev->bitmap_ops->close_sync(mddev);
+ if (md_bitmap_enabled(mddev))
+ mddev->bitmap_ops->close_sync(mddev);
close_sync(conf);
*skipped = 1;
return sectors_skipped;
@@ -3573,7 +3574,8 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
* safety reason, which ensures curr_resync_completed is
* updated in bitmap_cond_end_sync.
*/
- mddev->bitmap_ops->cond_end_sync(mddev, sector_nr,
+ if (md_bitmap_enabled(mddev))
+ mddev->bitmap_ops->cond_end_sync(mddev, sector_nr,
mddev_is_clustered(mddev) &&
(sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high));
@@ -4229,7 +4231,6 @@ static int raid10_resize(struct mddev *mddev, sector_t sectors)
*/
struct r10conf *conf = mddev->private;
sector_t oldsize, size;
- int ret;
if (mddev->reshape_position != MaxSector)
return -EBUSY;
@@ -4243,9 +4244,12 @@ static int raid10_resize(struct mddev *mddev, sector_t sectors)
mddev->array_sectors > size)
return -EINVAL;
- ret = mddev->bitmap_ops->resize(mddev, size, 0);
- if (ret)
- return ret;
+ if (md_bitmap_enabled(mddev)) {
+ int ret = mddev->bitmap_ops->resize(mddev, size, 0);
+
+ if (ret)
+ return ret;
+ }
md_set_array_sectors(mddev, size);
if (sectors > mddev->dev_sectors &&
@@ -4511,7 +4515,7 @@ static int raid10_start_reshape(struct mddev *mddev)
oldsize = raid10_size(mddev, 0, 0);
newsize = raid10_size(mddev, 0, conf->geo.raid_disks);
- if (!mddev_is_clustered(mddev)) {
+ if (!mddev_is_clustered(mddev) && md_bitmap_enabled(mddev)) {
ret = mddev->bitmap_ops->resize(mddev, newsize, 0);
if (ret)
goto abort;
@@ -4534,6 +4538,7 @@ static int raid10_start_reshape(struct mddev *mddev)
MD_FEATURE_RESHAPE_ACTIVE)) || (oldsize == newsize))
goto out;
+ /* cluster can't be setup without bitmap */
ret = mddev->bitmap_ops->resize(mddev, newsize, 0);
if (ret)
goto abort;
--
2.39.2
Powered by blists - more mailing lists