Skip to contentSkip to conversation

GFS2: Only wait for demote when last holder is dequeued

PATCH New Bob Peterson 2 participants 2 messages Jun 20, 2014 1 message not in the archive GFS2 file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 GFS2: Only wait for demote when last holder is dequeued

Hi,

Function gfs2_glock_dq_wait is supposed to dequeue a glock and then wait for the lock to be demoted. The problem is, if this is a shared lock, its demote will depend on the other holders, which means you might end up waiting forever because the other process is blocked. This problem is especially apparent when dealing with nested flocks.

Regards,

Bob Peterson
Red Hat File Systems

---

fs/gfs2/glock.c +3 -1
index aec7f73..22ce2f0 100644
@@ -1128,7 +1128,9 @@ void gfs2_glock_dq_wait(struct gfs2_holder *gh)
 	struct gfs2_glock *gl = gh->gh_gl;
 	gfs2_glock_dq(gh);
 	might_sleep();
-	wait_on_bit(&gl->gl_flags, GLF_DEMOTE, gfs2_glock_demote_wait, TASK_UNINTERRUPTIBLE);
+	if (!find_first_holder(gl))
+		wait_on_bit(&gl->gl_flags, GLF_DEMOTE, gfs2_glock_demote_wait,
+			    TASK_UNINTERRUPTIBLE);
 }
 
 /**
#2 lore raw

PATCH 1/1 GFS2: Only wait for demote when last holder is dequeued

Hi,

Now in the -nmw tree. Thanks,

Steve.

Quoted 31 lines · Bob Peterson

Hi,

Function gfs2_glock_dq_wait is supposed to dequeue a glock and then wait for the lock to be demoted. The problem is, if this is a shared lock, its demote will depend on the other holders, which means you might end up waiting forever because the other process is blocked. This problem is especially apparent when dealing with nested flocks.

Regards,

Bob Peterson
Red Hat File Systems

---

fs/gfs2/glock.c +3 -1
index aec7f73..22ce2f0 100644
@@ -1128,7 +1128,9 @@ void gfs2_glock_dq_wait(struct gfs2_holder *gh)
  	struct gfs2_glock *gl = gh->gh_gl;
  	gfs2_glock_dq(gh);
  	might_sleep();
-	wait_on_bit(&gl->gl_flags, GLF_DEMOTE, gfs2_glock_demote_wait, TASK_UNINTERRUPTIBLE);
+	if (!find_first_holder(gl))
+		wait_on_bit(&gl->gl_flags, GLF_DEMOTE, gfs2_glock_demote_wait,
+			    TASK_UNINTERRUPTIBLE);
  }
 
  /**