gfs2: Misc withdraw patches (version 3)
v3 cover gfs2: Misc withdraw patches (version 3)
This is version 3 which has further simplification and improvements.
This patch set fixes a few bugs in how gfs2 handles file systems after withdraw. In an ideal world, after a file system is withdrawn, users should be able to unmount the file system without problems. However, we discovered three problems that prevented clean unmounts:
1. A duplicate iput of the journal after attempted recovery caused kernel panics after withdraw.
2. After withdraw, unmount would hang for its alloted timeout period when glocks had waiters queued that, due to the withdraw, could never be granted.
3. Unmount would similarly hang when the withdraw prevented an outgoing request to dlm, but so the glock was never unlocked.
Bob Peterson (3):
gfs2: Prevent double iput for journal on error
gfs2: Dequeue waiters when withdrawn
gfs2: Clear flags when withdraw prevents xmote
fs/gfs2/glock.c | 36 ++++++++++++++++++++++++++++++++++-- fs/gfs2/glock.h | 1 + fs/gfs2/util.c | 6 ++++++ 3 files changed, 41 insertions(+), 2 deletions(-)
Signature · 1 line
2.37.2
PATCH v3 1/3 gfs2: Prevent double iput for journal on error
When a gfs2 file system is withdrawn it does iput on its journal to allow recovery from another cluster node. If it's unable to get a replacement inode for whatever reason, the journal descriptor would still be pointing at the evicted inode. So when unmount clears out the list of journals, it would do a second iput referencing the pointer. To avoid this, set the inode pointer to NULL.
--- fs/gfs2/util.c | 1 + 1 file changed, 1 insertion(+)
fs/gfs2/util.c +1 -0
@@ -204,6 +204,7 @@ static void signal_our_withdraw(struct gfs2_sbd *sdp)* exception code in glock_dq. */ iput (inode); + sdp->sd_jdesc->jd_inode =NULL ;/* * Wait until the journal inode's glock is freed. This allows try locks * on other nodes to be successful, otherwise we remain the owner of
Signature · 1 line
2.37.2
PATCH v3 2/3 gfs2: Dequeue waiters when withdrawn
In reply to Bob PetersonWhen a withdraw occurs, ordinary (not system) glocks may not be granted anymore. Later, when the file system is unmounted, gfs2_gl_hash_clear() tries to clear out all the glocks, but these un-grantable pending waiters prevent some glocks from being freed. So the unmount hangs, at least for its ten-minute timeout period.
This patch takes measures to remove any pending waiters from the glocks that will never be granted. This allows the unmount to proceed in a reasonable period of time.
--- fs/gfs2/glock.c | 14 ++++++++++++++ fs/gfs2/glock.h | 1 + fs/gfs2/util.c | 5 +++++ 3 files changed, 20 insertions(+)
fs/gfs2/glock.c +14 -0
@@ -2194,6 +2194,20 @@ static void dump_glock_func(struct gfs2_glock *gl)dump_glock (NULL , gl, true); } +static void withdraw_dq (struct gfs2_glock *gl) +{ +spin_lock (&gl->gl_lockref.lock); +if (!__lockref_is_dead (&gl->gl_lockref) && +glock_blocked_by_withdraw (gl)) +do_error (gl,LM_OUT_ERROR );/* remove pending waiters */ +spin_unlock (&gl->gl_lockref.lock); +} + +void gfs2_gl_dq_holders (struct gfs2_sbd *sdp) +{ +glock_hash_walk (withdraw_dq, sdp); +} +/** * gfs2_gl_hash_clear - Empty out the glock hash table * @sdp: the filesystem
fs/gfs2/glock.h +1 -0
@@ -274,6 +274,7 @@ extern void gfs2_cancel_delete_work(struct gfs2_glock *gl);extern bool gfs2_delete_work_queued (const struct gfs2_glock *gl);extern void gfs2_flush_delete_work (struct gfs2_sbd *sdp);extern void gfs2_gl_hash_clear (struct gfs2_sbd *sdp); +extern void gfs2_gl_dq_holders (struct gfs2_sbd *sdp);extern void gfs2_glock_thaw (struct gfs2_sbd *sdp);extern void gfs2_glock_add_to_lru (struct gfs2_glock *gl);extern void gfs2_glock_free (struct gfs2_glock *gl);
fs/gfs2/util.c +5 -0
@@ -164,6 +164,11 @@ static void signal_our_withdraw(struct gfs2_sbd *sdp) }if (!ret)gfs2_make_fs_ro (sdp); +/* +* Dequeue any pending non-system glock holders that can no +* longer be granted because the file system is withdrawn. +*/ +gfs2_gl_dq_holders (sdp);gfs2_freeze_unlock (&freeze_gh); }
Signature · 1 line
2.37.2
PATCH v3 3/3 gfs2: Clear flags when withdraw prevents xmote
In reply to Bob PetersonThere are a couple places in function do_xmote where normal processing is circumvented due to withdraws in progress. However, since we bypass most of do_xmote() we bypass telling dlm to lock the dlm lock, which means dlm will never respond with a completion callback. Since the completion callback ordinarily clears GLF_LOCK, this patch changes function do_xmote to handle those situations more gracefully so the file system may be unmounted after withdraw.
A very similar situation happens with the GLF_DEMOTE_IN_PROGRESS flag, which is cleared by function finish_xmote(). Since the withdraw causes us to skip the majority of do_xmote, it therefore also skips the call to finish_xmote() so the DEMOTE_IN_PROGRESS flag needs to be cleared manually.
--- fs/gfs2/glock.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
fs/gfs2/glock.c +20 -2
@@ -59,6 +59,8 @@ typedef void (*glock_examiner) (struct gfs2_glock * gl);static void do_xmote (struct gfs2_glock *gl,struct gfs2_holder *gh,unsigned int target);static void __gfs2_glock_dq (struct gfs2_holder *gh); +static void handle_callback (struct gfs2_glock *gl,unsigned int state, +unsigned long delay,bool remote);static struct dentry *gfs2_root;static struct workqueue_struct *glock_workqueue;
@@ -730,7 +732,8 @@ static bool is_system_glock(struct gfs2_glock *gl)* */ -static void do_xmote (struct gfs2_glock *gl,struct gfs2_holder *gh,unsigned int target) +static void do_xmote (struct gfs2_glock *gl,struct gfs2_holder *gh, +unsigned int target) __releases(&gl->gl_lockref.lock) __acquires(&gl->gl_lockref.lock) {
@@ -741,7 +744,8 @@ __acquires(&gl->gl_lockref.lock)if (target !=LM_ST_UNLOCKED &&glock_blocked_by_withdraw (gl) && gh && !(gh->gh_flags &LM_FLAG_NOEXP )) -return ; + goto skip_inval; + lck_flags &= (LM_FLAG_TRY |LM_FLAG_TRY_1CB |LM_FLAG_NOEXP |LM_FLAG_PRIORITY );GLOCK_BUG_ON (gl, gl->gl_state == target);
@@ -826,6 +830,20 @@ __acquires(&gl->gl_lockref.lock) (target != LM_ST_UNLOCKED || test_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags))) {if (!is_system_glock (gl)) { +handle_callback (gl,LM_ST_UNLOCKED ,0 , false);/* sets demote */ +/* +* Ordinarily, we would call dlm and its callback would call +* finish_xmote, which would call state_change() to the new state. +* Since we withdrew, we won't call dlm, so call state_change +* manually, but to the UNLOCKED state we desire. +*/ +state_change (gl,LM_ST_UNLOCKED ); +/* +* We skip telling dlm to do the locking, so we won't get a +* reply that would otherwise clear GLF_LOCK. So we clear it here. +*/ +clear_bit (GLF_LOCK , &gl->gl_flags); +clear_bit (GLF_DEMOTE_IN_PROGRESS , &gl->gl_flags);gfs2_glock_queue_work (gl,GL_GLOCK_DFT_HOLD ); goto out; }else {
Signature · 1 line
2.37.2
v3 cover gfs2: Misc withdraw patches (version 3)
In reply to Bob PetersonQuoted 20 lines · Bob Peterson
This is version 3 which has further simplification and improvements.
This patch set fixes a few bugs in how gfs2 handles file systems after withdraw. In an ideal world, after a file system is withdrawn, users should be able to unmount the file system without problems. However, we discovered three problems that prevented clean unmounts:
1. A duplicate iput of the journal after attempted recovery caused kernel panics after withdraw.
2. After withdraw, unmount would hang for its alloted timeout period when glocks had waiters queued that, due to the withdraw, could never be granted.
3. Unmount would similarly hang when the withdraw prevented an outgoing request to dlm, but so the glock was never unlocked.Bob Peterson (3):
gfs2: Prevent double iput for journal on error
gfs2: Dequeue waiters when withdrawn
gfs2: Clear flags when withdraw prevents xmote
Quoted 8 lines
fs/gfs2/glock.c | 36 ++++++++++++++++++++++++++++++++++-- fs/gfs2/glock.h | 1 + fs/gfs2/util.c | 6 ++++++ 3 files changed, 41 insertions(+), 2 deletions(-)--
2.37.2
Pushed to for-next.
Thanks,
Andreas