gfs2: Move state2str
Andreas Gruenbacher
maintainerPATCH 1/3 gfs2: Move state2str
Move state2str() to the beginning of fs/gfs2/glock.c to make it available to finish_xmote().
--- fs/gfs2/glock.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
fs/gfs2/glock.c +15 -15
@@ -80,6 +80,21 @@ static const struct rhashtable_params ht_parms = {static struct rhashtable gl_hash_table; +static const char *state2str (unsigned state) +{ +switch (state) { +case LM_ST_UNLOCKED : +return "UN" ; +case LM_ST_SHARED : +return "SH" ; +case LM_ST_DEFERRED : +return "DF" ; +case LM_ST_EXCLUSIVE : +return "EX" ; + } +return "??" ; +} +#define GLOCK_WAIT_TABLE_BITS 12#define GLOCK_WAIT_TABLE_SIZE (1 << GLOCK_WAIT_TABLE_BITS) static wait_queue_head_t glock_wait_table[GLOCK_WAIT_TABLE_SIZE] __cacheline_aligned;
@@ -2025,21 +2040,6 @@ void gfs2_wait_glocks(struct gfs2_sbd *sdp) sdp->sd_glock_wq =NULL ; } -static const char *state2str (unsigned state) -{ -switch (state) { -case LM_ST_UNLOCKED : -return "UN" ; -case LM_ST_SHARED : -return "SH" ; -case LM_ST_DEFERRED : -return "DF" ; -case LM_ST_EXCLUSIVE : -return "EX" ; - } -return "??" ; -} -static const char *hflags2str (char *buf,u16 flags,unsigned long iflags) {char *p = buf;
Signature · 1 line
2.56.0
Andreas Gruenbacher
maintainerPATCH 2/3 gfs2: Don't BUG during a withdraw
Recent testing has revealed the following BUG:
[] gfs2: fsid=STSRHTS7386:withdraw0.0: about to withdraw this file system
[] gfs2: fsid=STSRHTS7386:withdraw0.0: gfs2_withdraw_helper failed with status 1 [] gfs2: fsid=STSRHTS7386:withdraw0.0: glock 2:13127 requested=1 ret=4
[] gfs2: fsid=STSRHTS7386:withdraw0.0: G: s:EX n:2/3347 f:lDpyo t:SH d:SH/0 a:0 v:0 r:2 m:200 p:1 [] gfs2: fsid=STSRHTS7386:withdraw0.0: I: n:20/13127 t:4 f:0x00 d:0x00000001 s:3864 p:0 [] ------------[ cut here ]------------
[] kernel BUG at fs/gfs2/glock.c:585!
This indicates that we are withdrawing the filesystem and finish_xmote() has been called with status LM_OUT_ERROR on a glock that is being demoted. This happens when gfs2_withdraw_glocks() cancels pending locking requests, but finish_xmote() thinks that it's a communication error with dlm.
When finish_xmote() processes the result of a locking request, it usually retries failed demote requests until they eventually succeed. However, this is futile when the filesystem is already withdrawing, so change the code to bail out immediately in that case instead. This prevents the BUG described above.
In addition, when an actual protocol error occurs, withdraw the filesystem instead of triggering a BUG().
--- fs/gfs2/glock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/gfs2/glock.c +4 -2
@@ -562,8 +562,10 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)/* Check for state != intended state */ if (unlikely (gl->gl_state != gl->gl_target)) {struct gfs2_holder *gh =find_first_waiter (gl); +struct gfs2_sbd *sdp =glock_sbd (gl); -if (gh && !test_bit (GLF_DEMOTE_IN_PROGRESS , &gl->gl_flags)) { +if (gh && (!test_bit (GLF_DEMOTE_IN_PROGRESS , &gl->gl_flags) || +gfs2_withdrawn (sdp))) {if (ret &LM_OUT_CANCELED ) {list_del_init (&gh->gh_list);trace_gfs2_glock_queue (gh,0 );
@@ -596,7 +598,7 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)"glock %u:%llu requested=%u ret=%u\n" ,glock_type (gl),glock_number (gl), gl->gl_req, ret); -GLOCK_BUG_ON (gl,1 ); +gfs2_withdraw (sdp); }return ; }
Signature · 1 line
2.56.0
Andreas Gruenbacher
maintainerPATCH 3/3 gfs2: Minor error message improvement
In reply to Andreas GruenbacherUse a symbolic glock state name instead of the numeric code.
--- fs/gfs2/glock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/gfs2/glock.c +2 -2
@@ -595,9 +595,9 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)break ;default :/* Everything else */ fs_err (glock_sbd (gl), -"glock %u:%llu requested=%u ret=%u\n" , +"glock %u:%llu requested=%s ret=%u\n" ,glock_type (gl),glock_number (gl), - gl->gl_req, ret); +state2str (gl->gl_req), ret);gfs2_withdraw (sdp); }return ;
Signature · 1 line
2.56.0