Whamcloud - gitweb
LU-5038 llog: do not scan for empty llogs at initialization 08/10308/6
authorAlex Zhuravlev <alexey.zhuravlev@intel.com>
Tue, 13 May 2014 10:25:23 +0000 (14:25 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 16 Jul 2014 02:27:03 +0000 (02:27 +0000)
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 <alexey.zhuravlev@intel.com>
Reviewed-on: http://review.whamcloud.com/10308
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/obdclass/llog_cat.c

index e5cafa7..6541d79 100644 (file)
@@ -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);