Patchwork SRU for Lucid/Maverick/Natty/Oneiric, bsg: fix sysfs link remove warning

login
register
mail settings
Submitter Tim Gardner
Date March 5, 2012, 9:34 p.m.
Message ID <4F55317C.5070701@canonical.com>
Download mbox | patch
Permalink /patch/144777/
State New
Headers show

Comments

Tim Gardner - March 5, 2012, 9:34 p.m.
Clean cherry-pick as far back as 2.6.32.y
Brad Figg - March 5, 2012, 9:46 p.m.
On 03/05/2012 01:34 PM, Tim Gardner wrote:
> Clean cherry-pick as far back as 2.6.32.y
>
>

Nice!
Colin King - March 5, 2012, 9:50 p.m.
On 05/03/12 21:34, Tim Gardner wrote:
> Clean cherry-pick as far back as 2.6.32.y
>
>

Nice one.

Acked-by: Colin Ian King <colin.king@canonical.com>
Tim Gardner - March 6, 2012, 2:22 p.m.
On 03/05/2012 02:34 PM, Tim Gardner wrote:
> Clean cherry-pick as far back as 2.6.32.y

Patch

From b6d997273d3250868df8b9f8e06aea8c6e2c614c Mon Sep 17 00:00:00 2001
From: Stanislaw Gruszka <sgruszka@redhat.com>
Date: Wed, 8 Feb 2012 20:02:03 +0100
Subject: [PATCH 2.6.32.y 3.0.y 3.2.y] bsg: fix sysfs link remove warning

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

We create "bsg" link if q->kobj.sd is not NULL, so remove it only
when the same condition is true.

Fixes:

WARNING: at fs/sysfs/inode.c:323 sysfs_hash_and_remove+0x2b/0x77()
sysfs: can not remove 'bsg', no directory
Call Trace:
  [<c0429683>] warn_slowpath_common+0x6a/0x7f
  [<c0537a68>] ? sysfs_hash_and_remove+0x2b/0x77
  [<c042970b>] warn_slowpath_fmt+0x2b/0x2f
  [<c0537a68>] sysfs_hash_and_remove+0x2b/0x77
  [<c053969a>] sysfs_remove_link+0x20/0x23
  [<c05d88f1>] bsg_unregister_queue+0x40/0x6d
  [<c0692263>] __scsi_remove_device+0x31/0x9d
  [<c069149f>] scsi_forget_host+0x41/0x52
  [<c0689fa9>] scsi_remove_host+0x71/0xe0
  [<f7de5945>] quiesce_and_remove_host+0x51/0x83 [usb_storage]
  [<f7de5a1e>] usb_stor_disconnect+0x18/0x22 [usb_storage]
  [<c06c29de>] usb_unbind_interface+0x4e/0x109
  [<c067a80f>] __device_release_driver+0x6b/0xa6
  [<c067a861>] device_release_driver+0x17/0x22
  [<c067a46a>] bus_remove_device+0xd6/0xe6
  [<c06785e2>] device_del+0xf2/0x137
  [<c06c101f>] usb_disable_device+0x94/0x1a0

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(cherry picked from commit 37b40adf2d1b4a5e51323be73ccf8ddcf3f15dd3)

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 block/bsg.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/block/bsg.c b/block/bsg.c
index 702f131..c0ab25c 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -985,7 +985,8 @@  void bsg_unregister_queue(struct request_queue *q)
 
 	mutex_lock(&bsg_mutex);
 	idr_remove(&bsg_minor_idr, bcd->minor);
-	sysfs_remove_link(&q->kobj, "bsg");
+	if (q->kobj.sd)
+		sysfs_remove_link(&q->kobj, "bsg");
 	device_unregister(bcd->class_dev);
 	bcd->class_dev = NULL;
 	kref_put(&bcd->ref, bsg_kref_release_function);
-- 
1.7.9