]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gfs2: gfs2_glock_get cleanup
authorAndreas Gruenbacher <agruenba@redhat.com>
Mon, 8 Apr 2024 07:36:48 +0000 (09:36 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Wed, 29 May 2024 13:34:55 +0000 (15:34 +0200)
Clean up the messy code in gfs2_glock_get().  No change in
functionality.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/glock.c

index 5fed5a22a8e750b2787baf0284e2ac1952ba944e..2d4e927c4d2f35ed18f1cb175d420d0ebeddc750 100644 (file)
@@ -1203,13 +1203,10 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
                                    .ln_sbd = sdp };
        struct gfs2_glock *gl, *tmp;
        struct address_space *mapping;
-       int ret = 0;
 
        gl = find_insert_glock(&name, NULL);
-       if (gl) {
-               *glp = gl;
-               return 0;
-       }
+       if (gl)
+               goto found;
        if (!create)
                return -ENOENT;
 
@@ -1271,23 +1268,19 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
        }
 
        tmp = find_insert_glock(&name, gl);
-       if (!tmp) {
-               *glp = gl;
-               goto out;
-       }
-       if (IS_ERR(tmp)) {
-               ret = PTR_ERR(tmp);
-               goto out_free;
-       }
-       *glp = tmp;
+       if (tmp) {
+               gfs2_glock_dealloc(&gl->gl_rcu);
+               if (atomic_dec_and_test(&sdp->sd_glock_disposal))
+                       wake_up(&sdp->sd_kill_wait);
 
-out_free:
-       gfs2_glock_dealloc(&gl->gl_rcu);
-       if (atomic_dec_and_test(&sdp->sd_glock_disposal))
-               wake_up(&sdp->sd_kill_wait);
+               if (IS_ERR(tmp))
+                       return PTR_ERR(tmp);
+               gl = tmp;
+       }
 
-out:
-       return ret;
+found:
+       *glp = gl;
+       return 0;
 }
 
 /**