Whamcloud - gitweb
LU-15283 quota: deadlock between reint & lquota_wb
[fs/lustre-release.git] / lustre / include / lustre_quota.h
index 17ff2da..4b674d8 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/fs.h>
 #include <linux/quota.h>
 #include <linux/quotaops.h>
+#include <linux/sort.h>
 #include <dt_object.h>
 #include <lustre_fid.h>
 #include <lustre_dlm.h>
@@ -61,9 +62,9 @@ union lquota_rec {
 
 /* flags for inode/block quota accounting */
 enum osd_qid_declare_flags {
-       OSD_QID_INODE   = 1 << 0,
-       OSD_QID_BLK     = 1 << 1,
-       OSD_QID_FORCE   = 1 << 2,
+       OSD_QID_INODE   = BIT(0),
+       OSD_QID_BLK     = BIT(1),
+       OSD_QID_FORCE   = BIT(2),
 };
 
 /* Index features supported by the global index objects
@@ -177,14 +178,14 @@ struct qsd_instance;
 
 /* flags for quota local enforcement */
 enum osd_quota_local_flags {
-       QUOTA_FL_OVER_USRQUOTA = 1 << 0,
-       QUOTA_FL_OVER_GRPQUOTA = 1 << 1,
-       QUOTA_FL_SYNC = 1 << 2,
-       QUOTA_FL_OVER_PRJQUOTA = 1 << 3,
+       QUOTA_FL_OVER_USRQUOTA  = BIT(0),
+       QUOTA_FL_OVER_GRPQUOTA  = BIT(1),
+       QUOTA_FL_SYNC           = BIT(2),
+       QUOTA_FL_OVER_PRJQUOTA  = BIT(3),
 };
 
 struct qsd_instance *qsd_init(const struct lu_env *, char *, struct dt_device *,
-                             struct proc_dir_entry *, bool is_md);
+                             struct proc_dir_entry *, bool is_md, bool excl);
 int qsd_prepare(const struct lu_env *, struct qsd_instance *);
 int qsd_start(const struct lu_env *, struct qsd_instance *);
 void qsd_fini(const struct lu_env *, struct qsd_instance *);
@@ -195,6 +196,13 @@ void qsd_op_end(const struct lu_env *, struct qsd_instance *,
                struct lquota_trans *);
 void qsd_op_adjust(const struct lu_env *, struct qsd_instance *,
                   union lquota_id *, int);
+int qsd_transfer(const struct lu_env *env, struct qsd_instance *qsd,
+                struct lquota_trans *trans, unsigned int qtype,
+                u64 orig_id, u64 new_id, u64 bspace,
+                struct lquota_id_info *qi);
+int qsd_reserve_or_free_quota(const struct lu_env *env,
+                             struct qsd_instance *qsd,
+                             struct lquota_id_info *qi);
 
 /*
  * Quota information attached to a transaction
@@ -243,5 +251,29 @@ struct lquota_trans {
  * on slave */
 int lquotactl_slv(const struct lu_env *, struct dt_device *,
                  struct obd_quotactl *);
+
+static inline int quota_reserve_or_free(const struct lu_env *env,
+                                       struct qsd_instance *qsd,
+                                       struct lquota_id_info *qi,
+                                       enum quota_type type, __u64 uid,
+                                       __u64 gid, __s64 count, bool is_md)
+{
+       qi->lqi_type = type;
+       if (count > 0)
+               qi->lqi_space = toqb(count);
+       else
+               qi->lqi_space = -toqb(-count);
+
+       if (is_md)
+               qi->lqi_is_blk = false;
+       else
+               qi->lqi_is_blk = true;
+
+       qi->lqi_id.qid_uid = uid;
+       qi->lqi_id.qid_gid = gid;
+
+       return qsd_reserve_or_free_quota(env, qsd, qi);
+}
+
 /** @} quota */
 #endif /* _LUSTRE_QUOTA_H */