[PATCH] loop: Properly clear sysfs in autoclear mode

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Milan Broz
Date: Monday, October 25, 2010 - 12:11 am

In autoclear mode bdev is NULL but the sysfs
entry should be destroyed otherwise this warning appears:

WARNING: at fs/sysfs/dir.c:451 sysfs_add_one+0x82/0x95()
sysfs: cannot create duplicate filename '/devices/virtual/block/loop0/loop'

Fixes commit ee86273062cbb310665fe49e1f1937d2cf85b0b9

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 drivers/block/loop.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 6c48b35..c21d4f3 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1049,9 +1049,9 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
 	if (bdev)
 		invalidate_bdev(bdev);
 	set_capacity(lo->lo_disk, 0);
+	loop_sysfs_exit(lo);
 	if (bdev) {
 		bd_set_size(bdev, 0);
-		loop_sysfs_exit(lo);
 		/* let user-space know about this change */
 		kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
 	}
-- 
1.7.2.3

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
loop warnings in current git HEAD, Christoph Hellwig, (Sat Oct 23, 8:59 am)
Re: loop warnings in current git HEAD, Milan Broz, (Sun Oct 24, 3:02 am)
Re: loop warnings in current git HEAD, Christoph Hellwig, (Sun Oct 24, 9:13 am)
Re: loop warnings in current git HEAD, Milan Broz, (Sun Oct 24, 9:18 am)
[PATCH] loop: Properly clear sysfs in autoclear mode, Milan Broz, (Mon Oct 25, 12:11 am)