Skip to content

Commit 8f6b8f1

Browse files
author
Andreas Gruenbacher
committed
gfs2: gfs2_glock_get cleanup
Clean up the messy code in gfs2_glock_get(). No change in functionality. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent c8758ad commit 8f6b8f1

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

fs/gfs2/glock.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,13 +1203,10 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
12031203
.ln_sbd = sdp };
12041204
struct gfs2_glock *gl, *tmp;
12051205
struct address_space *mapping;
1206-
int ret = 0;
12071206

12081207
gl = find_insert_glock(&name, NULL);
1209-
if (gl) {
1210-
*glp = gl;
1211-
return 0;
1212-
}
1208+
if (gl)
1209+
goto found;
12131210
if (!create)
12141211
return -ENOENT;
12151212

@@ -1271,23 +1268,19 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
12711268
}
12721269

12731270
tmp = find_insert_glock(&name, gl);
1274-
if (!tmp) {
1275-
*glp = gl;
1276-
goto out;
1277-
}
1278-
if (IS_ERR(tmp)) {
1279-
ret = PTR_ERR(tmp);
1280-
goto out_free;
1281-
}
1282-
*glp = tmp;
1271+
if (tmp) {
1272+
gfs2_glock_dealloc(&gl->gl_rcu);
1273+
if (atomic_dec_and_test(&sdp->sd_glock_disposal))
1274+
wake_up(&sdp->sd_kill_wait);
12831275

1284-
out_free:
1285-
gfs2_glock_dealloc(&gl->gl_rcu);
1286-
if (atomic_dec_and_test(&sdp->sd_glock_disposal))
1287-
wake_up(&sdp->sd_kill_wait);
1276+
if (IS_ERR(tmp))
1277+
return PTR_ERR(tmp);
1278+
gl = tmp;
1279+
}
12881280

1289-
out:
1290-
return ret;
1281+
found:
1282+
*glp = gl;
1283+
return 0;
12911284
}
12921285

12931286
/**

0 commit comments

Comments
 (0)