Whamcloud - gitweb
LU-1842 quota: qsd request
[fs/lustre-release.git] / lustre / quota / qsd_internal.h
index 2ffeb3f..2af0307 100644 (file)
@@ -75,6 +75,9 @@ struct qsd_instance {
  * structure for each quota type (i.e. user & group).
  */
 struct qsd_qtype_info {
+       /* reference count incremented by each user of this structure */
+       cfs_atomic_t             qqi_ref;
+
        /* quota type, either USRQUOTA or GRPQUOTA
         * immutable after creation. */
        int                      qqi_qtype;
@@ -96,5 +99,68 @@ struct qsd_qtype_info {
        __u64                    qqi_glb_ver; /* global index version */
 };
 
+/*
+ * Helper functions & prototypes
+ */
+
+/* qqi_getref/putref is used to track users of a qqi structure  */
+static inline void qqi_getref(struct qsd_qtype_info *qqi)
+{
+       cfs_atomic_inc(&qqi->qqi_ref);
+}
+
+static inline void qqi_putref(struct qsd_qtype_info *qqi)
+{
+       LASSERT(cfs_atomic_read(&qqi->qqi_ref) > 0);
+       cfs_atomic_dec(&qqi->qqi_ref);
+}
+
 #define QSD_RES_TYPE(qsd) ((qsd)->qsd_is_md ? LQUOTA_RES_MD : LQUOTA_RES_DT)
+
+/* Common data shared by qsd-level handlers. This is allocated per-thread to
+ * reduce stack consumption.  */
+struct qsd_thread_info {
+       union lquota_rec                qti_rec;
+       union lquota_id                 qti_id;
+       struct lu_fid                   qti_fid;
+       struct ldlm_res_id              qti_resid;
+       struct ldlm_enqueue_info        qti_einfo;
+       struct lustre_handle            qti_lockh;
+       __u64                           qti_slv_ver;
+       union ldlm_wire_lvb             qti_lvb;
+       union {
+               struct quota_body       qti_body;
+               struct idx_info         qti_ii;
+       };
+       char                            qti_buf[MTI_NAME_MAXLEN];
+};
+
+extern struct lu_context_key qsd_thread_key;
+
+static inline
+struct qsd_thread_info *qsd_info(const struct lu_env *env)
+{
+       struct qsd_thread_info *info;
+
+       info = lu_context_key_get(&env->le_ctx, &qsd_thread_key);
+       LASSERT(info);
+       return info;
+}
+
+/* qsd_request.c */
+typedef void (*qsd_req_completion_t) (const struct lu_env *,
+                                     struct qsd_qtype_info *,
+                                     struct quota_body *, struct quota_body *,
+                                     struct lustre_handle *,
+                                     union ldlm_wire_lvb *, void *, int);
+int qsd_send_dqacq(const struct lu_env *, struct obd_export *,
+                  struct quota_body *, bool, qsd_req_completion_t,
+                  struct qsd_qtype_info *, struct lustre_handle *,
+                  struct lquota_entry *);
+int qsd_intent_lock(const struct lu_env *, struct obd_export *,
+                   struct quota_body *, bool, int, qsd_req_completion_t,
+                   struct qsd_qtype_info *, union ldlm_wire_lvb *, void *);
+int qsd_fetch_index(const struct lu_env *, struct obd_export *,
+                   struct idx_info *, unsigned int, cfs_page_t **, bool *);
+
 #endif /* _QSD_INTERNAL_H */