Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / include / lustre_quota.h
index 9dd419c..838c460 100644 (file)
@@ -47,8 +47,8 @@
 #error Unsupported operating system.
 #endif
 
-#include <lustre/lustre_idl.h>
 #include <lustre_net.h>
+#include <lustre/lustre_idl.h>
 #include <lvfs.h>
 #include <obd_support.h>
 #include <class_hash.h>
@@ -190,7 +190,6 @@ struct dquot_id {
 #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);
@@ -200,46 +199,6 @@ 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
-#endif
-
-static 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)
 
@@ -272,12 +231,16 @@ struct lustre_quota_ctxt {
                                          * 0:Off, 1:On
                                          */
                       lqc_valid:1,      /** this qctxt is valid or not */
-                      lqc_setup:1;      /**
+                      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
                                          */
+                      lqc_immutable:1;  /**
+                                         * cannot be turned on/off on-fly;
+                                         * temporary used by SOM.
+                                         */
         /** }@ */
         /**
          * original unit size of file quota and
@@ -374,7 +337,7 @@ struct lustre_qunit_size {
         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;
-        struct quota_adjust_qunit lqs_key; /** hash key */
+        unsigned long long lqs_key;    /** hash key */
         struct lustre_quota_ctxt *lqs_ctxt; /** quota ctxt */
 };
 
@@ -386,6 +349,13 @@ struct lustre_qunit_size {
 #define LQS_SET_ADJBLK(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJBLK)
 #define LQS_SET_ADJINO(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJINO)
 
+/* 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,
+ * which will make comparing easier and more efficient */
+#define LQS_KEY(is_grp, id)  ((is_grp ? 1ULL << 32: 0) + id)
+#define LQS_KEY_ID(key)      (key & 0xffffffff)
+#define LQS_KEY_GRP(key)     (key >> 32)
+
 static inline void lqs_getref(struct lustre_qunit_size *lqs)
 {
         atomic_inc(&lqs->lqs_refcount);
@@ -453,9 +423,8 @@ struct quotacheck_thread_args {
 };
 
 struct obd_trans_info;
-typedef int (*quota_acquire)(struct obd_device *obd, unsigned int uid,
-                             unsigned int gid, struct obd_trans_info *oti,
-                             int isblk);
+typedef int (*quota_acquire)(struct obd_device *obd, const unsigned int id[],
+                             struct obd_trans_info *oti, int isblk);
 
 typedef struct {
         int (*quota_init) (void);
@@ -475,8 +444,8 @@ typedef struct {
         /**
          * For quota master/slave, adjust quota limit after fs operation
          */
-        int (*quota_adjust) (struct obd_device *, unsigned int[],
-                             unsigned int[], int, int);
+        int (*quota_adjust) (struct obd_device *, const unsigned int[],
+                             const unsigned int[], int, int);
 
         /**
          * For quota slave, set import, trigger quota recovery,
@@ -503,7 +472,7 @@ typedef struct {
         /**
          * For quota slave, acquire/release quota from master if needed
          */
-        int (*quota_acquire) (struct obd_device *, unsigned int, unsigned int,
+        int (*quota_acquire) (struct obd_device *, const unsigned int [],
                               struct obd_trans_info *, int);
 
         /**
@@ -511,16 +480,16 @@ 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 *, unsigned int, unsigned int,
-                               int, int *, quota_acquire,
+        int (*quota_chkquota) (struct obd_device *, 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
          */
-        int (*quota_pending_commit) (struct obd_device *, unsigned int,
-                                     unsigned int, int, int);
+        int (*quota_pending_commit) (struct obd_device *, const unsigned int [],
+                                     int [], int);
 #endif
 
         /**
@@ -531,12 +500,12 @@ typedef struct {
         /**
          * For quota client, check whether specified uid/gid is over quota
          */
-        int (*quota_chkdq) (struct client_obd *, unsigned int, unsigned int);
+        int (*quota_chkdq) (struct client_obd *, const unsigned int []);
 
         /**
          * For quota client, set over quota flag for specifed uid/gid
          */
-        int (*quota_setdq) (struct client_obd *, unsigned int, unsigned int,
+        int (*quota_setdq) (struct client_obd *, const unsigned int [],
                             obd_flag, obd_flag);
 
         /**
@@ -653,8 +622,8 @@ static inline int lquota_ctl(quota_interface_t *interface,
 
 static inline int lquota_adjust(quota_interface_t *interface,
                                 struct obd_device *obd,
-                                unsigned int qcids[],
-                                unsigned int qpids[],
+                                const unsigned int qcids[],
+                                const unsigned int qpids[],
                                 int rc, int opc)
 {
         int ret;
@@ -666,27 +635,25 @@ static inline int lquota_adjust(quota_interface_t *interface,
 }
 
 static inline int lquota_chkdq(quota_interface_t *interface,
-                               struct client_obd *cli,
-                               unsigned int uid, unsigned int gid)
+                               struct client_obd *cli, const unsigned int qid[])
 {
         int rc;
         ENTRY;
 
         QUOTA_CHECK_OP(interface, chkdq);
-        rc = QUOTA_OP(interface, chkdq)(cli, uid, gid);
+        rc = QUOTA_OP(interface, chkdq)(cli, qid);
         RETURN(rc);
 }
 
 static inline int lquota_setdq(quota_interface_t *interface,
-                               struct client_obd *cli,
-                               unsigned int uid, unsigned int gid,
+                               struct client_obd *cli, const unsigned int qid[],
                                obd_flag valid, obd_flag flags)
 {
         int rc;
         ENTRY;
 
         QUOTA_CHECK_OP(interface, setdq);
-        rc = QUOTA_OP(interface, setdq)(cli, uid, gid, valid, flags);
+        rc = QUOTA_OP(interface, setdq)(cli, qid, valid, flags);
         RETURN(rc);
 }
 
@@ -752,31 +719,31 @@ static inline int lquota_getflag(quota_interface_t *interface,
 #ifdef __KERNEL__
 static inline int lquota_chkquota(quota_interface_t *interface,
                                   struct obd_device *obd,
-                                  unsigned int uid, unsigned int gid, int count,
-                                  int *flag, struct obd_trans_info *oti,
-                                  int isblk, struct inode *inode, int frags)
+                                  const unsigned int id[], int pending[],
+                                  int count, struct obd_trans_info *oti,
+                                  int isblk, void *data, int frags)
 {
         int rc;
         ENTRY;
 
         QUOTA_CHECK_OP(interface, chkquota);
         QUOTA_CHECK_OP(interface, acquire);
-        rc = QUOTA_OP(interface, chkquota)(obd, uid, gid, count, flag,
+        rc = QUOTA_OP(interface, chkquota)(obd, id, pending, count,
                                            QUOTA_OP(interface, acquire), oti,
-                                           isblk, inode, frags);
+                                           isblk, (struct inode *)data, frags);
         RETURN(rc);
 }
 
 static inline int lquota_pending_commit(quota_interface_t *interface,
                                         struct obd_device *obd,
-                                        unsigned int uid, unsigned int gid,
-                                        int pending, int isblk)
+                                        const unsigned int id[],
+                                        int pending[], int isblk)
 {
         int rc;
         ENTRY;
 
         QUOTA_CHECK_OP(interface, pending_commit);
-        rc = QUOTA_OP(interface, pending_commit)(obd, uid, gid, pending, isblk);
+        rc = QUOTA_OP(interface, pending_commit)(obd, id, pending, isblk);
         RETURN(rc);
 }
 #endif