From f623f68ae3cbfc6e2d4951aefb3047f72e669564 Mon Sep 17 00:00:00 2001 From: Alexander Boyko Date: Tue, 17 Nov 2015 15:22:05 +0300 Subject: [PATCH] LU-7443 llog: remove unused and empty llog 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 Seagate-bug-id: MRP-2897 Change-Id: Ic24a1643f2fb264ad1212668e382a0bbc9b735b7 Reviewed-on: http://review.whamcloud.com/17227 Tested-by: Jenkins Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/obdclass/llog.c | 5 +++- lustre/tests/sanity.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index 56e941e..0fdd8fe 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -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) && - (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 diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 52d1f3a..2c239e4 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -13562,6 +13562,69 @@ test_252() { } 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 -- 1.8.3.1