lkml.org 
[lkml]   [2007]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: [PATCH] md: Avoid a deadlock when removing a device from an md array via sysfs.
On Monday April 2, akpm@linux-foundation.org wrote:
>
> What guarantees that *rdev is still valid when delayed_delete() runs?

Because that is how kobjects and krefs work. There is an embedded
refcount etc etc..

>
> And what guarantees that the md module hasn't been rmmodded when
> delayed_delete() tries to run?

Good point. Nothing. Maybe this patch is needed.

Thanks,
NeilBrown

---------------------------
Avoid a deadlock when removing a device from an md array via sysfs. - fix

Make sure any delayed_delete calls finish before module unload.
For simplicity, flush the queue when we stop the array.

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
./drivers/md/md.c | 3 +++
1 file changed, 3 insertions(+)

diff .prev/drivers/md/md.c ./drivers/md/md.c
--- .prev/drivers/md/md.c 2007-04-02 17:38:46.000000000 +1000
+++ ./drivers/md/md.c 2007-04-02 18:49:24.000000000 +1000
@@ -3410,6 +3410,9 @@ static int do_md_stop(mddev_t * mddev, i
sysfs_remove_link(&mddev->kobj, nm);
}

+ /* make sure all delayed_delete calls have finished */
+ flush_scheduled_work();
+
export_array(mddev);

mddev->array_size = 0;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2007-04-02 10:55    [W:0.026 / U:0.992 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site