Skip to contentSkip to conversation

gfs2: Mark flock glock holders as GL_NOPID

PATCH New Andreas Gruenbacher 1 participant 1 message Apr 6, 2022 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: Mark flock glock holders as GL_NOPID

Add the GL_NOPID flag for flock glock holders. Clean up the flag setting code in do_flock.

In add_to_queue(), since flock glock holders now always have the GL_NOPID flag set, there is no need to separately check for those types of locks anymore.

---
 fs/gfs2/file.c  | 7 +++++--
 fs/gfs2/glock.c | 2 --
 2 files changed, 5 insertions(+), 4 deletions(-)
fs/gfs2/file.c +5 -2
index 22b41acfbbc3..6f57a132ef26 100644
@@ -1469,7 +1469,9 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
 	int sleeptime;
 
 	state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED;
-	flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY_1CB) | GL_EXACT;
+	flags = GL_EXACT | GL_NOPID;
+	if (!IS_SETLKW(cmd))
+		flags |= LM_FLAG_TRY_1CB;
 
 	mutex_lock(&fp->f_fl_mutex);
 
@@ -1495,7 +1497,8 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
 		error = gfs2_glock_nq(fl_gh);
 		if (error != GLR_TRYFAILED)
 			break;
-		fl_gh->gh_flags = LM_FLAG_TRY | GL_EXACT;
+		fl_gh->gh_flags &= ~LM_FLAG_TRY_1CB;
+		fl_gh->gh_flags |= LM_FLAG_TRY;
 		msleep(sleeptime);
 	}
 	if (error) {
fs/gfs2/glock.c +0 -2
index 106a994b20c0..26169cedcefc 100644
@@ -1508,8 +1508,6 @@ __acquires(&gl->gl_lockref.lock)
 	list_for_each_entry(gh2, &gl->gl_holders, gh_list) {
 		if (likely(gh2->gh_owner_pid != gh->gh_owner_pid))
 			continue;
-		if (gh->gh_gl->gl_ops->go_type == LM_TYPE_FLOCK)
-			continue;
 		if (test_bit(HIF_MAY_DEMOTE, &gh2->gh_iflags))
 			continue;
 		if (!pid_is_meaningful(gh2))
Signature · 1 line
2.35.1