lustre_quota.h
来自「lustre 1.6.5 source code」· C头文件 代码 · 共 595 行 · 第 1/2 页
H
595 行
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: */#ifndef _LUSTRE_QUOTA_H#define _LUSTRE_QUOTA_H#if defined(__linux__)#include <linux/lustre_quota.h>#elif defined(__APPLE__)#include <darwin/lustre_quota.h>#elif defined(__WINNT__)#include <winnt/lustre_quota.h>#else#error Unsupported operating system.#endif#include <lustre/lustre_idl.h>#include <lustre_net.h>#include <lvfs.h>#include <obd_support.h>struct obd_device;struct client_obd;#ifndef NR_DQHASH#define NR_DQHASH 45#endif#ifdef HAVE_QUOTA_SUPPORT#ifdef __KERNEL__/* 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;};#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 */ __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 */ struct list_head dq_hash; /* Protect the data in lustre_dquot */ struct semaphore dq_sem; /* Use count */ int dq_refcnt; /* Pointer of quota info it belongs to */ struct lustre_quota_info *dq_info; loff_t dq_off; /* Offset of dquot on disk */ unsigned int dq_id; /* ID this applies to (uid, gid) */ int dq_type; /* Type fo quota (USRQUOTA, GRPQUOUTA) */ unsigned short dq_status; /* See DQ_STATUS_ */ unsigned long dq_flags; /* See DQ_ in quota.h */ struct lustre_mem_dqblk dq_dqb; /* Diskquota usage */};struct dquot_id { struct list_head di_link; __u32 di_id;};#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 */#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)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, struct list_head *list);int lustre_quota_convert(struct lustre_quota_info *lqi, int type);#else#ifndef DQ_FAKE_B#define DQ_FAKE_B 6#endifstatic inline int lustre_check_quota_file(struct lustre_quota_info *lqi, int type){ return 0;}static inline int lustre_read_quota_info(struct lustre_quota_info *lqi, int type){ return 0;}static inline int lustre_write_quota_info(struct lustre_quota_info *lqi, int type){ return 0;}static inline int lustre_read_dquot(struct lustre_dquot *dquot){ return 0;}static inline int lustre_commit_dquot(struct lustre_dquot *dquot){ return 0;}static inline int lustre_init_quota_info(struct lustre_quota_info *lqi, int type){ return 0;}static inline int lustre_quota_convert(struct lustre_quota_info *lqi, int type){ return 0;}#endif /* KERNEL_VERSION(2,5,0) */#define LL_DQUOT_OFF(sb) DQUOT_OFF(sb)typedef int (*dqacq_handler_t) (struct obd_device * obd, struct qunit_data * qd, int opc);struct lustre_quota_ctxt { struct super_block *lqc_sb; /* superblock this applies to */ struct obd_import *lqc_import; /* import used to send dqacq/dqrel RPC */ dqacq_handler_t lqc_handler; /* dqacq/dqrel RPC handler, only for quota master */ unsigned long lqc_recovery:1, /* Doing recovery */ lqc_atype:2, /* Turn on user/group quota at setup automatically, * 0: none, 1: user quota, 2: group quota, 3: both */ lqc_status:1, /* Quota status. 0:Off, 1:On */ lqc_switch_qs:1; /* the function of change qunit size * 0:Off, 1:On */ unsigned long lqc_iunit_sz; /* original unit size of file quota and * upper limitation for adjust file * qunit */ unsigned long lqc_itune_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_bunit_sz; /* original unit size of block quota and * upper limitation for adjust block * qunit */ unsigned long lqc_btune_sz; /* See comment of lqc_itune_sz */ struct lustre_class_hash_body *lqc_lqs_hash_body; /* all lustre_qunit_size structure in * it */ /* the values below are relative to how master change its qunit sizes */ unsigned long lqc_cqs_boundary_factor; /* this affects the boundary of * shrinking and enlarging qunit * size. default=4 */ unsigned long lqc_cqs_least_bunit; /* the least value of block qunit */ unsigned long lqc_cqs_least_iunit; /* the least value of inode qunit */ unsigned long lqc_cqs_qs_factor; /* when enlarging, qunit size will * mutilple it; when shrinking, * qunit size will divide it */ int lqc_switch_seconds; /* avoid ping-pong effect of * adjusting qunit size. How many * seconds must be waited between * enlarging and shinking qunit */ spinlock_t lqc_lock; /* guard lqc_imp_valid now */};#define LQC_HASH_BODY(qctxt) (qctxt->lqc_lqs_hash_body)struct lustre_qunit_size { struct hlist_node lqs_hash; /* the hash entry */ unsigned int lqs_id; /* id of user/group */ unsigned long lqs_flags; /* is user/group; FULLBUF or LESSBUF */ unsigned long lqs_iunit_sz; /* Unit size of file quota currently */ unsigned long lqs_itune_sz; /* Trigger dqacq when available file quota * less than this value, trigger dqrel * when more than this value + 1 iunit */ unsigned long lqs_bunit_sz; /* Unit size of block quota currently */ unsigned long lqs_btune_sz; /* See comment of lqs itune sz */ unsigned long lqs_bwrite_pending; /* the blocks reached ost and don't * finish */ unsigned long lqs_iwrite_pending; /* the inodes reached mds and don't * finish */ long long lqs_ino_rec; /* when inodes are allocated/released, * this value will record it */ long long lqs_blk_rec; /* when blocks are allocated/released, * this value will record it */ atomic_t lqs_refcount; cfs_time_t lqs_last_bshrink; /* time of last block shrink */ cfs_time_t lqs_last_ishrink; /* time of last inode shrink */ spinlock_t lqs_lock;};#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_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)static inline void lqs_getref(struct lustre_qunit_size *lqs){ atomic_inc(&lqs->lqs_refcount);}static inline void lqs_putref(struct lustre_qunit_size *lqs){ if (atomic_dec_and_test(&lqs->lqs_refcount)) { spin_lock(&lqs->lqs_lock); hlist_del_init(&lqs->lqs_hash); spin_unlock(&lqs->lqs_lock); OBD_FREE_PTR(lqs); }}static inline void lqs_initref(struct lustre_qunit_size *lqs){ atomic_set(&lqs->lqs_refcount, 0);}#elsestruct lustre_quota_info {};struct lustre_quota_ctxt {};#endif /* !__KERNEL__ */#else#define LL_DQUOT_OFF(sb) do {} while(0)struct lustre_quota_info {};struct lustre_quota_ctxt {};#endif /* !HAVE_QUOTA_SUPPORT *//* If the (quota limit < qunit * slave count), the slave which can't * acquire qunit should set it's local limit as MIN_QLIMIT */#define MIN_QLIMIT 1struct quotacheck_thread_args { struct obd_export *qta_exp; /* obd export */ struct obd_quotactl qta_oqctl; /* obd_quotactl args */ struct super_block *qta_sb; /* obd super block */ atomic_t *qta_sem; /* obt_quotachecking */};typedef int (*quota_acquire)(struct obd_device *obd, unsigned int uid, unsigned int gid);typedef struct { int (*quota_init) (void); int (*quota_exit) (void); int (*quota_setup) (struct obd_device *); int (*quota_cleanup) (struct obd_device *); /* For quota master, close admin quota files */ int (*quota_fs_cleanup) (struct obd_device *); int (*quota_ctl) (struct obd_export *, struct obd_quotactl *); int (*quota_check) (struct obd_export *, struct obd_quotactl *); int (*quota_recovery) (struct obd_device *); /* For quota master/slave, adjust quota limit after fs operation */ int (*quota_adjust) (struct obd_device *, unsigned int[], unsigned int[], int, int); /* For quota slave, set import, trigger quota recovery */ int (*quota_setinfo) (struct obd_export *, struct obd_device *);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?