loop: Fold __loop_release into loop_release
authorJan Kara <jack@suse.cz>
Thu, 8 Nov 2018 13:01:03 +0000 (14:01 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 8 Nov 2018 13:30:14 +0000 (06:30 -0700)
__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>
drivers/block/loop.c

index 63008e8..3de2cd9 100644 (file)
@@ -1641,12 +1641,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) {
@@ -1656,7 +1659,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,
@@ -1667,12 +1670,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);
 }