Skip to contentSkip to conversation

gfs2: Initialize gh_error in gfs2_glock_nq

PATCH New Andreas Gruenbacher 1 participant 1 message Feb 2, 2022 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 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().

---
 fs/gfs2/file.c  | 1 -
 fs/gfs2/glock.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
fs/gfs2/file.c +0 -1
index 5bac4f6e8e05..a743a9eb602f 100644
@@ -1497,7 +1497,6 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
 		if (error != GLR_TRYFAILED)
 			break;
 		fl_gh->gh_flags = LM_FLAG_TRY | GL_EXACT;
-		fl_gh->gh_error = 0;
 		msleep(sleeptime);
 	}
 	if (error) {
fs/gfs2/glock.c +1 -1
index f7f296e8e506..3a4c0cca6580 100644
@@ -1264,7 +1264,6 @@ void __gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, u16 flags,
 	gh->gh_owner_pid = get_pid(task_pid(current));
 	gh->gh_state = state;
 	gh->gh_flags = flags;
-	gh->gh_error = 0;
 	gh->gh_iflags = 0;
 	gfs2_glock_hold(gl);
 }
@@ -1570,6 +1569,7 @@ int gfs2_glock_nq(struct gfs2_holder *gh)
 	if (test_bit(GLF_LRU, &gl->gl_flags))
 		gfs2_glock_remove_from_lru(gl);
 
+	gh->gh_error = 0;
 	spin_lock(&gl->gl_lockref.lock);
 	add_to_queue(gh);
 	if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) &&
Signature · 1 line
2.33.1