From e82d8ad284fd37bbc4863723aa42c927d456fae6 Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Wed, 13 Dec 2017 13:50:11 +0800 Subject: [PATCH] LU-10321 lfsck: not start lfsck during umount There is race condition bewtween lfsck_start and umount: the LFSCK may be triggered just after the LFSCK stopped during umount the target, then nobody will stop the new started LFSCK, as to the umount may be blocked. This patch sets flag on the lfsck instance when umount that will prevent subsequent lfsck_start. This is a port to b2_10 of Lustre-change: https://review.whamcloud.com/#/c/30513/ Lustre-commit: 6263064b369dd4fddbb0dfa9ab49013a0d791629 Signed-off-by: Fan Yong Change-Id: I779f862d4195d4289bb9dd96575cd7746ac4b35b Reviewed-on: https://review.whamcloud.com/30514 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond --- lustre/lfsck/lfsck_internal.h | 3 ++- lustre/lfsck/lfsck_lib.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lustre/lfsck/lfsck_internal.h b/lustre/lfsck/lfsck_internal.h index fe0f6be..6c3c4f9 100644 --- a/lustre/lfsck/lfsck_internal.h +++ b/lustre/lfsck/lfsck_internal.h @@ -744,7 +744,8 @@ struct lfsck_instance { li_drop_dryrun:1, /* Ever dryrun, not now. */ li_master:1, /* Master instance or not. */ li_current_oit_processed:1, - li_start_unplug:1; + li_start_unplug:1, + li_stopping:1; struct lfsck_rec_lmv_save li_rec_lmv_save[LFSCK_REC_LMV_MAX_DEPTH]; }; diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index 8325bc2..29f88a7 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -3088,6 +3088,9 @@ int lfsck_start(const struct lu_env *env, struct dt_device *key, if (unlikely(lfsck == NULL)) RETURN(-ENXIO); + if (unlikely(lfsck->li_stopping)) + GOTO(put, rc = -ENXIO); + /* System is not ready, try again later. */ if (unlikely(lfsck->li_namespace == NULL || lfsck_dev_site(lfsck)->ss_server_fld == NULL)) @@ -3370,6 +3373,10 @@ int lfsck_stop(const struct lu_env *env, struct dt_device *key, } spin_lock(&lfsck->li_lock); + /* The target is umounted */ + if (stop && stop->ls_status == LS_PAUSED) + lfsck->li_stopping = 1; + if (thread_is_init(thread) || thread_is_stopped(thread)) /* no error if LFSCK stopped already, or not started */ GOTO(unlock, rc = 0); -- 1.8.3.1