Re: [PATCH v2 1/5] md/md-bitmap: call md_bitmap_create,destroy in location_store
Su Yue <[email protected]>
| Newsgroups | gmane.linux.raid |
|---|---|
| Message-ID | <[email protected]> |
aOn Mon 13 Apr 2026 at 15:47, Li Nan <[email protected]> wrote: > 在 2026/4/7 18:26, Su Yue 写道: >> If bitmap/location is present, mdadm will call >> update_array_info() >> while growing bitmap from none to internal via >> location_store(). >> md_bitmap_create() is needed to set mddev->bitmap_ops otherwise >> mddev->bitmap_ops->get_stats() in update_array_info() will >> trigger >> kernel NULL pointer dereference. >> Fixes: fb8cc3b0d9db ("md/md-bitmap: delay registration of >> bitmap_ops until >> creating bitmap") >> Signed-off-by: Su Yue <[email protected]> >> --- >> drivers/md/md-bitmap.c | 11 ++++++++--- >> drivers/md/md.c | 4 ++-- >> drivers/md/md.h | 2 ++ >> 3 files changed, 12 insertions(+), 5 deletions(-) >> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c >> index 83378c033c72..2f24aae05552 100644 >> --- a/drivers/md/md-bitmap.c >> +++ b/drivers/md/md-bitmap.c >> @@ -2618,7 +2618,7 @@ location_store(struct mddev *mddev, const >> char *buf, size_t len) >> goto out; >> } >> - bitmap_destroy(mddev); >> + md_bitmap_destroy(mddev); >> mddev->bitmap_info.offset = 0; >> if (mddev->bitmap_info.file) { >> struct file *f = mddev->bitmap_info.file; >> @@ -2653,15 +2653,20 @@ location_store(struct mddev *mddev, >> const char *buf, size_t len) >> goto out; >> } >> + /* >> + * lockless bitmap shoudle have set bitmap_id >> + * using bitmap_type, so always ID_BITMAP. >> + */ >> + mddev->bitmap_id = ID_BITMAP; >> mddev->bitmap_info.offset = offset; >> - rv = bitmap_create(mddev); >> + rv = md_bitmap_create(mddev); >> if (rv) >> goto out; >> rv = bitmap_load(mddev); > > mddev->bitmap_ops->load() should also be used here. /NOD. location_store() is only used for ID_BITMAP_NONE and ID_BITMAP, so mddev->bitmap_ops->load() is always bitmap_load(). But for code consistency, mddev->bitmap_ops->load() is better, will fix it. -- Su