-#ifdef __KERNEL__
-
-#ifdef LPROCFS
-enum {
- LQUOTA_FIRST_STAT = 0,
- /** @{ */
- /**
- * these four are for measuring quota requests, for both of
- * quota master and quota slaves
- */
- LQUOTA_SYNC_ACQ = LQUOTA_FIRST_STAT,
- LQUOTA_SYNC_REL,
- LQUOTA_ASYNC_ACQ,
- LQUOTA_ASYNC_REL,
- /** }@ */
- /** @{ */
- /**
- * these four measure how much time I/O threads spend on dealing
- * with quota before and after writing data or creating files,
- * only for quota slaves(lquota_chkquota and lquota_pending_commit)
- */
- LQUOTA_WAIT_FOR_CHK_BLK,
- LQUOTA_WAIT_FOR_CHK_INO,
- LQUOTA_WAIT_FOR_COMMIT_BLK,
- LQUOTA_WAIT_FOR_COMMIT_INO,
- /** }@ */
- /** @{ */
- /**
- * these two are for measuring time waiting return of quota reqs
- * (qctxt_wait_pending_dqacq), only for quota salves
- */
- LQUOTA_WAIT_PENDING_BLK_QUOTA,
- LQUOTA_WAIT_PENDING_INO_QUOTA,
- /** }@ */
- /** @{ */
- /**
- * these two are for those when they are calling
- * qctxt_wait_pending_dqacq, the quota req has returned already,
- * only for quota salves
- */
- LQUOTA_NOWAIT_PENDING_BLK_QUOTA,
- LQUOTA_NOWAIT_PENDING_INO_QUOTA,
- /** }@ */
- /** @{ */
- /**
- * these are for quota ctl
- */
- LQUOTA_QUOTA_CTL,
- /** }@ */
- /** @{ */
- /**
- * these are for adjust quota qunit, for both of
- * quota master and quota slaves
- */
- LQUOTA_ADJUST_QUNIT,
- LQUOTA_LAST_STAT
- /** }@ */
-};
-#endif /* LPROCFS */
-
-/* structures to access admin quotafile */
-struct lustre_mem_dqinfo {
- unsigned int dqi_bgrace;
- unsigned int dqi_igrace;
- unsigned long dqi_flags;
- unsigned int dqi_blocks;
- unsigned int dqi_free_blk;
- unsigned int dqi_free_entry;
-};
-
-struct lustre_quota_info {
- struct file *qi_files[MAXQUOTAS];
- struct lustre_mem_dqinfo qi_info[MAXQUOTAS];
- lustre_quota_version_t qi_version;
-};
-
-struct lustre_mem_dqblk {
- __u64 dqb_bhardlimit; /**< absolute limit on disk blks alloc */
- __u64 dqb_bsoftlimit; /**< preferred limit on disk blks */
- __u64 dqb_curspace; /**< current used space */
- __u64 dqb_ihardlimit; /**< absolute limit on allocated inodes */
- __u64 dqb_isoftlimit; /**< preferred inode limit */
- __u64 dqb_curinodes; /**< current # allocated inodes */
- time_t dqb_btime; /**< time limit for excessive disk use */
- time_t dqb_itime; /**< time limit for excessive inode use */
-};
-
-struct lustre_dquot {
- /** Hash list in memory, protect by dquot_hash_lock */
- cfs_list_t dq_hash;
- /** Protect the data in lustre_dquot */
- cfs_semaphore_t dq_sem;
- /** Use count */
- cfs_atomic_t dq_refcnt;
- /** Pointer of quota info it belongs to */
- struct lustre_quota_info *dq_info;
- /** Offset of dquot on disk */
- loff_t dq_off;
- /** ID this applies to (uid, gid) */
- unsigned int dq_id;
- /** Type fo quota (USRQUOTA, GRPQUOUTA) */
- int dq_type;
- /** See DQ_ in quota.h */
- unsigned long dq_flags;
- /** Diskquota usage */
- struct lustre_mem_dqblk dq_dqb;
-};
-
-struct dquot_id {
- cfs_list_t di_link;
- __u32 di_id;
- __u32 di_flag;
-};
-/* set inode quota limitation on a quota uid/gid */
-#define QI_SET (1 << 30)
-/* set block quota limitation on a quota uid/gid */
-#define QB_SET (1 << 31)
-
-#define QFILE_CHK 1
-#define QFILE_RD_INFO 2
-#define QFILE_WR_INFO 3
-#define QFILE_INIT_INFO 4
-#define QFILE_RD_DQUOT 5
-#define QFILE_WR_DQUOT 6
-#define QFILE_CONVERT 7
-
-/* admin quotafile operations */
-int lustre_check_quota_file(struct lustre_quota_info *lqi, int type);
-int lustre_read_quota_info(struct lustre_quota_info *lqi, int type);
-int lustre_write_quota_info(struct lustre_quota_info *lqi, int type);
-int lustre_read_dquot(struct lustre_dquot *dquot);
-int lustre_commit_dquot(struct lustre_dquot *dquot);
-int lustre_init_quota_info(struct lustre_quota_info *lqi, int type);
-int lustre_get_qids(struct file *file, struct inode *inode, int type,
- cfs_list_t *list);
-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);
-
-/* user quota is turned on on filter */
-#define LQC_USRQUOTA_FLAG (1 << 0)
-/* group quota is turned on on filter */
-#define LQC_GRPQUOTA_FLAG (1 << 1)
-
-#define UGQUOTA2LQC(id) ((Q_TYPEMATCH(id, USRQUOTA) ? LQC_USRQUOTA_FLAG : 0) | \
- (Q_TYPEMATCH(id, GRPQUOTA) ? LQC_GRPQUOTA_FLAG : 0))
-
-struct lustre_quota_ctxt {
- /** superblock this applies to */
- struct super_block *lqc_sb;
- /** obd_device_target for obt_rwsem */
- struct obd_device_target *lqc_obt;
- /** import used to send dqacq/dqrel RPC */
- struct obd_import *lqc_import;
- /** dqacq/dqrel RPC handler, only for quota master */
- dqacq_handler_t lqc_handler;
- /** quota flags */
- unsigned long lqc_flags;
- /** @{ */
- unsigned long lqc_recovery:1, /** Doing recovery */
- lqc_switch_qs:1, /**
- * the function of change qunit size
- * 0:Off, 1:On
- */
- lqc_valid:1, /** this qctxt is valid or not */
- lqc_setup:1; /**
- * tell whether of not quota_type has
- * been processed, so that the master
- * knows when it can start processing
- * incoming acq/rel quota requests
- */
- /** }@ */
- /**
- * original unit size of file quota and
- * upper limitation for adjust file qunit
- */
- unsigned long lqc_iunit_sz;
- /**
- * Trigger dqacq when available file
- * quota less than this value, trigger
- * dqrel when available file quota
- * more than this value + 1 iunit
- */
- unsigned long lqc_itune_sz;
- /**
- * original unit size of block quota and
- * upper limitation for adjust block qunit
- */
- unsigned long lqc_bunit_sz;
- /** See comment of lqc_itune_sz */
- unsigned long lqc_btune_sz;
- /** all lustre_qunit_size structures */
- cfs_hash_t *lqc_lqs_hash;
-
- /** @{ */
- /**
- * the values below are relative to how master change its qunit sizes
- */
- /**
- * this affects the boundary of
- * shrinking and enlarging qunit size. default=4
- */
- unsigned long lqc_cqs_boundary_factor;
- /** the least value of block qunit */
- unsigned long lqc_cqs_least_bunit;
- /** the least value of inode qunit */
- unsigned long lqc_cqs_least_iunit;
- /**
- * when enlarging, qunit size will
- * mutilple it; when shrinking,
- * qunit size will divide it
- */
- unsigned long lqc_cqs_qs_factor;
- /**
- * avoid ping-pong effect of
- * adjusting qunit size. How many
- * seconds must be waited between
- * enlarging and shinking qunit
- */
- /** }@ */
- int lqc_switch_seconds;
- /**
- * when blk qunit reaches this value,
- * later write reqs from client should be sync b=16642
- */
- int lqc_sync_blk;
- /** guard lqc_imp_valid now */
- cfs_spinlock_t lqc_lock;
- /**
- * when mds isn't connected, threads
- * on osts who send the quota reqs
- * with wait==1 will be put here b=14840
- */
- cfs_waitq_t lqc_wait_for_qmaster;
- struct proc_dir_entry *lqc_proc_dir;
- /** lquota statistics */
- struct lprocfs_stats *lqc_stats;
- /** the number of used hashed lqs */
- cfs_atomic_t lqc_lqs;
- /** no lqs are in use */
- cfs_waitq_t lqc_lqs_waitq;
-};