X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosc%2Fosc_quota.c;h=4320ae40777cfc02b691ff562bb4edee5d223916;hb=e703700e9c095d94996d7bfd957f57285d659fbf;hp=1c7748c8111c1fed2a61818226c27ddc79b356a2;hpb=036d987c6d716d2e3d8f5a12800b44f3cd01bb9c;p=fs%2Flustre-release.git diff --git a/lustre/osc/osc_quota.c b/lustre/osc/osc_quota.c index 1c7748c..4320ae4 100644 --- a/lustre/osc/osc_quota.c +++ b/lustre/osc/osc_quota.c @@ -23,7 +23,7 @@ /* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * - * Copyright (c) 2012, 2015, Intel Corporation. + * Copyright (c) 2012, 2017, Intel Corporation. * * Code originally extracted from quota directory */ @@ -61,11 +61,11 @@ int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[]) * quota space on this OST */ CDEBUG(D_QUOTA, "chkdq found noquota for %s %d\n", type == USRQUOTA ? "user" : "grout", qid[type]); - RETURN(NO_QUOTA); + RETURN(-EDQUOT); } } - RETURN(QUOTA_OK); + RETURN(0); } static inline u32 md_quota_flag(int qtype) @@ -96,7 +96,7 @@ static inline u32 fl_quota_flag(int qtype) } } -int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], +int osc_quota_setdq(struct client_obd *cli, __u64 xid, const unsigned int qid[], u64 valid, u32 flags) { int type; @@ -107,6 +107,17 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], if ((valid & (OBD_MD_FLALLQUOTA)) == 0) RETURN(0); + mutex_lock(&cli->cl_quota_mutex); + /* still mark the quots is running out for the old request, because it + * could be processed after the new request at OST, the side effect is + * the following request will be processed synchronously, but it will + * not break the quota enforcement. */ + if (cli->cl_quota_last_xid > xid && !(flags & OBD_FL_NO_QUOTA_ALL)) + GOTO(out_unlock, rc); + + if (cli->cl_quota_last_xid < xid) + cli->cl_quota_last_xid = xid; + for (type = 0; type < LL_MAXQUOTAS; type++) { struct osc_quota_info *oqi; @@ -153,6 +164,8 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], } } +out_unlock: + mutex_unlock(&cli->cl_quota_mutex); RETURN(rc); } @@ -232,6 +245,8 @@ int osc_quota_setup(struct obd_device *obd) int i, type; ENTRY; + mutex_init(&cli->cl_quota_mutex); + for (type = 0; type < LL_MAXQUOTAS; type++) { cli->cl_quota_hash[type] = cfs_hash_create("QUOTA_HASH", HASH_QUOTA_CUR_BITS,