gfs2: improvements to recovery and withdraw process
cover gfs2: improvements to recovery and withdraw process
Hi,
This is a first draft of a two-patch set to fix some of the nasty journal recovery problems I've found lately.
The problems have to do with file system corruption caused when recovery replays a journal after the resource group blocks have been unlocked by the recovery process. In other words, when no cluster node takes responsibility to replay the journal of a withdrawing node, then it gets replayed later on, after the blocks contents have been changed.
The first patch prevents gfs2 from attempting recovery if the file system is withdrawn or has journal IO errors. Trying to recover your own journal from either of these unstable conditions is dangerous and likely to corrupt the file system.
The second patch is more extensive. When a node withdraws from a file system it first empties out all ourstanding pages in the ail lists, then it signals all other nodes with the file system mounted to perform recovery on its journal since it cannot safely recover its own journal. This is accomplished by a new non-disk callback glop used exclusively by the "live" glock, which sets up an lvb in the glock to indicate which journal(s) need to be replayed. This sytem makes it necessary to prevent recursion, since the journal operations themselves (i.e. the ones that empty out the ail list on withdraw) can also withdraw. Thus, the withdraw system is now separated into "journal" and "non-journal" withdraws. Also, the "withdraw" flag is now replaced by a superblock bit because once the file system withdraws in this way, it needs to remember that from that point on.
Regards,
Bob Peterson
---
Bob Peterson (2):
gfs2: Ignore recovery attempts if gfs2 has io error or is withdrawn
gfs2: initiate journal recovery as soon as a node withdraws
fs/gfs2/glock.c | 5 ++- fs/gfs2/glops.c | 47 +++++++++++++++++++++++ fs/gfs2/incore.h | 3 ++ fs/gfs2/lock_dlm.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++ fs/gfs2/log.c | 62 ++++++++++++++++-------------- fs/gfs2/super.c | 5 ++- fs/gfs2/super.h | 1 + fs/gfs2/util.c | 84 ++++++++++++++++++++++++++++++++++++++++ fs/gfs2/util.h | 13 +++++++ 9 files changed, 282 insertions(+), 33 deletions(-)
Signature · 1 line
2.17.2
PATCH 1/2 gfs2: Ignore recovery attempts if gfs2 has io error or is withdrawn
Before this patch, when a node had an io error or was withdrawn, the dlm would send its normal callbacks to start recovery. But if the file system has an io error, it cannot safely replay its journal anyway; someone else needs to do it. Also, if it's withdrawn, we don't want it messing with the journal recovery generation numbers. If we try to do journal recovery and update the generation number, it can confuse the remaining functioning nodes into believing the recovery is not necessary.
This patch adds checks to the callbacks used by dlm so that the functions are skipped if an io error has occurred or if the file system was withdraw.
--- fs/gfs2/lock_dlm.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
fs/gfs2/lock_dlm.c +36 -0
@@ -1081,6 +1081,14 @@ static void gdlm_recover_prep(void *arg)struct gfs2_sbd *sdp = arg;struct lm_lockstruct *ls = &sdp->sd_lockstruct; +if (test_bit (SDF_AIL1_IO_ERROR , &sdp->sd_flags)) { +fs_err (sdp,"recover prep ignored due to io error.\n" ); +return ; + } +if (test_bit (SDF_SHUTDOWN , &sdp->sd_flags)) { +fs_err (sdp,"recover prep ignored due to withdraw.\n" ); +return ; + }spin_lock (&ls->ls_recover_spin); ls->ls_recover_block = ls->ls_recover_start;set_bit (DFL_DLM_RECOVERY , &ls->ls_recover_flags);
@@ -1103,6 +1111,16 @@ static void gdlm_recover_slot(void *arg, struct dlm_slot *slot)struct lm_lockstruct *ls = &sdp->sd_lockstruct;int jid = slot->slot -1 ; +if (test_bit (SDF_AIL1_IO_ERROR , &sdp->sd_flags)) { +fs_err (sdp,"recover slot jid %d ignored due to io error.\n" , + jid); +return ; + } +if (test_bit (SDF_SHUTDOWN , &sdp->sd_flags)) { +fs_err (sdp,"recover slot jid %d ignored due to withdraw.\n" , + jid); +return ; + }spin_lock (&ls->ls_recover_spin);if (ls->ls_recover_size < jid +1 ) { fs_err(sdp, "recover_slot jid %d gen %u short size %d\n",
@@ -1127,6 +1145,14 @@ static void gdlm_recover_done(void *arg, struct dlm_slot *slots, int num_slots,struct gfs2_sbd *sdp = arg;struct lm_lockstruct *ls = &sdp->sd_lockstruct; +if (test_bit (SDF_AIL1_IO_ERROR , &sdp->sd_flags)) { +fs_err (sdp,"recover done ignored due to io error.\n" ); +return ; + } +if (test_bit (SDF_SHUTDOWN , &sdp->sd_flags)) { +fs_err (sdp,"recover done ignored due to withdraw.\n" ); +return ; + }/* ensure the ls jid arrays are large enough */ set_recover_size (sdp, slots, num_slots);
@@ -1154,6 +1180,16 @@ static void gdlm_recovery_result(struct gfs2_sbd *sdp, unsigned int jid, {struct lm_lockstruct *ls = &sdp->sd_lockstruct; +if (test_bit (SDF_AIL1_IO_ERROR , &sdp->sd_flags)) { +fs_err (sdp,"recovery result jid %d ignored due to io error.\n" , + jid); +return ; + } +if (test_bit (SDF_SHUTDOWN , &sdp->sd_flags)) { +fs_err (sdp,"recovery result jid %d ignored due to withdraw.\n" , + jid); +return ; + }if (test_bit (DFL_NO_DLM_OPS , &ls->ls_recover_flags))return ;
Signature · 1 line
2.17.2
PATCH 2/2 gfs2: initiate journal recovery as soon as a node withdraws
In reply to Bob PetersonThis patch uses the "live" glock and some new lvbs to signal when a node has withdrawn from a file system. Nodes who see this try to initiate journal recovery. When they withdraw, the need to flush the metadata buffers and mark the file system read-only so journal replay doesn't corrupt any data. They also need to avoid certain operations if the withdraw comes from a journal operation.
--- fs/gfs2/glock.c | 5 +-- fs/gfs2/glops.c | 47 ++++++++++++++++++++++++++ fs/gfs2/incore.h | 3 ++ fs/gfs2/lock_dlm.c | 59 ++++++++++++++++++++++++++++++++ fs/gfs2/log.c | 62 ++++++++++++++++++---------------- fs/gfs2/super.c | 5 +-- fs/gfs2/super.h | 1 + fs/gfs2/util.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++ fs/gfs2/util.h | 13 +++++++ 9 files changed, 246 insertions(+), 33 deletions(-)
fs/gfs2/glock.c +3 -2
@@ -543,7 +543,7 @@ __acquires(&gl->gl_lockref.lock)int ret;if (unlikely (test_bit (SDF_SHUTDOWN , &sdp->sd_flags)) && - target !=LM_ST_UNLOCKED ) + gl->gl_ops != &gfs2_nondisk_glops && target !=LM_ST_UNLOCKED )return ; lck_flags &= (LM_FLAG_TRY |LM_FLAG_TRY_1CB |LM_FLAG_NOEXP |LM_FLAG_PRIORITY );
@@ -1092,7 +1092,8 @@ int gfs2_glock_nq(struct gfs2_holder *gh)struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;int error =0 ; -if (unlikely (test_bit (SDF_SHUTDOWN , &sdp->sd_flags))) +if (unlikely (test_bit (SDF_SHUTDOWN , &sdp->sd_flags) && + gl->gl_ops != &gfs2_nondisk_glops))return -EIO ;if (test_bit (GLF_LRU , &gl->gl_flags))
fs/gfs2/glops.c +47 -0
65 lines not on this page · raw message
fs/gfs2/incore.h +3 -0
@@ -346,6 +346,7 @@ enum {GLF_OBJECT =14 ,/* Used only for tracing */ GLF_BLOCKING =15 ,GLF_INODE_CREATING =16 ,/* Inode creation occurring */ + GLF_IN_RECOVERY = 17, /* glock is in recovery */ }; struct gfs2_glock {
@@ -622,6 +623,8 @@ enum {SDF_SKIP_DLM_UNLOCK =8 ,SDF_FORCE_AIL_FLUSH =9 ,SDF_AIL1_IO_ERROR =10 , +SDF_REMOTE_WITHDRAW =11 ,/* another node did withdraw */ + SDF_JOURNAL_WITHDRAW = 12, /* Was withdrawn from a log operation */ }; enum gfs2_freeze_state {
fs/gfs2/lock_dlm.c +59 -0
83 lines not on this page · raw message
fs/gfs2/log.c +33 -29
164 lines not on this page · raw message
fs/gfs2/super.c +3 -2
@@ -844,7 +844,7 @@ static void gfs2_dirty_inode(struct inode *inode, int flags)* Returns: errno */ -static int gfs2_make_fs_ro (struct gfs2_sbd *sdp) +int gfs2_make_fs_ro (struct gfs2_sbd *sdp) {struct gfs2_holder freeze_gh;int error;
@@ -922,7 +922,8 @@ static void gfs2_put_super(struct super_block *sb)if (!sdp->sd_args.ar_spectator) {gfs2_glock_dq_uninit (&sdp->sd_journal_gh); -gfs2_glock_dq_uninit (&sdp->sd_jinode_gh); +if (gfs2_holder_initialized (&sdp->sd_jinode_gh)) +gfs2_glock_dq_uninit (&sdp->sd_jinode_gh);gfs2_glock_dq_uninit (&sdp->sd_sc_gh);gfs2_glock_dq_uninit (&sdp->sd_qc_gh);iput (sdp->sd_sc_inode);
fs/gfs2/super.h +1 -0
@@ -46,6 +46,7 @@ extern void update_statfs(struct gfs2_sbd *sdp, struct buffer_head *m_bh, struct buffer_head *l_bh);extern int gfs2_statfs_sync (struct super_block *sb,int type);extern void gfs2_freeze_func (struct work_struct *work); +extern int gfs2_make_fs_ro (struct gfs2_sbd *sdp);extern struct file_system_type gfs2_fs_type;extern struct file_system_type gfs2meta_fs_type;
fs/gfs2/util.c +84 -0
117 lines not on this page · raw message
fs/gfs2/util.h +13 -0
@@ -41,11 +41,17 @@ do { \int gfs2_assert_withdraw_i (struct gfs2_sbd *sdp,char *assertion,const char *function,char *file,unsigned int line); +int gfs2_assert_withdraw_j (struct gfs2_sbd *sdp,char *assertion, +const char *function,char *file,unsigned int line);#define gfs2_assert_withdraw (sdp, assertion) \ ((likely(assertion)) ? 0 : gfs2_assert_withdraw_i((sdp), #assertion, \ __func__, __FILE__, __LINE__)) +#define gfs2_jrnl_assert_withdraw (sdp, assertion) \ +((likely(assertion)) ? 0 : gfs2_assert_withdraw_j((sdp), #assertion, \ + __func__, __FILE__, __LINE__)) +int gfs2_assert_warn_i (struct gfs2_sbd *sdp,char *assertion,const char *function,char *file,unsigned int line);
@@ -140,12 +146,19 @@ void gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh, const char *function, char *file, unsigned int line, bool withdraw); +void gfs2_jrnl_io_error_bh_i (struct gfs2_sbd *sdp,struct buffer_head *bh, +const char *function,char *file, +unsigned int line,bool withdraw); +#define gfs2_io_error_bh_wd (sdp, bh) \ gfs2_io_error_bh_i((sdp), (bh), __func__, __FILE__, __LINE__, true);#define gfs2_io_error_bh (sdp, bh) \ gfs2_io_error_bh_i((sdp), (bh), __func__, __FILE__, __LINE__, false); +#define gfs2_jrnl_io_error_bh (sdp, bh) \ +gfs2_jrnl_io_error_bh_i((sdp), (bh), __func__, __FILE__, __LINE__, false); +extern struct kmem_cache *gfs2_glock_cachep;extern struct kmem_cache *gfs2_glock_aspace_cachep;
Signature · 1 line
2.17.2
cover gfs2: improvements to recovery and withdraw process
In reply to Bob PetersonHi,
Quoted 11 lines · Bob Peterson
Hi,
This is a first draft of a two-patch set to fix some of the nasty journal recovery problems I've found lately.
The problems have to do with file system corruption caused when recovery replays a journal after the resource group blocks have been unlocked by the recovery process. In other words, when no cluster node takes responsibility to replay the journal of a withdrawing node, then it gets replayed later on, after the blocks contents have been changed.
Quoted 4 lines
The first patch prevents gfs2 from attempting recovery if the file system is withdrawn or has journal IO errors. Trying to recover your own journal from either of these unstable conditions is dangerous and likely to corrupt the file system.
That sounds sensible to me.
Quoted 2 lines
The second patch is more extensive. When a node withdraws from a file system it first empties out all ourstanding pages in the ail lists, then it
How are we doing this? Since the disk can no longer be written to, there are two cases we need to cover. One is for dirty but not yet written pages. The other for pages in flight - these will need to either time out or complete somehow.
Quoted 7 lines
signals all other nodes with the file system mounted to perform recovery on its journal since it cannot safely recover its own journal. This is accomplished by a new non-disk callback glop used exclusively by the "live" glock, which sets up an lvb in the glock to indicate which journal(s) need to be replayed. This sytem makes it necessary to prevent recursion, since the journal operations themselves (i.e. the ones that empty out the ail list on withdraw) can also withdraw. Thus, the withdraw
We should ignore any further I/O errors after we have withdrawn I think, since we know that no further disk writes can take place anyway. These will be completed as EIO by dm. As you say we definitely don't want the node that is withdrawing replaying its own journal. That should be done by the remaining nodes in the cluster.
The other question is should we just use the "normal" recovery process which would fence the withdrawn node, or whether we should have a different system which avoids the fencing, since we have effectively self-fenced from the storage. Looking at the patch I assume that perhaps this implements the latter?
Steve.
Quoted 24 lines
system is now separated into "journal" and "non-journal" withdraws. Also, the "withdraw" flag is now replaced by a superblock bit because once the file system withdraws in this way, it needs to remember that from that point on.
Regards,
Bob Peterson
---
Bob Peterson (2):
gfs2: Ignore recovery attempts if gfs2 has io error or is withdrawn
gfs2: initiate journal recovery as soon as a node withdrawsfs/gfs2/glock.c | 5 ++- fs/gfs2/glops.c | 47 +++++++++++++++++++++++ fs/gfs2/incore.h | 3 ++ fs/gfs2/lock_dlm.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++ fs/gfs2/log.c | 62 ++++++++++++++++-------------- fs/gfs2/super.c | 5 ++- fs/gfs2/super.h | 1 + fs/gfs2/util.c | 84 ++++++++++++++++++++++++++++++++++++++++ fs/gfs2/util.h | 13 +++++++ 9 files changed, 282 insertions(+), 33 deletions(-)