Whamcloud - gitweb
b=16098
[fs/lustre-release.git] / lustre / quota / quota_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef __QUOTA_INTERNAL_H
38 #define __QUOTA_INTERNAL_H
39
40 #include <lustre_quota.h>
41
42 /* QUSG covnert bytes to blocks when counting block quota */
43 #define QUSG(count, isblk)      (isblk ? toqb(count) : count)
44
45 /* This flag is set in qc_stat to distinguish if the current getquota 
46  * operation is for quota recovery */
47 #define QUOTA_RECOVERING    0x01
48
49 #ifdef __KERNEL__
50
51 #define DQUOT_DEBUG(dquot, fmt, arg...)                                       \
52         CDEBUG(D_QUOTA, "refcnt(%u) id(%u) type(%u) off(%llu) flags(%lu) "    \
53                "bhardlimit(%u) curspace("LPX64") ihardlimit(%u) "             \
54                "curinodes(%u): " fmt, dquot->dq_refcnt,                       \
55                dquot->dq_id, dquot->dq_type, dquot->dq_off,  dquot->dq_flags, \
56                dquot->dq_dqb.dqb_bhardlimit, dquot->dq_dqb.dqb_curspace,      \
57                dquot->dq_dqb.dqb_ihardlimit, dquot->dq_dqb.dqb_curinodes,     \
58                ## arg);                                                       \
59
60 #define QINFO_DEBUG(qinfo, fmt, arg...)                                       \
61         CDEBUG(D_QUOTA, "files (%p/%p) flags(%lu/%lu) blocks(%u/%u) "         \
62                "free_blk(/%u/%u) free_entry(%u/%u): " fmt,                    \
63                qinfo->qi_files[0], qinfo->qi_files[1],                        \
64                qinfo->qi_info[0].dqi_flags, qinfo->qi_info[1].dqi_flags,      \
65                qinfo->qi_info[0].dqi_blocks, qinfo->qi_info[1].dqi_blocks,    \
66                qinfo->qi_info[0].dqi_free_blk, qinfo->qi_info[1].dqi_free_blk,\
67                qinfo->qi_info[0].dqi_free_entry,                              \
68                qinfo->qi_info[1].dqi_free_entry, ## arg);
69
70 #define QDATA_DEBUG(qd, fmt, arg...)                                          \
71         CDEBUG(D_QUOTA, "id(%u) type(%lu) count("LPU64") isblk(%lu):"         \
72                fmt, qd->qd_id, qd->qd_flags & QUOTA_IS_GRP, qd->qd_count,     \
73                (qd->qd_flags & QUOTA_IS_BLOCK) >> 1,       \
74                ## arg);
75
76
77 /* quota_context.c */
78 void qunit_cache_cleanup(void);
79 int qunit_cache_init(void);
80 int qctxt_adjust_qunit(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
81                        uid_t uid, gid_t gid, __u32 isblk, int wait);
82 int qctxt_wait_pending_dqacq(struct lustre_quota_ctxt *qctxt, unsigned int id,
83                              unsigned short type, int isblk);
84 int qctxt_init(struct lustre_quota_ctxt *qctxt, struct super_block *sb,
85                dqacq_handler_t handler);
86 void qctxt_cleanup(struct lustre_quota_ctxt *qctxt, int force);
87 void qslave_start_recovery(struct obd_device *obd, 
88                            struct lustre_quota_ctxt *qctxt);
89 int compute_remquota(struct obd_device *obd,
90                      struct lustre_quota_ctxt *qctxt, struct qunit_data *qdata);
91 /* quota_master.c */
92 int lustre_dquot_init(void);
93 void lustre_dquot_exit(void);
94 int dqacq_handler(struct obd_device *obd, struct qunit_data *qdata, int opc);
95 int mds_quota_adjust(struct obd_device *obd, unsigned int qcids[],
96                      unsigned int qpids[], int rc, int opc);
97 int filter_quota_adjust(struct obd_device *obd, unsigned int qcids[],
98                         unsigned int qpids[], int rc, int opc);
99 int init_admin_quotafiles(struct obd_device *obd, struct obd_quotactl *oqctl);
100 int mds_admin_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl);
101 int mds_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl);
102 int mds_quota_off(struct obd_device *obd, struct obd_quotactl *oqctl);
103 int mds_set_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl);
104 int mds_get_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl);
105 int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl);
106 int mds_get_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl);
107 int mds_quota_recovery(struct obd_device *obd);
108 int mds_get_obd_quota(struct obd_device *obd, struct obd_quotactl *oqctl);
109 #endif
110
111 /* quota_ctl.c */
112 int mds_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
113 int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
114 int client_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
115 int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
116
117 /* quota_chk.c */
118 int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
119 int client_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
120 int lov_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
121 int client_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk);
122
123 #ifdef LPROCFS
124 void lprocfs_quotactl_test_init_vars(struct lprocfs_static_vars *lvars);
125 void lprocfs_quotacheck_test_init_vars(struct lprocfs_static_vars *lvars);
126 #else
127 static inline void lprocfs_quotactl_test_init_vars
128                                 (struct lprocfs_static_vars *lvars)
129 {
130         memset(lvars, 0, sizeof(*lvars));
131 }
132 static inline void lprocfs_quotacheck_test_init_vars
133                                 (struct lprocfs_static_vars *lvars)
134 {
135         memset(lvars, 0, sizeof(*lvars));
136 }
137 #endif
138
139 #endif