Handle multiple glock demote requests
PATCH 1/1 Handle multiple glock demote requests
Red Hat bugzilla 295641... Wendy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gfs2_waiters2.patch
Type: text/x-patch
Size: 2461 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20071004/eaf33e56/attachment.bin>
PATCH 1/1 Handle multiple glock demote requests
Quoted 46 lines · Wendy Cheng
Red Hat bugzilla 295641... Wendy
Fix a race condition where multiple glock demote requests are sent to a node back-to-back. This patch does a check inside
handle_callback()to see whether a demote request is in progress. If true, it sets a flag to make surerun_queue()will loop again to handle the new request, instead of erroneously settinggl_demote_stateto a different state.Signed-off-by S. Wendy Cheng <[email protected]>glock.c | 13 ++++++++++++- incore.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-)fs/gfs2/incore.h +2
-0@@ -171,6 +171,7 @@ enum {GLF_DEMOTE =3 ,GLF_PENDING_DEMOTE =4 ,GLF_DIRTY =5 , + GLF_DEMOTE_IN_PROGRESS = 6, }; struct gfs2_glock {@@ -190,6 +191,7 @@ struct gfs2_glock {struct list_head gl_holders;struct list_head gl_waiters1;/* HIF_MUTEX */ struct list_head gl_waiters3;/* HIF_PROMOTE */ +int gl_waiters2;/* GIF_DEMOTE */ const struct gfs2_glock_operations *gl_ops;fs/gfs2/glock.c +1
-0@@ -567,6 +567,7 @@ static int rq_demote(struct gfs2_glock *return 0 ; }set_bit (GLF_LOCK , &gl->gl_flags); +set_bit (GLF_DEMOTE_IN_PROGRESS , &gl->gl_flags);if (gl->gl_demote_state ==LM_ST_UNLOCKED || gl->gl_state !=LM_ST_EXCLUSIVE ) {spin_unlock (&gl->gl_spin);
fs/gfs2/glock.c static int rq_demote(struct gfs2_glock * · line 582
Quoted 7 lines
fs/gfs2/glock.c +2
-0@@ -575,6 +576,8 @@ static int rq_demote(struct gfs2_glock *spin_unlock (&gl->gl_spin);gfs2_glock_xmote_th (gl,NULL ); } + +clear_bit (GLF_DEMOTE_IN_PROGRESS , &gl->gl_flags);spin_lock (&gl->gl_spin);
May want to move the clear_bit inside the spin_lock so you don't end up having the same race where we clear the bit while inside handle_callback.
Josef
PATCH 1/1 Handle multiple glock demote requests
Quoted 9 lines · Josef Bacik
Quoted 9 lines
(quoted diff) +1
-0set_bit(GLF_LOCK, &gl->gl_flags); + set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags); if (gl->gl_demote_state == LM_ST_UNLOCKED || gl->gl_state != LM_ST_EXCLUSIVE) { spin_unlock(&gl->gl_spin);@@ -575,6 +576,8 @@ static int rq_demote(struct gfs2_glock * spin_unlock(&gl->gl_spin); gfs2_glock_xmote_th(gl, NULL); }
Quoted 10 lines
Review static int rq_demote(struct gfs2_glock * · line 583
Quoted 5 lines
(quoted diff) +2
-0+ + clear_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags); spin_lock(&gl->gl_spin);May want to move the
clear_bitinside thespin_lockso you don't end up having the same race where we clear the bit while insidehandle_callback.
Yep... good point .... Will make changes .. Wendy
PATCH 1/1 Handle multiple glock demote requests
Make a correction based on Josef's comment .... Wendy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gfs2_waiters2.patch
Type: text/x-patch
Size: 2495 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20071005/3fb11f92/attachment.bin>