Whamcloud - gitweb
LU-1842 quota: helper routines to manage FID_SEQ_QUOTA_GLB
[fs/lustre-release.git] / lustre / quota / lquota_internal.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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
20  *
21  * GPL HEADER END
22  */
23 /*
24  * Copyright (c) 2012 Whamcloud, Inc.
25  * Use is subject to license terms.
26  */
27
28 #include <obd.h>
29 #include <lquota.h>
30
31 #ifndef _LQUOTA_INTERNAL_H
32 #define _LQUOTA_INTERNAL_H
33
34 #define QTYPE_NAME(qtype) ((qtype) == USRQUOTA ? "usr" : "grp")
35
36 #define QIF_IFLAGS (QIF_INODES | QIF_ITIME | QIF_ILIMITS)
37 #define QIF_BFLAGS (QIF_SPACE | QIF_BTIME | QIF_BLIMITS)
38
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
43
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,
50 };
51
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;
56         struct lu_buf           qti_lb;
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];
62 };
63
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
67
68 extern struct lu_context_key lquota_thread_key;
69
70 /* extract lquota_threa_info context from environment */
71 static inline
72 struct lquota_thread_info *lquota_info(const struct lu_env *env)
73 {
74         struct lquota_thread_info       *info;
75
76         info = lu_context_key_get(&env->le_ctx, &lquota_thread_key);
77         LASSERT(info);
78         return info;
79 }
80
81 /* lquota_lib.c */
82 struct dt_object *acct_obj_lookup(const struct lu_env *, struct dt_device *,
83                                   int);
84 void lquota_generate_fid(struct lu_fid *, int, int, int);
85 int lquota_extract_fid(struct lu_fid *, int *, int *, int *);
86
87 /* lproc_quota.c */
88 extern struct file_operations lprocfs_quota_seq_fops;
89
90 /* quota_interface.c
91  * old quota module initialization routines, to be removed */
92 int init_lustre_quota(void);
93 void exit_lustre_quota(void);
94
95 #endif /* _LQUOTA_INTERNAL_H */