From 0f158c6a093e059d89f637f31d34742078c38209 Mon Sep 17 00:00:00 2001 From: Etienne AUJAMES Date: Wed, 13 Apr 2022 16:43:12 +0200 Subject: [PATCH] LU-15055 lod: run qmt_pool_* only from the MDT0000 config On the first mds (with MDT0000/QMT0000), if there is more than one MDT target, qmt_pool_{new/del/rem/add} functions will be call several times on QMT0000 for the same pool. This resulting to the following error in dmseg: LustreError: 5659:0:(qmt_pool.c:1390:qmt_pool_add_rem()) add to: can't scratch-QMT0000 scratch-OST0000_UUID pool pool1: rc = -17 This patch run qmt_pool_* only from a record config from the MDT0000. The qmt_pool_add_rem() dmesg error is checked on sanity-quota test_1b. Test-Parameters: mdtcount=2 mdscount=1 testlist=sanity-quota Fixes: 09f9fb32 ("LU-11023 quota: quota pools for OSTs") Signed-off-by: Etienne AUJAMES Change-Id: Ia6b712abe25a4d68770753e3408c3321181db1aa Reviewed-on: https://review.whamcloud.com/47059 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: Sergey Cheremencev Reviewed-by: Oleg Drokin --- lustre/lod/lod_dev.c | 19 +++++++++++++++---- lustre/quota/qmt_pool.c | 7 ++++--- lustre/tests/sanity-quota.sh | 6 ++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/lustre/lod/lod_dev.c b/lustre/lod/lod_dev.c index e535d2e..7021419 100644 --- a/lustre/lod/lod_dev.c +++ b/lustre/lod/lod_dev.c @@ -2219,11 +2219,22 @@ static struct obd_device *obd_find_qmt0(char *obd_name) return qmt; } +/* Run QMT0000 pool operations only for MDT0000 */ +static inline bool lod_pool_need_qmt0(const char *obd_name) +{ + __u32 idx; + int type; + + type = server_name2index(obd_name, &idx, NULL); + + return type == LDD_F_SV_TYPE_MDT && idx == 0; +} + static int lod_pool_new_q(struct obd_device *obd, char *poolname) { int err = lod_pool_new(obd, poolname); - if (!err) { + if (!err && lod_pool_need_qmt0(obd->obd_name)) { obd = obd_find_qmt0(obd->obd_name); if (obd) obd_pool_new(obd, poolname); @@ -2237,7 +2248,7 @@ static int lod_pool_remove_q(struct obd_device *obd, char *poolname, { int err = lod_pool_remove(obd, poolname, ostname); - if (!err) { + if (!err && lod_pool_need_qmt0(obd->obd_name)) { obd = obd_find_qmt0(obd->obd_name); if (obd) obd_pool_rem(obd, poolname, ostname); @@ -2250,7 +2261,7 @@ static int lod_pool_add_q(struct obd_device *obd, char *poolname, char *ostname) { int err = lod_pool_add(obd, poolname, ostname); - if (!err) { + if (!err && lod_pool_need_qmt0(obd->obd_name)) { obd = obd_find_qmt0(obd->obd_name); if (obd) obd_pool_add(obd, poolname, ostname); @@ -2263,7 +2274,7 @@ static int lod_pool_del_q(struct obd_device *obd, char *poolname) { int err = lod_pool_del(obd, poolname); - if (!err) { + if (!err && lod_pool_need_qmt0(obd->obd_name)) { obd = obd_find_qmt0(obd->obd_name); if (obd) obd_pool_del(obd, poolname); diff --git a/lustre/quota/qmt_pool.c b/lustre/quota/qmt_pool.c index 4b6004a..dcfb7c7 100644 --- a/lustre/quota/qmt_pool.c +++ b/lustre/quota/qmt_pool.c @@ -1397,9 +1397,10 @@ static int qmt_pool_add_rem(struct obd_device *obd, char *poolname, rc = add ? qmt_sarr_pool_add(qpi, idx, 32) : qmt_sarr_pool_rem(qpi, idx); if (rc) { - CERROR("%s: can't %s %s pool %s: rc = %d\n", - add ? "add to" : "remove", obd->obd_name, - slavename, poolname, rc); + /* message is checked in sanity-quota test_1b */ + CERROR("%s: can't %s %s pool '%s': rc = %d\n", + obd->obd_name, add ? "add to" : "remove", slavename, + poolname, rc); GOTO(out_putref, rc); } qmt_pool_slv_nr_change(&env, qpi, idx, add); diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index cfcc258..d36cefe 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -708,6 +708,12 @@ test_1b() { pool_add_targets $qpool 0 $(($OSTCOUNT - 1)) || error "pool_add_targets failed" + # check qmt_pool_add dmesg error + local msg_rgx="QMT0000: can't add to $FSNAME-OST0000.*pool.*$qpool" + local dmesg_err + dmesg_err=$(do_facet mds1 dmesg | grep "$msg_rgx" | tail -1) + [[ -z "$dmesg_err" ]] || error "found qmt_pool_add error: $dmesg_err" + $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR || error "set user quota failed" -- 1.8.3.1