};
extern void lustre_swab_quota_adjust_qunit(struct quota_adjust_qunit *q);
+/* Quota types currently supported */
+enum {
+ LQUOTA_TYPE_USR = 0x00, /* maps to USRQUOTA */
+ LQUOTA_TYPE_GRP = 0x01, /* maps to GRPQUOTA */
+ LQUOTA_TYPE_MAX
+};
+
+/* There are 2 different resource types on which a quota limit can be enforced:
+ * - inodes on the MDTs
+ * - blocks on the OSTs */
+enum {
+ LQUOTA_RES_MD = 0x01, /* skip 0 to avoid null oid in FID */
+ LQUOTA_RES_DT = 0x02,
+ LQUOTA_LAST_RES,
+ LQUOTA_FIRST_RES = LQUOTA_RES_MD
+};
+#define LQUOTA_NR_RES (LQUOTA_LAST_RES - LQUOTA_FIRST_RES + 1)
+
/*
* Space accounting support
* Format of an accounting record, providing disk usage information for a given
CLASSERT(LUSTRE_RES_ID_SEQ_OFF == 0);
CLASSERT(LUSTRE_RES_ID_VER_OID_OFF == 1);
CLASSERT(LUSTRE_RES_ID_HSH_OFF == 3);
+ CLASSERT(LQUOTA_TYPE_USR == 0);
+ CLASSERT(LQUOTA_TYPE_GRP == 1);
+ CLASSERT(LQUOTA_RES_MD == 1);
+ CLASSERT(LQUOTA_RES_DT == 2);
LASSERTF(OBD_PING == 400, "found %lld\n",
(long long)OBD_PING);
LASSERTF(OBD_LOG_CANCEL == 401, "found %lld\n",
/* lquota_lib.c */
struct dt_object *acct_obj_lookup(const struct lu_env *, struct dt_device *,
int);
+void lquota_generate_fid(struct lu_fid *, int, int, int);
+int lquota_extract_fid(struct lu_fid *, int *, int *, int *);
/* lproc_quota.c */
extern struct file_operations lprocfs_quota_seq_fops;
}
EXPORT_SYMBOL(lquotactl_slv);
+/**
+ * Helper routine returning the FID associated with the global index storing
+ * quota settings for the storage pool \pool_id, resource type \pool_type and
+ * the quota type \quota_type.
+ */
+void lquota_generate_fid(struct lu_fid *fid, int pool_id, int pool_type,
+ int quota_type)
+{
+ __u8 qtype;
+
+ qtype = (quota_type == USRQUOTA) ? LQUOTA_TYPE_USR : LQUOTA_TYPE_GRP;
+
+ fid->f_seq = FID_SEQ_QUOTA_GLB;
+ fid->f_oid = (qtype << 24) | (pool_type << 16) | (__u16)pool_id;
+ fid->f_ver = 0;
+}
+
+/**
+ * Helper routine used to extract pool ID, pool type and quota type from a
+ * given FID.
+ */
+int lquota_extract_fid(struct lu_fid *fid, int *pool_id, int *pool_type,
+ int *quota_type)
+{
+ unsigned int tmp;
+ ENTRY;
+
+ if (fid->f_seq != FID_SEQ_QUOTA_GLB)
+ RETURN(-EINVAL);
+
+ if (pool_id != NULL) {
+ tmp = fid->f_oid & 0xffffU;
+ if (tmp != 0)
+ /* we only support pool ID 0 for the time being */
+ RETURN(-ENOTSUPP);
+ *pool_id = tmp;
+ }
+
+ if (pool_type != NULL) {
+ tmp = (fid->f_oid >> 16) & 0xffU;
+ if (tmp >= LQUOTA_LAST_RES)
+ RETURN(-ENOTSUPP);
+
+ *pool_type = tmp;
+ }
+
+ if (quota_type != NULL) {
+ tmp = fid->f_oid >> 24;
+ if (tmp >= LQUOTA_TYPE_MAX)
+ RETURN(-ENOTSUPP);
+
+ *quota_type = (tmp == LQUOTA_TYPE_USR) ? USRQUOTA : GRPQUOTA;
+ }
+
+ RETURN(0);
+}
+
static int __init init_lquota(void)
{
int rc;
/* CHECK_CVALUE(LUSTRE_RES_ID_WAS_VER_OFF); packed with OID */
CHECK_CVALUE(LUSTRE_RES_ID_HSH_OFF);
+ CHECK_CVALUE(LQUOTA_TYPE_USR);
+ CHECK_CVALUE(LQUOTA_TYPE_GRP);
+
+ CHECK_CVALUE(LQUOTA_RES_MD);
+ CHECK_CVALUE(LQUOTA_RES_DT);
+
CHECK_VALUE(OBD_PING);
CHECK_VALUE(OBD_LOG_CANCEL);
CHECK_VALUE(OBD_QC_CALLBACK);
CLASSERT(LUSTRE_RES_ID_SEQ_OFF == 0);
CLASSERT(LUSTRE_RES_ID_VER_OID_OFF == 1);
CLASSERT(LUSTRE_RES_ID_HSH_OFF == 3);
+ CLASSERT(LQUOTA_TYPE_USR == 0);
+ CLASSERT(LQUOTA_TYPE_GRP == 1);
+ CLASSERT(LQUOTA_RES_MD == 1);
+ CLASSERT(LQUOTA_RES_DT == 2);
LASSERTF(OBD_PING == 400, "found %lld\n",
(long long)OBD_PING);
LASSERTF(OBD_LOG_CANCEL == 401, "found %lld\n",