Whamcloud - gitweb
LU-7443 llog: remove unused and empty llog 27/17227/9
authorAlexander Boyko <alexander.boyko@seagate.com>
Tue, 17 Nov 2015 12:22:05 +0000 (15:22 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 4 Feb 2016 04:45:30 +0000 (04:45 +0000)
This patch adds ability to remove plain llog during record
cancellation for inactive plain llog. Before it such files
were removed during mount operation. And this is not enough
for changelog. The current marker of catalog could reach the
undeleted record, and this causes changelog problem.

Signed-off-by: Alexander Boyko <alexander.boyko@seagate.com>
Seagate-bug-id: MRP-2897
Change-Id: Ic24a1643f2fb264ad1212668e382a0bbc9b735b7
Reviewed-on: http://review.whamcloud.com/17227
Tested-by: Jenkins
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@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.c
lustre/tests/sanity.sh

index 56e941e..0fdd8fe 100644 (file)
@@ -258,7 +258,10 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle,
 
        if ((llh->llh_flags & LLOG_F_ZAP_WHEN_EMPTY) &&
            (llh->llh_count == 1) &&
 
        if ((llh->llh_flags & LLOG_F_ZAP_WHEN_EMPTY) &&
            (llh->llh_count == 1) &&
-           (loghandle->lgh_last_idx == LLOG_HDR_BITMAP_SIZE(llh) - 1)) {
+           ((loghandle->lgh_last_idx == LLOG_HDR_BITMAP_SIZE(llh) - 1) ||
+            (loghandle->u.phd.phd_cat_handle != NULL &&
+             loghandle->u.phd.phd_cat_handle->u.chd.chd_current_log !=
+               loghandle))) {
                rc = llog_trans_destroy(env, loghandle, th);
                if (rc < 0) {
                        /* Sigh, can not destroy the final plain llog, but
                rc = llog_trans_destroy(env, loghandle, th);
                if (rc < 0) {
                        /* Sigh, can not destroy the final plain llog, but
index 52d1f3a..2c239e4 100755 (executable)
@@ -13562,6 +13562,69 @@ test_252() {
 }
 run_test 252 "check lr_reader tool"
 
 }
 run_test 252 "check lr_reader tool"
 
+test_256() {
+       local cl_user
+       local cat_sl
+       local mdt_dev
+
+       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
+               skip "non-ldiskfs backend" && return
+
+       mdt_dev=$(mdsdevname 1)
+       echo $mdt_dev
+       cl_user=$(do_facet mds1 \
+       "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
+       if [[ -n $cl_user ]]; then
+               skip "active changelog user"
+               return
+       fi
+
+       cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
+       echo "Registered as changelog user $cl_user"
+
+       rm -rf $DIR/$tdir
+       mkdir -p $DIR/$tdir
+
+       $LFS changelog_clear $MDT0 $cl_user 0
+
+       # change something
+       touch $DIR/$tdir/{1..10}
+
+       # stop the MDT
+       stop mds1 || error "Fail to stop MDT."
+
+       # remount the MDT
+       start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
+
+       #after mount new plainllog is used
+       touch $DIR/$tdir/{11..19}
+       cat_sl=$(do_facet mds1 \
+       "$DEBUGFS -R \\\"dump changelog_catalog cat.dmp\\\" $mdt_dev; \
+        llog_reader cat.dmp | grep \\\"type=1064553b\\\" | wc -l")
+
+       if (( cat_sl != 2 )); then
+               do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
+               error "Changelog catalog has wrong number of slots $cat_sl"
+       fi
+
+       $LFS changelog_clear $MDT0 $cl_user 0
+
+       cat_sl=$(do_facet mds1 \
+       "$DEBUGFS -R \\\"dump changelog_catalog cat.dmp\\\" $mdt_dev; \
+        llog_reader cat.dmp | grep \\\"type=1064553b\\\" | wc -l")
+
+       do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
+
+       if (( cat_sl == 2 )); then
+               error "Empty plain llog was not deleted from changelog catalog"
+       fi
+       if (( cat_sl != 1 )); then
+               error "Active plain llog shouldn\`t be deleted from catalog"
+       fi
+}
+run_test 256 "Check llog delete for empty and not full state"
 
 cleanup_test_300() {
        trap 0
 
 cleanup_test_300() {
        trap 0