From: Fan Yong Date: Sun, 28 Aug 2016 09:41:14 +0000 (+0800) Subject: LU-8886 lfsck: handle -ENODATA for the end of iteration X-Git-Tag: 2.9.51~6 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8ff4556055edf496a0d23cf35fd0d63619143363 LU-8886 lfsck: handle -ENODATA for the end of iteration When the LFSCK engine makes checkpoint, it will record the current position (hash) of the iteration that can be used to resume the LFSCK scanning from the latest checkpoint. But if someone removed the target corresponding to the LFSCK checkpoint position, then the LFSCK will start scanning from the 'next' position when try to resume from the latest checkpoint. But if the 'next' hits the end of the iteration, the lower layer (ldiskfs) will return "-ENODATA" for dt_it_ops::load() call. The LFSCK engine needs to handle such case properly to avoid reguarding it as failure. Signed-off-by: Fan Yong Change-Id: I5a6a46cf3eefbdc680780abcc3402860736d6e0a Reviewed-on: https://review.whamcloud.com/24056 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/lfsck/lfsck_engine.c b/lustre/lfsck/lfsck_engine.c index c604bb9..0af5e95 100644 --- a/lustre/lfsck/lfsck_engine.c +++ b/lustre/lfsck/lfsck_engine.c @@ -362,7 +362,9 @@ int lfsck_open_dir(const struct lu_env *env, GOTO(out, rc = PTR_ERR(di)); rc = iops->load(env, di, cookie); - if (rc == 0 || (rc > 0 && cookie > 0)) + if (rc == -ENODATA) + rc = 1; + else if (rc == 0 || (rc > 0 && cookie > 0)) rc = iops->next(env, di); else if (rc > 0) rc = 0; @@ -441,7 +443,7 @@ static int lfsck_prep(const struct lu_env *env, struct lfsck_instance *lfsck, /* Init otable-based iterator. */ if (pos == NULL) { rc = iops->load(env, lfsck->li_di_oit, 0); - if (rc > 0) { + if (rc > 0 || unlikely(rc == -ENODATA)) { lfsck->li_oit_over = 1; rc = 0; } @@ -450,10 +452,10 @@ static int lfsck_prep(const struct lu_env *env, struct lfsck_instance *lfsck, } rc = iops->load(env, lfsck->li_di_oit, pos->lp_oit_cookie); - if (rc < 0) - GOTO(out, rc); - else if (rc > 0) + if (rc > 0 || unlikely(rc == -ENODATA)) lfsck->li_oit_over = 1; + else if (rc < 0) + GOTO(out, rc); if (!lfsck->li_master || fid_is_zero(&pos->lp_dir_parent)) GOTO(out, rc = 0);