From dc910ede715c4f13cde0c64d74e7badaa8dcb07b Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Tue, 13 May 2014 14:25:23 +0400 Subject: [PATCH] LU-5038 llog: do not scan for empty llogs at initialization in some cases the catalog can contain lots of non-empty llogs (e.g. robinhood isn't running all the time and this lead to many alive plain llogs) and scanning this in the context of mount can take a lot. instead we can do this during normal llog processing. Change-Id: I6c23b02b4a9733f80599314d37ffac6d2ee57001 Signed-off-by: Alex Zhuravlev Reviewed-on: http://review.whamcloud.com/10308 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/obdclass/llog_cat.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/lustre/obdclass/llog_cat.c b/lustre/obdclass/llog_cat.c index e5cafa7..6541d79 100644 --- a/lustre/obdclass/llog_cat.c +++ b/lustre/obdclass/llog_cat.c @@ -518,6 +518,7 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, struct llog_process_data *d = data; struct llog_logid_rec *lir = (struct llog_logid_rec *)rec; struct llog_handle *llh; + struct llog_log_hdr *hdr; int rc; ENTRY; @@ -537,6 +538,18 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, RETURN(rc); } + /* clean old empty llogs, do not consider current llog in use */ + hdr = llh->lgh_hdr; + if ((hdr->llh_flags & LLOG_F_ZAP_WHEN_EMPTY) && + hdr->llh_count == 1 && + llh != cat_llh->u.chd.chd_current_log) { + rc = llog_destroy(env, llh); + if (rc) + CERROR("%s: fail to destroy empty log: rc = %d\n", + llh->lgh_ctxt->loc_obd->obd_name, rc); + GOTO(out, rc = LLOG_DEL_PLAIN); + } + if (rec->lrh_index < d->lpd_startcat) { /* Skip processing of the logs until startcat */ rc = 0; @@ -554,6 +567,7 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, NULL, false); } +out: /* The empty plain log was destroyed while processing */ if (rc == LLOG_DEL_PLAIN) rc = llog_cat_cleanup(env, cat_llh, llh, @@ -620,6 +634,7 @@ static int llog_cat_reverse_process_cb(const struct lu_env *env, struct llog_process_data *d = data; struct llog_logid_rec *lir = (struct llog_logid_rec *)rec; struct llog_handle *llh; + struct llog_log_hdr *hdr; int rc; if (le32_to_cpu(rec->lrh_type) != LLOG_LOGID_MAGIC) { @@ -638,8 +653,21 @@ static int llog_cat_reverse_process_cb(const struct lu_env *env, RETURN(rc); } + /* clean old empty llogs, do not consider current llog in use */ + hdr = llh->lgh_hdr; + if ((hdr->llh_flags & LLOG_F_ZAP_WHEN_EMPTY) && + hdr->llh_count == 1 && + llh != cat_llh->u.chd.chd_current_log) { + rc = llog_destroy(env, llh); + if (rc) + CERROR("%s: fail to destroy empty log: rc = %d\n", + llh->lgh_ctxt->loc_obd->obd_name, rc); + GOTO(out, rc = LLOG_DEL_PLAIN); + } + rc = llog_reverse_process(env, llh, d->lpd_cb, d->lpd_data, NULL); +out: /* The empty plain was destroyed while processing */ if (rc == LLOG_DEL_PLAIN) rc = llog_cat_cleanup(env, cat_llh, llh, @@ -809,10 +837,6 @@ int llog_cat_init_and_process(const struct lu_env *env, if (rc) RETURN(rc); - rc = llog_process_or_fork(env, llh, cat_cancel_cb, NULL, NULL, false); - if (rc) - CERROR("%s: llog_process() with cat_cancel_cb failed: rc = " - "%d\n", llh->lgh_ctxt->loc_obd->obd_name, rc); RETURN(0); } EXPORT_SYMBOL(llog_cat_init_and_process); -- 1.8.3.1