X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Finclude%2Flustre_quota.h;h=558263780ba12f8cae3b74c4e838a563191f1616;hb=95dbd166988cf0a2912c51305572c78a9aa2d324;hp=5c154adcd790b568903e840f83157dfdb014b957;hpb=7661294557774975dbd7aa90014f4ab1610db7df;p=fs%2Flustre-release.git diff --git a/lustre/include/lustre_quota.h b/lustre/include/lustre_quota.h index 5c154ad..5582637 100644 --- a/lustre/include/lustre_quota.h +++ b/lustre/include/lustre_quota.h @@ -51,7 +51,6 @@ #include #include #include -#include struct obd_device; struct client_obd; @@ -60,8 +59,28 @@ struct client_obd; #define NR_DQHASH 45 #endif +#ifndef QUOTABLOCK_BITS +#define QUOTABLOCK_BITS 10 +#endif + +#ifndef QUOTABLOCK_SIZE +#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS) +#endif + +#ifndef toqb +#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS) +#endif + #ifdef HAVE_QUOTA_SUPPORT +#ifndef MAX_IQ_TIME +#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */ +#endif + +#ifndef MAX_DQ_TIME +#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */ +#endif + #ifdef __KERNEL__ #ifdef LPROCFS @@ -205,11 +224,20 @@ int lustre_get_qids(struct file *file, struct inode *inode, int type, struct list_head *list); int lustre_quota_convert(struct lustre_quota_info *lqi, int type); -#define LL_DQUOT_OFF(sb) DQUOT_OFF(sb) - 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 */ @@ -267,7 +295,7 @@ struct lustre_quota_ctxt { /** See comment of lqc_itune_sz */ unsigned long lqc_btune_sz; /** all lustre_qunit_size structures */ - struct lustre_hash *lqc_lqs_hash; + cfs_hash_t *lqc_lqs_hash; /** @{ */ /** @@ -312,6 +340,10 @@ struct lustre_quota_ctxt { struct proc_dir_entry *lqc_proc_dir; /** lquota statistics */ struct lprocfs_stats *lqc_stats; + /** the number of used hashed lqs */ + atomic_t lqc_lqs; + /** no lqs are in use */ + cfs_waitq_t lqc_lqs_waitq; }; #define QUOTA_MASTER_READY(qctxt) (qctxt)->lqc_setup = 1 @@ -363,28 +395,34 @@ 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) +{ + int count = atomic_inc_return(&lqs->lqs_refcount); + + if (count == 2) /* quota_create_lqs */ + 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) { - atomic_inc(&lqs->lqs_refcount); - CDEBUG(D_QUOTA, "lqs=%p refcount %d\n", - lqs, atomic_read(&lqs->lqs_refcount)); + __lqs_getref(lqs); } -static inline void lqs_putref(struct lustre_qunit_size *lqs) +static inline void __lqs_putref(struct lustre_qunit_size *lqs) { LASSERT(atomic_read(&lqs->lqs_refcount) > 0); - /* killing last ref, let's let hash table kill it */ - if (atomic_read(&lqs->lqs_refcount) == 1) { - lustre_hash_del(lqs->lqs_ctxt->lqc_lqs_hash, - &lqs->lqs_key, &lqs->lqs_hash); - OBD_FREE_PTR(lqs); - } else { - atomic_dec(&lqs->lqs_refcount); - CDEBUG(D_QUOTA, "lqs=%p refcount %d\n", - lqs, atomic_read(&lqs->lqs_refcount)); - - } + if (atomic_dec_return(&lqs->lqs_refcount) == 1) + if (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, 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) @@ -407,7 +445,7 @@ struct lustre_quota_ctxt { #else -#define LL_DQUOT_OFF(sb) do {} while(0) +#define LL_DQUOT_OFF(sb, remount) do {} while(0) struct lustre_quota_info { }; @@ -426,7 +464,7 @@ struct quotacheck_thread_args { struct obd_device *qta_obd; /** obd device */ struct obd_quotactl qta_oqctl; /** obd_quotactl args */ struct super_block *qta_sb; /** obd super block */ - atomic_t *qta_sem; /** obt_quotachecking */ + struct semaphore *qta_sem; /** obt_quotachecking */ }; struct obd_trans_info; @@ -487,10 +525,10 @@ typedef struct { * can finish a block_write or inode_create rpc. It updates the pending * record of block and inode, acquires quota if necessary */ - int (*quota_chkquota) (struct obd_device *, const unsigned int [], - int [], int, quota_acquire, - struct obd_trans_info *, int, struct inode *, - int); + int (*quota_chkquota) (struct obd_device *, struct obd_export *, + const unsigned int [], int [], + int, quota_acquire, struct obd_trans_info *, + int, struct inode *, int); /** * For quota client, the actions after the pending write is committed @@ -726,6 +764,7 @@ static inline int lquota_getflag(quota_interface_t *interface, #ifdef __KERNEL__ static inline int lquota_chkquota(quota_interface_t *interface, struct obd_device *obd, + struct obd_export *exp, const unsigned int id[], int pending[], int count, struct obd_trans_info *oti, int isblk, void *data, int frags) @@ -735,7 +774,7 @@ static inline int lquota_chkquota(quota_interface_t *interface, QUOTA_CHECK_OP(interface, chkquota); QUOTA_CHECK_OP(interface, acquire); - rc = QUOTA_OP(interface, chkquota)(obd, id, pending, count, + rc = QUOTA_OP(interface, chkquota)(obd, exp, id, pending, count, QUOTA_OP(interface, acquire), oti, isblk, (struct inode *)data, frags); RETURN(rc);