On Tue, Oct 12, 2021 at 5:14 PM Li Feng <[email protected]> wrote:
> > sysfs_notify_dirent_safe(rdev->sysfs_state);
> > + if (need_update_sb)
> > + if (mddev->pers) {
> > + set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags);
> > + md_wakeup_thread(mddev->thread);
> > + }
> When will mddev->pers is NULL?
The process of creating a raid device is:
1. md_ioctl->md_add_new_disk
2. md_ioctl->do_md_run->md_run->(pers->run)->(mddev->pers = pers)
In md_add_new_disk it creates the per device sysfs files. It can
read/write these
files before setting mddev->pers.
> If it is NULL, this change will not on disk.
I did a test. You are right. Someone can change the per device state
before ADD_NEW_DISK
and RUN_ARRAY ioctl. Please note, the mdadm --create command doesn't
return until RUN_ARRAY
ioctl finishes. Even though the are small, we can try to set MD_SB_CHANGE_DEVS.
Best regards
Xiao