On Wed, Apr 28, 2021 at 1:31 AM Lidong Zhong <lidong.zhong@xxxxxxxx> wrote: > > The mddev data structure is freed in mddev_delayed_delete(), which is > schedualed after the array is deconfigured completely when stopping. So > there is a race window between md_open() and do_md_stop(), which leads > to /dev/mdX can still be opened by userspace even it's not accessible > any more. As a result, a DeviceDisappeared event will not be able to be > monitored by mdadm in monitor mode. This patch tries to fix it by adding > this new flag MD_DELETING. > > Signed-off-by: Lidong Zhong <lidong.zhong@xxxxxxxx> Sorry for the delay. I missed this one. As I try to apply the patch, I found the patch is somehow corrupted. It contains special patterns like: =09if ((err =3D mutex_lock_interruptible(&mddev->open_mutex))) =09=09goto out; =20 -=09if (test_bit(MD_CLOSING, &mddev->flags)) { +=09if (test_bit(MD_CLOSING, &mddev->flags) || + (test_bit(MD_DELETING, &mddev->flags) && mddev->pers =3D=3D NU= LL)) { Could you please try resend it? Thanks, Song