diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2024-04-08 09:36:48 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2024-05-29 15:34:55 +0200 |
commit | 8f6b8f142bdab2ed8c8fcd00def947c372382401 (patch) | |
tree | 3c7ce45d474f678631a0c055d86a6eaaadb5c715 /fs/gfs2 | |
parent | c8758ad005c98b15cd8b7a559dc51f8ddbc56d0a (diff) | |
download | lwn-8f6b8f142bdab2ed8c8fcd00def947c372382401.tar.gz lwn-8f6b8f142bdab2ed8c8fcd00def947c372382401.zip |
gfs2: gfs2_glock_get cleanup
Clean up the messy code in gfs2_glock_get(). No change in
functionality.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/glock.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 5fed5a22a8e7..2d4e927c4d2f 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -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; } /** |