Skip to content

Commit a4e8145

Browse files
author
Andreas Gruenbacher
committed
gfs2: Initialize gh_error in gfs2_glock_nq
The gh_error field if a glock holder is initialized to zero in gfs2_holder_init(). When a locking operation fails, gh_error is set to an error code; when it succeeds, the gh_error value is left unchanged. The field isn't initialized in gfs2_holder_reinit(), which is a problem. Instead of fixing that directly, initialize gh_error in gfs2_glock_nq(). That also obsoletes the assignment in do_flock(). Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 5a27a43 commit a4e8145

2 files changed

Lines changed: 1 addition & 2 deletions

File tree

fs/gfs2/file.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,6 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
14971497
if (error != GLR_TRYFAILED)
14981498
break;
14991499
fl_gh->gh_flags = LM_FLAG_TRY | GL_EXACT;
1500-
fl_gh->gh_error = 0;
15011500
msleep(sleeptime);
15021501
}
15031502
if (error) {

fs/gfs2/glock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,6 @@ void __gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, u16 flags,
12611261
gh->gh_owner_pid = get_pid(task_pid(current));
12621262
gh->gh_state = state;
12631263
gh->gh_flags = flags;
1264-
gh->gh_error = 0;
12651264
gh->gh_iflags = 0;
12661265
gfs2_glock_hold(gl);
12671266
}
@@ -1567,6 +1566,7 @@ int gfs2_glock_nq(struct gfs2_holder *gh)
15671566
if (test_bit(GLF_LRU, &gl->gl_flags))
15681567
gfs2_glock_remove_from_lru(gl);
15691568

1569+
gh->gh_error = 0;
15701570
spin_lock(&gl->gl_lockref.lock);
15711571
add_to_queue(gh);
15721572
if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) &&

0 commit comments

Comments
 (0)