Hi, 在 2025/7/8 19:57, Hannes Reinecke 写道: > On 7/8/25 13:31, 余快 wrote: >> Hi, >> >> Hannes Reinecke <hare@xxxxxxx <mailto:hare@xxxxxxx>> 于2025年7月8日周二 >> 14:29写道: >> >> > + if (mddev->bitmap_ops->group && !mddev_is_dm(mddev)) { >> > + if (sysfs_create_group(&mddev->kobj, mddev- >> >bitmap_ops->group)) >> > + pr_warn("md: cannot register extra bitmap >> attributes for %s\n", >> > + mdname(mddev)); >> > + else >> > + kobject_uevent(&mddev->kobj, KOBJ_CHANGE); >> > + } >> > return true; >> > >> > err: >> >> Ouch. This will cause havoc with the udev rules. >> Having different events for 'add' and 'change' tends to confuse udev >> rules (most treat 'add' and 'change' identically), so at the very >> least >> you would need to document this. >> >> >> Do you mean document here as new sysfs entries are created under mddev >> kobject? >> > No, I meant to document that 'add' events will have access to > different sysfs attributes than the 'change' events. > In the running system one will only see the final status, so it's not > immediately obvious that some attributes are only valid for 'change', > and not for 'add'. Thanks for the explanation, just to make sure you mean: diff --git a/Documentation/admin-guide/md.rst b/Documentation/admin-guide/md.rst index 2030772075b5..db7a39894c8d 100644 --- a/Documentation/admin-guide/md.rst +++ b/Documentation/admin-guide/md.rst @@ -388,6 +388,9 @@ All md devices contain: bitmap The default internal bitmap +If bitmap_type is not none, then additional bitmap attributes will be created +after md device KOBJ_CHANGE event. + If bitmap_type is bitmap, then the md device will also contain: bitmap/location diff --git a/drivers/md/md.c b/drivers/md/md.c index 22378686a964..60e2de23c9b5 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -699,6 +699,7 @@ static bool mddev_set_bitmap_ops(struct mddev *mddev) pr_warn("md: cannot register extra bitmap attributes for %s\n", mdname(mddev)); else + /* Inform user with KOBJ_CHANGE about new bitmap attributes. */ kobject_uevent(&mddev->kobj, KOBJ_CHANGE); } return true; > > Cheers, > > Hannes