[PATCH 2/2] block: clear ro on fd detach fd is bound

Tejun Heo
2011-01-22T14:23:08Z

Commit 75f1dc0d (block: check bdev_read_only() from blkdev_get())
enforced bdev_read_only() check during blkdev_get(). This had an
unfortunate side effect on loop because loop didn't clear ro flag on
fd detach, so once a loop device was used ro, it can't be used for rw
at all.

Fix it by clearing ro flag on fd detach.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: "J. R. Okajima" <hooanon05@yahoo.co.jp>
---
drivers/block/loop.c | 1 +
1 file changed, 1 insertion(+)

Index: work/drivers/block/loop.c
===================================================================
--- work.orig/drivers/block/loop.c
+++ work/drivers/block/loop.c
@@ -1041,6 +1041,7 @@ static int loop_clr_fd(struct loop_devic
set_capacity(lo->lo_disk, 0);
loop_sysfs_exit(lo);
bd_set_size(bdev, 0);
+ set_device_ro(bdev, 0);
/* let user-space know about this change */
kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, KOBJ_CHANGE);
mapping_set_gfp_mask(filp->f_mapping, gfp);