Whamcloud - gitweb
LU-1842 quota: setup/shutdown qmt device
[fs/lustre-release.git] / lustre / include / lquota.h
index e6bf161..689bfc1 100644 (file)
@@ -32,6 +32,9 @@
 #ifndef _LUSTRE_LQUOTA_H
 #define _LUSTRE_LQUOTA_H
 
+struct lquota_id_info;
+struct lquota_trans;
+
 /* Gather all quota record type in an union that can be used to read any records
  * from disk. All fields of these records must be 64-bit aligned, otherwise the
  * OSD layer may swab them incorrectly. */
@@ -56,48 +59,47 @@ extern struct dt_index_features dt_quota_bgrp_features;
 #define QUOTA_DATAPOOL_NAME   "ost="
 
 /*
- * Quota information attached to a transaction
+ * Quota Master Target support
  */
 
-struct lquota_entry;
+/* Request handlers for quota master operations.
+ * This is used by the MDT to pass quota/lock requests to the quota master
+ * target. This won't be needed any more once the QMT is a real target and
+ * does not rely any more on the MDT service threads and namespace. */
+struct qmt_handlers {
+       /* Handle quotactl request from client. */
+       int (*qmth_quotactl)(const struct lu_env *, struct lu_device *,
+                            struct obd_quotactl *);
 
-struct lquota_id_info {
-       /* quota identifier */
-       union lquota_id          lqi_id;
+       /* Handle dqacq/dqrel request from slave. */
+       int (*qmth_dqacq)(const struct lu_env *, struct lu_device *,
+                         struct ptlrpc_request *);
 
-       /* USRQUOTA or GRPQUOTA for now, could be expanded for
-        * directory quota or other types later.  */
-       int                      lqi_type;
+       /* LDLM intent policy associated with quota locks */
+       int (*qmth_intent_policy)(const struct lu_env *, struct lu_device *,
+                                 struct ptlrpc_request *, struct ldlm_lock **,
+                                 int);
 
-       /* inodes or kbytes to be consumed or released, it could
-        * be negative when releasing space.  */
-       long long                lqi_space;
+       /* Initialize LVB of ldlm resource associated with quota objects */
+       int (*qmth_lvbo_init)(struct lu_device *, struct ldlm_resource *);
 
-       /* quota slave entry structure associated with this ID */
-       struct lquota_entry     *lqi_qentry;
+       /* Update LVB of ldlm resource associated with quota objects */
+       int (*qmth_lvbo_update)(struct lu_device *, struct ldlm_resource *,
+                               struct ptlrpc_request *, int);
 
-       /* whether we are reporting blocks or inodes */
-       bool                     lqi_is_blk;
-};
+       /* Return size of LVB to be packed in ldlm message */
+       int (*qmth_lvbo_size)(struct lu_device *, struct ldlm_lock *);
 
-/* Since we enforce only inode quota in meta pool (MDTs), and block quota in
- * data pool (OSTs), there are at most 4 quota ids being enforced in a single
- * transaction, which is chown transaction:
- * original uid and gid, new uid and gid.
- *
- * This value might need to be revised when directory quota is added.  */
-#define QUOTA_MAX_TRANSIDS    4
+       /* Fill request buffer with lvb */
+       int (*qmth_lvbo_fill)(struct lu_device *, struct ldlm_lock *, void *,
+                             int);
 
-/* all qids involved in a single transaction */
-struct lquota_trans {
-        unsigned short         lqt_id_cnt;
-        struct lquota_id_info  lqt_ids[QUOTA_MAX_TRANSIDS];
+       /* Free lvb associated with ldlm resource */
+       int (*qmth_lvbo_free)(struct lu_device *, struct ldlm_resource *);
 };
 
-/* flags for quota local enforcement */
-#define QUOTA_FL_OVER_USRQUOTA  0x01
-#define QUOTA_FL_OVER_GRPQUOTA  0x02
-#define QUOTA_FL_SYNC           0x04
+/* actual handlers are defined in lustre/quota/qmt_handler.c */
+extern struct qmt_handlers qmt_hdls;
 
 /*
  * Quota enforcement support on slaves
@@ -126,11 +128,6 @@ struct qsd_instance *qsd_init(const struct lu_env *, char *, struct dt_device *,
 
 void qsd_fini(const struct lu_env *, struct qsd_instance *);
 
-/* helper function used by MDT & OFD to retrieve quota accounting information
- * on slave */
-int lquotactl_slv(const struct lu_env *, struct dt_device *,
-                 struct obd_quotactl *);
-
 /* XXX: dummy qsd_op_begin() & qsd_op_end(), will be replaced with the real
  *      one once all the enforcement code landed. */
 static inline int qsd_op_begin(const struct lu_env *env,
@@ -147,4 +144,57 @@ static inline void qsd_op_end(const struct lu_env *env,
                              struct lquota_trans *trans)
 {
 }
+
+/*
+ * Quota information attached to a transaction
+ */
+
+struct lquota_entry;
+
+struct lquota_id_info {
+       /* quota identifier */
+       union lquota_id          lqi_id;
+
+       /* USRQUOTA or GRPQUOTA for now, could be expanded for
+        * directory quota or other types later.  */
+       int                      lqi_type;
+
+       /* inodes or kbytes to be consumed or released, it could
+        * be negative when releasing space.  */
+       long long                lqi_space;
+
+       /* quota slave entry structure associated with this ID */
+       struct lquota_entry     *lqi_qentry;
+
+       /* whether we are reporting blocks or inodes */
+       bool                     lqi_is_blk;
+};
+
+/* Since we enforce only inode quota in meta pool (MDTs), and block quota in
+ * data pool (OSTs), there are at most 4 quota ids being enforced in a single
+ * transaction, which is chown transaction:
+ * original uid and gid, new uid and gid.
+ *
+ * This value might need to be revised when directory quota is added.  */
+#define QUOTA_MAX_TRANSIDS    4
+
+/* all qids involved in a single transaction */
+struct lquota_trans {
+       unsigned short          lqt_id_cnt;
+       struct lquota_id_info   lqt_ids[QUOTA_MAX_TRANSIDS];
+};
+
+/* flags for quota local enforcement */
+#define QUOTA_FL_OVER_USRQUOTA  0x01
+#define QUOTA_FL_OVER_GRPQUOTA  0x02
+#define QUOTA_FL_SYNC           0x04
+
+#define IS_LQUOTA_RES(res)                                             \
+       (res->lr_name.name[LUSTRE_RES_ID_SEQ_OFF] == FID_SEQ_QUOTA ||   \
+        res->lr_name.name[LUSTRE_RES_ID_SEQ_OFF] == FID_SEQ_QUOTA_GLB)
+
+/* helper function used by MDT & OFD to retrieve quota accounting information
+ * on slave */
+int lquotactl_slv(const struct lu_env *, struct dt_device *,
+                 struct obd_quotactl *);
 #endif /* _LUSTRE_LQUOTA_H */