summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2018-11-08 14:01:03 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-23 08:09:51 +0100
commitf1e81ba8a3fa56dcc48828869b392b29559a0ac3 (patch)
tree185f11fb8abe0da8e5f589d485c8c718cba7c590 /drivers/block
parent57da9a9742200f391d1cf93fea389f7ddc25ec9a (diff)
downloadlinux-stable-f1e81ba8a3fa56dcc48828869b392b29559a0ac3.tar.gz
linux-stable-f1e81ba8a3fa56dcc48828869b392b29559a0ac3.tar.bz2
linux-stable-f1e81ba8a3fa56dcc48828869b392b29559a0ac3.zip
loop: Fold __loop_release into loop_release
commit 967d1dc144b50ad005e5eecdfadfbcfb399ffff6 upstream. __loop_release() has a single call site. Fold it there. This is currently not a huge win but it will make following replacement of loop_index_mutex more obvious. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/loop.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index aa9e9b2fce02..cb13430082ef 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1603,12 +1603,15 @@ out:
return err;
}
-static void __lo_release(struct loop_device *lo)
+static void lo_release(struct gendisk *disk, fmode_t mode)
{
+ struct loop_device *lo;
int err;
+ mutex_lock(&loop_index_mutex);
+ lo = disk->private_data;
if (atomic_dec_return(&lo->lo_refcnt))
- return;
+ goto unlock_index;
mutex_lock(&loop_ctl_mutex);
if (lo->lo_flags & LO_FLAGS_AUTOCLEAR) {
@@ -1618,7 +1621,7 @@ static void __lo_release(struct loop_device *lo)
*/
err = loop_clr_fd(lo);
if (!err)
- return;
+ goto unlock_index;
} else if (lo->lo_state == Lo_bound) {
/*
* Otherwise keep thread (if running) and config,
@@ -1629,12 +1632,7 @@ static void __lo_release(struct loop_device *lo)
}
mutex_unlock(&loop_ctl_mutex);
-}
-
-static void lo_release(struct gendisk *disk, fmode_t mode)
-{
- mutex_lock(&loop_index_mutex);
- __lo_release(disk->private_data);
+unlock_index:
mutex_unlock(&loop_index_mutex);
}