#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>
/* 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
* Below are the function prototypes to be used by OSD layer to manage quota
* enforcement. Arguments are documented where each function is defined. */
+/* flags for quota local enforcement */
+enum osd_quota_local_flags {
+ 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 *);
int qsd_op_begin(const struct lu_env *, struct qsd_instance *,
- struct lquota_trans *, struct lquota_id_info *, int *);
+ struct lquota_trans *, struct lquota_id_info *,
+ enum osd_quota_local_flags *);
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
* a single transaction for inode and block quota, 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 8
+ * Given a parent dir and a sub dir, with different uid, gid and project id,
+ * need <parent,child> x <user,group,project> x <block,inode> = 12 ids */
+#define QUOTA_MAX_TRANSIDS 12
/* all qids involved in a single transaction */
struct lquota_trans {
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 QUOTA_FL_OVER_PRJQUOTA 0x08
-
#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)