diff mbox

[Vivid,SRU] enclosure: fix WARN_ON removing an adapter in multi-path devices

Message ID 1433963750-19179-1-git-send-email-chris.j.arges@canonical.com
State New
Headers show

Commit Message

Chris J Arges June 10, 2015, 7:15 p.m. UTC
From: James Bottomley <JBottomley@Parallels.com>

BugLink: http://bugs.launchpad.net/bugs/1415178

We have peculiar problems with multi-path and enclosures: physically, we know
each bay can only be occupied by a single disk device.  However in multi-path,
it appears we have many (because each path to the device appears in Linux as a
different kernel device).  We try to fix this by only having the last seen
device show up in the bay.

Sysfs gets very annoyed if we try to manipulate links when the kobject sysfs
directory (kobj.sd) doesn't exist and drops a huge WARN_ON which most users
panic and report an oops for.  This happens on a few path removal situations
and IBM reports seeing it when one of their multi-path adapters is removed.

Add a check to enclosure device removal for the existence the sysfs directory
containing both the forward and back links so that the remnants (if any) get
removed in either direction but no scary warnings are dumped.

Reported-by: Wen Xiong <wenxiong@linux.vnet.ibm.com>
Tested-by: Wen Xiong <wenxiong@linux.vnet.ibm.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
(cherry picked from commit 11e52a699afff576606ceb6cf697270459f1a4aa)
Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
---
 drivers/misc/enclosure.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Stefan Bader June 11, 2015, 6:52 a.m. UTC | #1
Cherry pick and looks sensible. Wondering whether this would be make some sense
for Trusty, too.

-Stefan
Tim Gardner June 11, 2015, 12:22 p.m. UTC | #2

Brad Figg June 11, 2015, 4:05 p.m. UTC | #3
Applied to the Vivid master-next branch.
diff mbox

Patch

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 180a544..ca75087 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -199,16 +199,17 @@  static void enclosure_remove_links(struct enclosure_component *cdev)
 {
 	char name[ENCLOSURE_NAME_SIZE];
 
+	enclosure_link_name(cdev, name);
+
 	/*
 	 * In odd circumstances, like multipath devices, something else may
 	 * already have removed the links, so check for this condition first.
 	 */
-	if (!cdev->dev->kobj.sd)
-		return;
+	if (cdev->dev->kobj.sd)
+		sysfs_remove_link(&cdev->dev->kobj, name);
 
-	enclosure_link_name(cdev, name);
-	sysfs_remove_link(&cdev->dev->kobj, name);
-	sysfs_remove_link(&cdev->cdev.kobj, "device");
+	if (cdev->cdev.kobj.sd)
+		sysfs_remove_link(&cdev->cdev.kobj, "device");
 }
 
 static int enclosure_add_links(struct enclosure_component *cdev)