From 72f87638570508d5d02868d4e90b131670ae2b17 Mon Sep 17 00:00:00 2001 From: fanyong Date: Thu, 22 Oct 2009 02:38:49 +0000 Subject: [PATCH] Branch HEAD b=20811 i=tianzy i=robert.read Do not try to acquire quota from master repeatly if mismatched quota configure was found. --- lustre/lvfs/fsfilt_ext3.c | 4 ++-- lustre/lvfs/lustre_quota_fmt.c | 2 +- lustre/quota/quota_context.c | 4 ++++ lustre/quota/quota_interface.c | 7 +++++++ lustre/tests/sanity-quota.sh | 7 +++++-- lustre/tests/test-framework.sh | 19 ++++++++++++++----- 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c index 8cfbd00..36d126d 100644 --- a/lustre/lvfs/fsfilt_ext3.c +++ b/lustre/lvfs/fsfilt_ext3.c @@ -2096,7 +2096,7 @@ static int fsfilt_ext3_quotainfo(struct lustre_quota_info *lqi, int type, if (lqi->qi_files[type] == NULL) { CERROR("operate qinfo before it's enabled!\n"); - RETURN(-EIO); + RETURN(-ESRCH); } switch (cmd) { @@ -2139,7 +2139,7 @@ static int fsfilt_ext3_dquot(struct lustre_dquot *dquot, int cmd) if (dquot->dq_info->qi_files[dquot->dq_type] == NULL) { CERROR("operate dquot before it's enabled!\n"); - RETURN(-EIO); + RETURN(-ESRCH); } switch (cmd) { diff --git a/lustre/lvfs/lustre_quota_fmt.c b/lustre/lvfs/lustre_quota_fmt.c index 0488c2c..937e496 100644 --- a/lustre/lvfs/lustre_quota_fmt.c +++ b/lustre/lvfs/lustre_quota_fmt.c @@ -843,7 +843,7 @@ int lustre_read_dquot(struct lustre_dquot *dquot) /* Invalidated quota? */ if (!dquot->dq_info || !(filp = dquot->dq_info->qi_files[type])) { CDEBUG(D_ERROR, "VFS: Quota invalidated while reading!\n"); - return -EIO; + return -ESRCH; } version = dquot->dq_info->qi_version; diff --git a/lustre/quota/quota_context.c b/lustre/quota/quota_context.c index 440ddf8..e65bfaf 100644 --- a/lustre/quota/quota_context.c +++ b/lustre/quota/quota_context.c @@ -830,6 +830,10 @@ static int dqacq_interpret(const struct lu_env *env, rc = -EPROTO; } + if (unlikely(rc == -ESRCH)) + CERROR("quota for %s has been enabled by master, but disabled " + "by slave.\n", QDATA_IS_GRP(qdata) ? "group" : "user"); + rc = dqacq_completion(obd, qctxt, qdata, rc, lustre_msg_get_opc(req->rq_reqmsg)); diff --git a/lustre/quota/quota_interface.c b/lustre/quota/quota_interface.c index 1a8076b..df2039a 100644 --- a/lustre/quota/quota_interface.c +++ b/lustre/quota/quota_interface.c @@ -461,6 +461,13 @@ static int quota_chk_acq_common(struct obd_device *obd, const unsigned int id[], break; } + /* Related quota has been disabled by master, but enabled by + * slave, do not try again. */ + if (unlikely(rc == -ESRCH)) { + CERROR("mismatched quota configuration, stop try.\n"); + break; + } + /* -EBUSY and others, wait a second and try again */ if (rc < 0) { cfs_waitq_t waitq; diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index d752e97..fe14e19 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -52,8 +52,6 @@ DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio} [ $MDSCOUNT -gt 1 ] && skip "CMD case" && exit 0 -unset ENABLE_QUOTA - remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0 @@ -66,11 +64,15 @@ QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log} DIR=${DIR:-$MOUNT} DIR2=${DIR2:-$MOUNT2} +QUOTA_AUTO_OLD=$QUOTA_AUTO +export QUOTA_AUTO=0 + check_and_setup_lustre if [ x"$(som_check)" = x"enabled" ]; then echo "Som is enabled, Quota is temporary conflicts with it" check_and_cleanup_lustre + export QUOTA_AUTO=$QUOTA_AUTO_OLD exit 0 fi @@ -2135,5 +2137,6 @@ log "cleanup: ======================================================" cd $ORIG_PWD check_and_cleanup_lustre echo '=========================== finished ===============================' +export QUOTA_AUTO=$QUOTA_AUTO_OLD [ -f "$QUOTALOG" ] && cat $QUOTALOG && grep -q FAIL $QUOTALOG && exit 1 || true echo "$0: completed" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 3e49798..66aba36 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -15,6 +15,7 @@ export GSS=false export GSS_KRB5=false export GSS_PIPEFS=false export IDENTITY_UPCALL=default +export QUOTA_AUTO=1 #export PDSH="pdsh -S -Rssh -w" @@ -545,9 +546,7 @@ restore_quota_type () { setup_quota(){ local mntpt=$1 - # We need: - # 1. run quotacheck only if quota is off - # 2. save the original quota_type params, restore them after testing + # We need save the original quota_type params, and restore them after testing # Suppose that quota type the same on mds and ost local quota_type=$(quota_type | grep MDT | cut -d "=" -f2) @@ -556,6 +555,9 @@ setup_quota(){ if [ "$quota_type" != "$QUOTA_TYPE" ]; then export old_QUOTA_TYPE=$quota_type quota_save_version $QUOTA_TYPE + else + qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE) + $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type" fi local quota_usrs=$QUOTA_USERS @@ -1826,9 +1828,16 @@ init_param_vars () { if [ x"$(som_check)" = x"enabled" ]; then ENABLE_QUOTA="" + echo "disable quota temporary when SOM enabled" fi - if [ "$ENABLE_QUOTA" ]; then - setup_quota $MOUNT || return 2 + if [ $QUOTA_AUTO -ne 0 ]; then + if [ "$ENABLE_QUOTA" ]; then + echo "enable quota as required" + setup_quota $MOUNT || return 2 + else + echo "disable quota as required" + $LFS quotaoff -ug $MOUNT > /dev/null 2>&1 + fi fi } -- 1.8.3.1