Whamcloud - gitweb
LU-13411 llog: allow delete of zero size llog 31/38131/5
authorAlexander Boyko <c17825@cray.com>
Fri, 3 Apr 2020 12:34:54 +0000 (08:34 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 20 May 2020 08:22:21 +0000 (08:22 +0000)
1) all plain logs belonging to catalog should have flag
LLOG_F_ZAP_WHEN_EMPTY base on llog_cat_new_log(). When
llog_cat_process_common processing plain log with zero file size,
this flag is not set during llog_cat_id2handle LLOG_EMPTY, so these
plain llogs are not canceled/destroyed. They appeared during cross
MDT updates. Fix adds flag LLOG_F_ZAP_WHEN_EMPTY for any plain llog
at catalog.

Signed-off-by: Alexander Boyko <c17825@cray.com>
Cray-bug-id: LUS-8634
Change-Id: Ieebee67bf9e7bebb9ecc51b858a9976a00583c7b
Reviewed-on: https://review.whamcloud.com/38131
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alexander Zarochentsev <alexander.zarochentsev@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/llog.c
lustre/obdclass/llog_cat.c

index 75224fd..2f8c046 100644 (file)
@@ -797,7 +797,8 @@ int llog_process_or_fork(const struct lu_env *env,
        struct llog_process_info *lpi;
        struct llog_process_data *d = data;
        struct llog_process_cat_data *cd = catdata;
-       int                      rc;
+       __u32 flags = loghandle->lgh_hdr->llh_flags;
+       int rc;
 
        ENTRY;
 
@@ -812,10 +813,10 @@ int llog_process_or_fork(const struct lu_env *env,
        lpi->lpi_catdata   = catdata;
 
        CDEBUG(D_OTHER, "Processing "DFID" flags 0x%03x startcat %d startidx %d first_idx %d last_idx %d\n",
-              PFID(&loghandle->lgh_id.lgl_oi.oi_fid),
-              loghandle->lgh_hdr->llh_flags, d ? d->lpd_startcat : -1,
-              d ? d->lpd_startidx : -1, cd ? cd->lpcd_first_idx : -1,
-              cd ? cd->lpcd_last_idx : -1);
+              PFID(&loghandle->lgh_id.lgl_oi.oi_fid), flags,
+              (flags & LLOG_F_IS_CAT) && d ? d->lpd_startcat : -1,
+              (flags & LLOG_F_IS_CAT) && d ? d->lpd_startidx : -1,
+              cd ? cd->lpcd_first_idx : -1, cd ? cd->lpcd_last_idx : -1);
        if (fork) {
                struct task_struct *task;
 
index 9ada0e8..15804cd 100644 (file)
@@ -419,7 +419,8 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle,
                RETURN(rc);
        }
 
-       rc = llog_init_handle(env, loghandle, LLOG_F_IS_PLAIN | fmt, NULL);
+       rc = llog_init_handle(env, loghandle, LLOG_F_IS_PLAIN |
+                             LLOG_F_ZAP_WHEN_EMPTY | fmt, NULL);
        if (rc < 0) {
                llog_close(env, loghandle);
                *res = NULL;
@@ -884,13 +885,9 @@ static int llog_cat_process_cb(const struct lu_env *env,
 
 out:
        /* The empty plain log was destroyed while processing */
-       if (rc == LLOG_DEL_PLAIN) {
-               rc = llog_cat_cleanup(env, cat_llh, llh,
-                                     llh->u.phd.phd_cookie.lgc_index);
-       } else if (rc == LLOG_DEL_RECORD) {
+       if (rc == LLOG_DEL_PLAIN || rc == LLOG_DEL_RECORD)
                /* clear wrong catalog entry */
-               rc = llog_cat_cleanup(env, cat_llh, NULL, rec->lrh_index);
-       }
+               rc = llog_cat_cleanup(env, cat_llh, llh, rec->lrh_index);
 
        if (llh)
                llog_handle_put(env, llh);
@@ -1169,7 +1166,8 @@ int llog_cat_cleanup(const struct lu_env *env, struct llog_handle *cathandle,
                        cathandle->u.chd.chd_current_log = NULL;
                list_del_init(&loghandle->u.phd.phd_entry);
                up_write(&cathandle->lgh_lock);
-               LASSERT(index == loghandle->u.phd.phd_cookie.lgc_index);
+               LASSERT(index == loghandle->u.phd.phd_cookie.lgc_index ||
+                       loghandle->u.phd.phd_cookie.lgc_index == 0);
                /* llog was opened and keep in a list, close it now */
                llog_close(env, loghandle);
        }