All of lore.kernel.org
 help / color / mirror / Atom feed
* + md-avoid-a-deadlock-when-removing-a-device-from-an-md-array-via-sysfs.patch added to -mm tree
@ 2007-04-02  8:01 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2007-04-02  8:01 UTC (permalink / raw)
  To: mm-commits; +Cc: neilb, stern


The patch titled
     md: avoid a deadlock when removing a device from an md array via sysfs
has been added to the -mm tree.  Its filename is
     md-avoid-a-deadlock-when-removing-a-device-from-an-md-array-via-sysfs.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: md: avoid a deadlock when removing a device from an md array via sysfs
From: NeilBrown <neilb@suse.de>

A device can be removed from an md array via e.g.
  echo remove > /sys/block/md3/md/dev-sde/state

This will try to remove the 'dev-sde' subtree which will deadlock
since
  commit e7b0d26a86943370c04d6833c6edba2a72a6e240

With this patch we run the kobject_del via schedule_work so as to
avoid the deadlock.

Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/md/md.c           |   13 ++++++++++++-
 include/linux/raid/md_k.h |    1 +
 2 files changed, 13 insertions(+), 1 deletion(-)

diff -puN drivers/md/md.c~md-avoid-a-deadlock-when-removing-a-device-from-an-md-array-via-sysfs drivers/md/md.c
--- a/drivers/md/md.c~md-avoid-a-deadlock-when-removing-a-device-from-an-md-array-via-sysfs
+++ a/drivers/md/md.c
@@ -1378,6 +1378,12 @@ static int bind_rdev_to_array(mdk_rdev_t
 	return err;
 }
 
+static void delayed_delete(struct work_struct *ws)
+{
+	mdk_rdev_t *rdev = container_of(ws, mdk_rdev_t, del_work);
+	kobject_del(&rdev->kobj);
+}
+
 static void unbind_rdev_from_array(mdk_rdev_t * rdev)
 {
 	char b[BDEVNAME_SIZE];
@@ -1390,7 +1396,12 @@ static void unbind_rdev_from_array(mdk_r
 	printk(KERN_INFO "md: unbind<%s>\n", bdevname(rdev->bdev,b));
 	rdev->mddev = NULL;
 	sysfs_remove_link(&rdev->kobj, "block");
-	kobject_del(&rdev->kobj);
+
+	/* We need to delay this, otherwise we can deadlock when
+	 * writing to 'remove' to "dev/state"
+	 */
+	INIT_WORK(&rdev->del_work, delayed_delete);
+	schedule_work(&rdev->del_work);
 }
 
 /*
diff -puN include/linux/raid/md_k.h~md-avoid-a-deadlock-when-removing-a-device-from-an-md-array-via-sysfs include/linux/raid/md_k.h
--- a/include/linux/raid/md_k.h~md-avoid-a-deadlock-when-removing-a-device-from-an-md-array-via-sysfs
+++ a/include/linux/raid/md_k.h
@@ -104,6 +104,7 @@ struct mdk_rdev_s
 					   * for reporting to userspace and storing
 					   * in superblock.
 					   */
+	struct work_struct del_work;	/* used for delayed sysfs removal */
 };
 
 struct mddev_s
_

Patches currently in -mm which might be from neilb@suse.de are

origin.patch
md-avoid-a-deadlock-when-removing-a-device-from-an-md-array-via-sysfs.patch
net-sunrpc-svcsockc-fix-a-check.patch
fix-quadratic-behavior-of-shrink_dcache_parent.patch
fix-__d_path-for-lazy-unmounts-and-make-it-unambiguous.patch
the-nfsv2-nfsv3-server-does-not-handle-zero-length-write.patch
readahead-nfsd-case.patch
drivers-mdc-use-array_size-macro-when-appropriate.patch
md-dm-reduce-stack-usage-with-stacked-block-devices.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-04-02  8:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-02  8:01 + md-avoid-a-deadlock-when-removing-a-device-from-an-md-array-via-sysfs.patch added to -mm tree akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.