From 795e13aeed68c08a72884c7db9df35b114d972b1 Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Thu, 5 Nov 2015 16:44:52 +0100 Subject: [PATCH] LU-7329 obdclass: sync device to flush journal callbacks After llog_test_10() has been added to check correct Catalog wrap-around as part of LU-6556, frequent auto-tests failures have been encountered due to OOM situation on VMs caused by a lot of journal commit callbacks backlog induced by the huge LLOG activity generated by new test. This patch forces frequent device sync to flush these journal commit callbacks. Signed-off-by: Bruno Faccini Change-Id: If06914a395f5bacbbb55fcdc229ffcd47d742843 Reviewed-on: http://review.whamcloud.com/17052 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/obdclass/llog_test.c | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/lustre/obdclass/llog_test.c b/lustre/obdclass/llog_test.c index 3629397..a6ab973 100644 --- a/lustre/obdclass/llog_test.c +++ b/lustre/obdclass/llog_test.c @@ -1397,6 +1397,7 @@ static int llog_test_10(const struct lu_env *env, struct obd_device *obd) struct llog_ctxt *ctxt; struct lu_attr la; __u64 cat_max_size; + struct dt_device *dt; ENTRY; @@ -1420,6 +1421,7 @@ static int llog_test_10(const struct lu_env *env, struct obd_device *obd) } cat_logid = cath->lgh_id; + dt = lu2dt_dev(cath->lgh_obj->do_lu.lo_dev); /* force catalog wrap for 5th plain LLOG */ cfs_fail_loc = CFS_FAIL_SKIP|OBD_FAIL_CAT_RECORDS; @@ -1440,6 +1442,15 @@ static int llog_test_10(const struct lu_env *env, struct obd_device *obd) if (rc) GOTO(out, rc); + /* sync device to commit all recent LLOG changes to disk and avoid + * to consume a huge space with delayed journal commit callbacks + * particularly on low memory nodes or VMs */ + rc = dt_sync(env, dt); + if (rc) { + CERROR("10b: sync failed: %d\n", rc); + GOTO(out, rc); + } + CWARN("10c: write %d more log records\n", 2 * LLOG_TEST_RECNUM); for (i = 0; i < 2 * LLOG_TEST_RECNUM; i++) { rc = llog_cat_add(env, cath, &lmr.lmr_hdr, NULL); @@ -1455,6 +1466,15 @@ static int llog_test_10(const struct lu_env *env, struct obd_device *obd) if (rc) GOTO(out, rc); + /* sync device to commit all recent LLOG changes to disk and avoid + * to consume a huge space with delayed journal commit callbacks + * particularly on low memory nodes or VMs */ + rc = dt_sync(env, dt); + if (rc) { + CERROR("10c: sync failed: %d\n", rc); + GOTO(out, rc); + } + /* fill last allocated plain LLOG and reach -ENOSPC condition * because no slot available in Catalog */ enospc = 0; @@ -1530,6 +1550,15 @@ static int llog_test_10(const struct lu_env *env, struct obd_device *obd) if (rc) GOTO(out, rc); + /* sync device to commit all recent LLOG changes to disk and avoid + * to consume a huge space with delayed journal commit callbacks + * particularly on low memory nodes or VMs */ + rc = dt_sync(env, dt); + if (rc) { + CERROR("10d: sync failed: %d\n", rc); + GOTO(out, rc); + } + enospc = 0; eok = 0; CWARN("10e: write %d more log records\n", LLOG_TEST_RECNUM); @@ -1597,6 +1626,15 @@ static int llog_test_10(const struct lu_env *env, struct obd_device *obd) CWARN("10e: catalog successfully wrap around, last_idx %d, first %d\n", cath->lgh_last_idx, cath->lgh_hdr->llh_cat_idx); + /* sync device to commit all recent LLOG changes to disk and avoid + * to consume a huge space with delayed journal commit callbacks + * particularly on low memory nodes or VMs */ + rc = dt_sync(env, dt); + if (rc) { + CERROR("10e: sync failed: %d\n", rc); + GOTO(out, rc); + } + /* cancel more records to free one more slot in Catalog * see if it is re-allocated when adding more records */ CWARN("10f: Cancel %d records, see one log zapped\n", LLOG_TEST_RECNUM); @@ -1628,6 +1666,15 @@ static int llog_test_10(const struct lu_env *env, struct obd_device *obd) if (rc) GOTO(out, rc); + /* sync device to commit all recent LLOG changes to disk and avoid + * to consume a huge space with delayed journal commit callbacks + * particularly on low memory nodes or VMs */ + rc = dt_sync(env, dt); + if (rc) { + CERROR("10f: sync failed: %d\n", rc); + GOTO(out, rc); + } + enospc = 0; eok = 0; CWARN("10f: write %d more log records\n", LLOG_TEST_RECNUM); @@ -1683,6 +1730,15 @@ static int llog_test_10(const struct lu_env *env, struct obd_device *obd) GOTO(out, rc = -EINVAL); } + /* sync device to commit all recent LLOG changes to disk and avoid + * to consume a huge space with delayed journal commit callbacks + * particularly on low memory nodes or VMs */ + rc = dt_sync(env, dt); + if (rc) { + CERROR("10f: sync failed: %d\n", rc); + GOTO(out, rc); + } + /* will llh_cat_idx also successfully wrap ? */ /* cancel all records in the plain LLOGs referenced by 2 last indexes in @@ -1718,6 +1774,15 @@ static int llog_test_10(const struct lu_env *env, struct obd_device *obd) if (rc) GOTO(out, rc); + /* sync device to commit all recent LLOG changes to disk and avoid + * to consume a huge space with delayed journal commit callbacks + * particularly on low memory nodes or VMs */ + rc = dt_sync(env, dt); + if (rc) { + CERROR("10g: sync failed: %d\n", rc); + GOTO(out, rc); + } + /* cancel more records to free one more slot in Catalog */ CWARN("10g: Cancel %d records, see one log zapped\n", LLOG_TEST_RECNUM); cancel_count = 0; @@ -1756,6 +1821,15 @@ static int llog_test_10(const struct lu_env *env, struct obd_device *obd) GOTO(out, rc = -EINVAL); } + /* sync device to commit all recent LLOG changes to disk and avoid + * to consume a huge space with delayed journal commit callbacks + * particularly on low memory nodes or VMs */ + rc = dt_sync(env, dt); + if (rc) { + CERROR("10g: sync failed: %d\n", rc); + GOTO(out, rc); + } + /* cancel more records to free one more slot in Catalog */ CWARN("10g: Cancel %d records, see one log zapped\n", LLOG_TEST_RECNUM); cancel_count = 0; -- 1.8.3.1