[PATCH 4.9 03/32] Revert "loop: Fold __loop_release into loop_release"
From: Greg Kroah-Hartman
Date: Mon Mar 04 2019 - 03:47:51 EST
4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
This reverts commit 7d839c10b848aa66ca1290a21ee600bd17c2dcb4 which is
commit 967d1dc144b50ad005e5eecdfadfbcfb399ffff6 upstream.
It does not work properly in the 4.9.y tree and causes more problems
than it fixes, so revert it.
Reported-by: Thomas Lindroth <thomas.lindroth@xxxxxxxxx>
Reported-by: Jan Kara <jack@xxxxxxx>
Cc: Jens Axboe <axboe@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/block/loop.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1575,15 +1575,12 @@ out:
return err;
}
-static void lo_release(struct gendisk *disk, fmode_t mode)
+static void __lo_release(struct loop_device *lo)
{
- struct loop_device *lo;
int err;
- mutex_lock(&loop_index_mutex);
- lo = disk->private_data;
if (atomic_dec_return(&lo->lo_refcnt))
- goto unlock_index;
+ return;
mutex_lock(&loop_ctl_mutex);
if (lo->lo_flags & LO_FLAGS_AUTOCLEAR) {
@@ -1593,7 +1590,7 @@ static void lo_release(struct gendisk *d
*/
err = loop_clr_fd(lo);
if (!err)
- goto unlock_index;
+ return;
} else {
/*
* Otherwise keep thread (if running) and config,
@@ -1603,7 +1600,12 @@ static void lo_release(struct gendisk *d
}
mutex_unlock(&loop_ctl_mutex);
-unlock_index:
+}
+
+static void lo_release(struct gendisk *disk, fmode_t mode)
+{
+ mutex_lock(&loop_index_mutex);
+ __lo_release(disk->private_data);
mutex_unlock(&loop_index_mutex);
}