X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Finclude%2Flustre_quota.h;h=ee0ca22b719445791c57051a5df5f1983cdb71a0;hp=03db1da290a475822fa112c8dff04d3baf020c08;hb=d750891e478804bc495ffa075d771d1816369958;hpb=cd40f5454d9fefcbdf0a2eb50dee78be5d19e72c diff --git a/lustre/include/lustre_quota.h b/lustre/include/lustre_quota.h index 03db1da..ee0ca22 100644 --- a/lustre/include/lustre_quota.h +++ b/lustre/include/lustre_quota.h @@ -26,7 +26,7 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. */ /* @@ -37,6 +37,11 @@ #ifndef _LUSTRE_QUOTA_H #define _LUSTRE_QUOTA_H +/** \defgroup quota quota + * + * @{ + */ + #if defined(__linux__) #include #elif defined(__APPLE__) @@ -157,10 +162,6 @@ struct lustre_quota_info { lustre_quota_version_t qi_version; }; -#define DQ_STATUS_AVAIL 0x0 /* Available dquot */ -#define DQ_STATUS_SET 0x01 /* Sombody is setting dquot */ -#define DQ_STATUS_RECOVERY 0x02 /* dquot is in recovery */ - struct lustre_mem_dqblk { __u64 dqb_bhardlimit; /**< absolute limit on disk blks alloc */ __u64 dqb_bsoftlimit; /**< preferred limit on disk blks */ @@ -178,7 +179,7 @@ struct lustre_dquot { /** Protect the data in lustre_dquot */ cfs_semaphore_t dq_sem; /** Use count */ - int dq_refcnt; + cfs_atomic_t dq_refcnt; /** Pointer of quota info it belongs to */ struct lustre_quota_info *dq_info; /** Offset of dquot on disk */ @@ -187,8 +188,6 @@ struct lustre_dquot { unsigned int dq_id; /** Type fo quota (USRQUOTA, GRPQUOUTA) */ int dq_type; - /** See DQ_STATUS_ */ - unsigned short dq_status; /** See DQ_ in quota.h */ unsigned long dq_flags; /** Diskquota usage */ @@ -227,17 +226,6 @@ int lustre_quota_convert(struct lustre_quota_info *lqi, int type); typedef int (*dqacq_handler_t) (struct obd_device * obd, struct qunit_data * qd, int opc); -/* -#ifdef HAVE_VFS_DQ_OFF -#define LL_DQUOT_OFF(sb, remount) vfs_dq_off(sb, remount) -#else -#define LL_DQUOT_OFF(sb, remount) DQUOT_OFF(sb) -#endif -*/ - -#define LL_DQUOT_OFF(sb) DQUOT_OFF(sb) - - /* user quota is turned on on filter */ #define LQC_USRQUOTA_FLAG (1 << 0) /* group quota is turned on on filter */ @@ -376,13 +364,20 @@ struct lustre_qunit_size { struct lustre_quota_ctxt *lqs_ctxt; /** quota ctxt */ }; -#define LQS_IS_GRP(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_GRP) -#define LQS_IS_ADJBLK(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_ADJBLK) -#define LQS_IS_ADJINO(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_ADJINO) +#define LQS_IS_GRP(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_GRP) +#define LQS_IS_ADJBLK(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_ADJBLK) +#define LQS_IS_ADJINO(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_ADJINO) +#define LQS_IS_RECOVERY(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_RECOVERY) +#define LQS_IS_SETQUOTA(lqs) ((lqs)->lqs_flags & LQUOTA_FLAGS_SETQUOTA) + +#define LQS_SET_GRP(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_GRP) +#define LQS_SET_ADJBLK(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJBLK) +#define LQS_SET_ADJINO(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJINO) +#define LQS_SET_RECOVERY(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_RECOVERY) +#define LQS_SET_SETQUOTA(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_SETQUOTA) -#define LQS_SET_GRP(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_GRP) -#define LQS_SET_ADJBLK(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJBLK) -#define LQS_SET_ADJINO(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJINO) +#define LQS_CLEAR_RECOVERY(lqs) ((lqs)->lqs_flags &= ~LQUOTA_FLAGS_RECOVERY) +#define LQS_CLEAR_SETQUOTA(lqs) ((lqs)->lqs_flags &= ~LQUOTA_FLAGS_SETQUOTA) /* In the hash for lustre_qunit_size, the key is decided by * grp_or_usr and uid/gid, in here, I combine these two values, @@ -391,39 +386,25 @@ struct lustre_qunit_size { #define LQS_KEY_ID(key) (key & 0xffffffff) #define LQS_KEY_GRP(key) (key >> 32) -static inline void __lqs_getref(struct lustre_qunit_size *lqs) +static inline void lqs_getref(struct lustre_qunit_size *lqs) { int count = cfs_atomic_inc_return(&lqs->lqs_refcount); - if (count == 2) /* quota_create_lqs */ - cfs_atomic_inc(&lqs->lqs_ctxt->lqc_lqs); CDEBUG(D_INFO, "lqs=%p refcount %d\n", lqs, count); } -static inline void lqs_getref(struct lustre_qunit_size *lqs) +static inline void lqs_putref(struct lustre_qunit_size *lqs) { - __lqs_getref(lqs); -} + int count = cfs_atomic_read(&lqs->lqs_refcount); -static inline void __lqs_putref(struct lustre_qunit_size *lqs) -{ - LASSERT(cfs_atomic_read(&lqs->lqs_refcount) > 0); + LASSERT(count > 0); + CDEBUG(D_INFO, "lqs=%p refcount %d\n", lqs, count - 1); - if (cfs_atomic_dec_return(&lqs->lqs_refcount) == 1) + if (cfs_atomic_dec_and_test(&lqs->lqs_refcount)) { if (cfs_atomic_dec_and_test(&lqs->lqs_ctxt->lqc_lqs)) cfs_waitq_signal(&lqs->lqs_ctxt->lqc_lqs_waitq); - CDEBUG(D_INFO, "lqs=%p refcount %d\n", - lqs, cfs_atomic_read(&lqs->lqs_refcount)); -} - -static inline void lqs_putref(struct lustre_qunit_size *lqs) -{ - __lqs_putref(lqs); -} - -static inline void lqs_initref(struct lustre_qunit_size *lqs) -{ - cfs_atomic_set(&lqs->lqs_refcount, 0); + OBD_FREE_PTR(lqs); + } } #else @@ -441,7 +422,7 @@ struct lustre_quota_ctxt { #else -#define LL_DQUOT_OFF(sb, remount) do {} while(0) +#define LL_DQUOT_OFF(sb) do {} while(0) struct lustre_quota_info { }; @@ -554,7 +535,8 @@ typedef struct { */ int (*quota_adjust_qunit) (struct obd_export *exp, struct quota_adjust_qunit *oqaq, - struct lustre_quota_ctxt *qctxt); + struct lustre_quota_ctxt *qctxt, + struct ptlrpc_request_set *rqset); } quota_interface_t; @@ -815,4 +797,6 @@ extern quota_interface_t lmv_quota_interface; "admin_quotafile_v2.grp" /** group admin quotafile */\ } +/** @} quota */ + #endif /* _LUSTRE_QUOTA_H */