From 16d7737894c0a8a111f64f04d7c6bdf0ddc86167 Mon Sep 17 00:00:00 2001 From: Di Wang Date: Tue, 26 Sep 2017 01:33:50 -0400 Subject: [PATCH] LU-9983 llog: skip non-exist log cancellation Let's skip the record cancellation if the llog does not exist at all, which usually happens when remote log creation failed. Signed-off-by: Di Wang Change-Id: If76d29d8fd72f3c5b619b72a899b18459c608dbb Reviewed-on: https://review.whamcloud.com/29218 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Fan Yong --- lustre/obdclass/llog_cat.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lustre/obdclass/llog_cat.c b/lustre/obdclass/llog_cat.c index 8771d68..084edea 100644 --- a/lustre/obdclass/llog_cat.c +++ b/lustre/obdclass/llog_cat.c @@ -754,16 +754,38 @@ int llog_cat_cancel_records(const struct lu_env *env, continue; } + if ((cathandle->lgh_ctxt->loc_flags & + LLOG_CTXT_FLAG_NORMAL_FID) && !llog_exist(loghandle)) { + /* For update log, some of loghandles of cathandle + * might not exist because remote llog creation might + * be failed, so let's skip the record cancellation + * for these non-exist llogs. + */ + lrc = -ENOENT; + CDEBUG(D_HA, "%s: llog "DFID":%x does not exist" + ": rc = %d\n", + cathandle->lgh_ctxt->loc_obd->obd_name, + PFID(&lgl->lgl_oi.oi_fid), lgl->lgl_ogen, lrc); + failed++; + if (rc == 0) + rc = lrc; + continue; + } + lrc = llog_cancel_rec(env, loghandle, cookies->lgc_index); if (lrc == LLOG_DEL_PLAIN) { /* log has been destroyed */ index = loghandle->u.phd.phd_cookie.lgc_index; - rc = llog_cat_cleanup(env, cathandle, loghandle, index); + lrc = llog_cat_cleanup(env, cathandle, loghandle, + index); + if (rc == 0) + rc = lrc; } else if (lrc == -ENOENT) { if (rc == 0) /* ENOENT shouldn't rewrite any error */ rc = lrc; } else if (lrc < 0) { failed++; - rc = lrc; + if (rc == 0) + rc = lrc; } llog_handle_put(loghandle); } -- 1.8.3.1