4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 021110-1307, USA
24 * Copyright (c) 2012 Whamcloud, Inc.
25 * Use is subject to license terms.
31 #ifndef _LQUOTA_INTERNAL_H
32 #define _LQUOTA_INTERNAL_H
34 #define QTYPE_NAME(qtype) ((qtype) == USRQUOTA ? "usr" : "grp")
36 #define QIF_IFLAGS (QIF_INODES | QIF_ITIME | QIF_ILIMITS)
37 #define QIF_BFLAGS (QIF_SPACE | QIF_BTIME | QIF_BLIMITS)
39 /* The biggest filename are the one used for slave index which are in the form
40 * of 0x%x-%s,glb_fid.f_oid,slv_uuid, that's to say:
41 * 2(0x) + 8(f_oid) + 1(-) + 40(UUID_MAX) which means 51 chars + '\0' */
42 #define LQUOTA_NAME_MAX 52
44 /* reserved OID in FID_SEQ_QUOTA for local objects */
45 enum lquota_local_oid {
46 LQUOTA_USR_OID = 1UL, /* slave index copy for user quota */
47 LQUOTA_GRP_OID = 2UL, /* slave index copy for group quota */
48 /* all OIDs after this are allocated dynamically by the QMT */
49 LQUOTA_GENERATED_OID = 4096UL,
52 /* Common data shared by quota-level handlers. This is allocated per-thread to
53 * reduce stack consumption */
54 struct lquota_thread_info {
55 union lquota_rec qti_rec;
57 struct lu_attr qti_attr;
58 struct dt_object_format qti_dof;
59 struct lustre_mdt_attrs qti_lma;
60 struct lu_fid qti_fid;
61 char qti_buf[LQUOTA_NAME_MAX];
64 #define qti_glb_rec qti_rec.lqr_glb_rec
65 #define qti_acct_rec qti_rec.lqr_acct_rec
66 #define qti_slv_rec qti_rec.lqr_slv_rec
68 #define LQUOTA_BUMP_VER 0x1
69 #define LQUOTA_SET_VER 0x2
71 extern struct lu_context_key lquota_thread_key;
73 /* extract lquota_threa_info context from environment */
75 struct lquota_thread_info *lquota_info(const struct lu_env *env)
77 struct lquota_thread_info *info;
79 info = lu_context_key_get(&env->le_ctx, &lquota_thread_key);
81 lu_env_refill((struct lu_env *)env);
82 info = lu_context_key_get(&env->le_ctx, &lquota_thread_key);
89 struct dt_object *acct_obj_lookup(const struct lu_env *, struct dt_device *,
91 void lquota_generate_fid(struct lu_fid *, int, int, int);
92 int lquota_extract_fid(struct lu_fid *, int *, int *, int *);
93 const struct dt_index_features *glb_idx_feature(struct lu_fid *);
96 struct dt_object *lquota_disk_dir_find_create(const struct lu_env *,
98 struct dt_object *, const char *);
99 struct dt_object *lquota_disk_glb_find_create(const struct lu_env *,
102 struct lu_fid *, bool);
103 struct dt_object *lquota_disk_slv_find_create(const struct lu_env *,
107 struct obd_uuid *, bool);
108 typedef int (*lquota_disk_slv_cb_t) (const struct lu_env *, struct lu_fid *,
109 char *, struct lu_fid *, void *);
110 int lquota_disk_for_each_slv(const struct lu_env *, struct dt_object *,
111 struct lu_fid *, lquota_disk_slv_cb_t, void *);
112 struct dt_object *lquota_disk_slv_find(const struct lu_env *,
113 struct dt_device *, struct dt_object *,
114 struct lu_fid *, struct obd_uuid *);
115 int lquota_disk_read(const struct lu_env *, struct dt_object *,
116 union lquota_id *, struct dt_rec *);
117 int lquota_disk_declare_write(const struct lu_env *, struct thandle *,
118 struct dt_object *, union lquota_id *);
119 int lquota_disk_write(const struct lu_env *, struct thandle *,
120 struct dt_object *, union lquota_id *, struct dt_rec *,
122 int lquota_disk_update_ver(const struct lu_env *, struct dt_device *,
123 struct dt_object *, __u64);
126 extern struct file_operations lprocfs_quota_seq_fops;
129 * old quota module initialization routines, to be removed */
130 int init_lustre_quota(void);
131 void exit_lustre_quota(void);
133 #endif /* _LQUOTA_INTERNAL_H */