Whamcloud - gitweb
LU-5859 llog: do not cleanup orphans in remote catalogs
[fs/lustre-release.git] / lustre / obdclass / llog_cat.c
index ae443e6..e7114cf 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -511,8 +511,9 @@ int llog_cat_cancel_records(const struct lu_env *env,
 }
 EXPORT_SYMBOL(llog_cat_cancel_records);
 
-int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh,
-                       struct llog_rec_hdr *rec, void *data)
+static int llog_cat_process_cb(const struct lu_env *env,
+                              struct llog_handle *cat_llh,
+                              struct llog_rec_hdr *rec, void *data)
 {
         struct llog_process_data *d = data;
         struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
@@ -549,9 +550,10 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh,
        }
 
        /* clean old empty llogs, do not consider current llog in use */
+       /* ignore remote (lgh_obj=NULL) llogs */
        hdr = llh->lgh_hdr;
        if ((hdr->llh_flags & LLOG_F_ZAP_WHEN_EMPTY) &&
-           hdr->llh_count == 1 &&
+           hdr->llh_count == 1 && cat_llh->lgh_obj != NULL &&
            llh != cat_llh->u.chd.chd_current_log) {
                rc = llog_destroy(env, llh);
                if (rc)
@@ -739,7 +741,7 @@ int llog_cat_reverse_process(const struct lu_env *env,
 }
 EXPORT_SYMBOL(llog_cat_reverse_process);
 
-int llog_cat_set_first_idx(struct llog_handle *cathandle, int index)
+static int llog_cat_set_first_idx(struct llog_handle *cathandle, int index)
 {
         struct llog_log_hdr *llh = cathandle->lgh_hdr;
         int i, bitmap_size, idx;
@@ -800,7 +802,8 @@ int llog_cat_cleanup(const struct lu_env *env, struct llog_handle *cathandle,
        return rc;
 }
 
-int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle,
+int cat_cancel_cb(const struct lu_env *env,
+                 struct llog_handle *cathandle,
                  struct llog_rec_hdr *rec, void *data)
 {
        struct llog_logid_rec   *lir = (struct llog_logid_rec *)rec;
@@ -861,4 +864,3 @@ int llog_cat_init_and_process(const struct lu_env *env,
        RETURN(0);
 }
 EXPORT_SYMBOL(llog_cat_init_and_process);
-