Whamcloud - gitweb
fb5fd93c1c58748bc269b49ebc4b76acc32a922d
[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  *  lustre/quota/quota_internal.h
5  *
6  *  Copyright (c) 2001-2005 Cluster File Systems, Inc.
7  *
8  *   This file is part of Lustre, http://www.lustre.org.
9  *
10  *   No redistribution or use is permitted outside of Cluster File Systems, Inc.
11  *
12  */
13
14 #ifndef __QUOTA_INTERNAL_H
15 #define __QUOTA_INTERNAL_H
16
17 #include <lustre_quota.h>
18
19 /* QUSG covnert bytes to blocks when counting block quota */
20 #define QUSG(count, isblk)      (isblk ? toqb(count) : count)
21
22 /* This flag is set in qc_stat to distinguish if the current getquota
23  * operation is for quota recovery */
24 #define QUOTA_RECOVERING    0x01
25
26 #ifdef __KERNEL__
27
28 #define DQUOT_DEBUG(dquot, fmt, arg...)                                       \
29         CDEBUG(D_QUOTA, "refcnt(%u) id(%u) type(%u) off(%llu) flags(%lu) "    \
30                "bhardlimit("LPU64") curspace("LPU64") ihardlimit("LPU64")"    \
31                "curinodes("LPU64"): " fmt, dquot->dq_refcnt,                  \
32                dquot->dq_id, dquot->dq_type, dquot->dq_off,  dquot->dq_flags, \
33                dquot->dq_dqb.dqb_bhardlimit, dquot->dq_dqb.dqb_curspace,      \
34                dquot->dq_dqb.dqb_ihardlimit, dquot->dq_dqb.dqb_curinodes,     \
35                ## arg);                                                       \
36
37 #define QINFO_DEBUG(qinfo, fmt, arg...)                                       \
38         CDEBUG(D_QUOTA, "files (%p/%p) flags(%lu/%lu) blocks(%u/%u) "         \
39                "free_blk(/%u/%u) free_entry(%u/%u): " fmt,                    \
40                qinfo->qi_files[0], qinfo->qi_files[1],                        \
41                qinfo->qi_info[0].dqi_flags, qinfo->qi_info[1].dqi_flags,      \
42                qinfo->qi_info[0].dqi_blocks, qinfo->qi_info[1].dqi_blocks,    \
43                qinfo->qi_info[0].dqi_free_blk, qinfo->qi_info[1].dqi_free_blk,\
44                qinfo->qi_info[0].dqi_free_entry,                              \
45                qinfo->qi_info[1].dqi_free_entry, ## arg);
46
47 #define QDATA_DEBUG(qd, fmt, arg...)                                          \
48         CDEBUG(D_QUOTA, "id(%u) flag(%u) type(%c) isblk(%c) count("LPU64") "  \
49                "qd_qunit("LPU64"): " fmt, qd->qd_id, qd->qd_flags,            \
50                QDATA_IS_GRP(qd) ? 'g' : 'u', QDATA_IS_BLK(qd) ? 'b': 'i',     \
51                qd->qd_count,                                                  \
52                (QDATA_IS_ADJBLK(qd) | QDATA_IS_ADJINO(qd)) ? qd->qd_qunit : 0,\
53                ## arg);
54
55 #define QAQ_DEBUG(qaq, fmt, arg...)                                           \
56         CDEBUG(D_QUOTA, "id(%u) flag(%u) type(%c) bunit("LPU64") "            \
57                "iunit("LPU64"): " fmt, qaq->qaq_id, qaq->qaq_flags,           \
58                QAQ_IS_GRP(qaq) ? 'g': 'u', qaq->qaq_bunit_sz,                 \
59                qaq->qaq_iunit_sz, ## arg);
60
61 #define LQS_DEBUG(lqs, fmt, arg...)                                           \
62         CDEBUG(D_QUOTA, "lqs(%p) id(%u) flag(%lu) type(%c) bunit(%lu) "       \
63                "btune(%lu) iunit(%lu) itune(%lu) lqs_bwrite_pending(%lu) "    \
64                "lqs_iwrite_pending(%lu) ino_rec("LPD64") blk_rec("LPD64" )"   \
65                "refcount(%d): "                                               \
66                fmt, lqs, lqs->lqs_id, lqs->lqs_flags,                         \
67                LQS_IS_GRP(lqs) ? 'g' : 'u',                                   \
68                lqs->lqs_bunit_sz, lqs->lqs_btune_sz, lqs->lqs_iunit_sz,       \
69                lqs->lqs_itune_sz, lqs->lqs_bwrite_pending,                    \
70                lqs->lqs_iwrite_pending, lqs->lqs_ino_rec,                     \
71                lqs->lqs_blk_rec, atomic_read(&lqs->lqs_refcount), ## arg);
72
73
74 /* quota_context.c */
75 void qunit_cache_cleanup(void);
76 int qunit_cache_init(void);
77 int qctxt_adjust_qunit(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
78                        uid_t uid, gid_t gid, __u32 isblk, int wait);
79 int qctxt_wait_pending_dqacq(struct lustre_quota_ctxt *qctxt, unsigned int id,
80                              unsigned short type, int isblk);
81 int qctxt_init(struct lustre_quota_ctxt *qctxt, struct super_block *sb,
82                dqacq_handler_t handler);
83 void qctxt_cleanup(struct lustre_quota_ctxt *qctxt, int force);
84 void qslave_start_recovery(struct obd_device *obd,
85                            struct lustre_quota_ctxt *qctxt);
86 int compute_remquota(struct obd_device *obd,
87                      struct lustre_quota_ctxt *qctxt, struct qunit_data *qdata,
88                      int isblk);
89 /* quota_master.c */
90 int lustre_dquot_init(void);
91 void lustre_dquot_exit(void);
92 int dqacq_handler(struct obd_device *obd, struct qunit_data *qdata, int opc);
93 int mds_quota_adjust(struct obd_device *obd, unsigned int qcids[],
94                      unsigned int qpids[], int rc, int opc);
95 int filter_quota_adjust(struct obd_device *obd, unsigned int qcids[],
96                         unsigned int qpids[], int rc, int opc);
97 int init_admin_quotafiles(struct obd_device *obd, struct obd_quotactl *oqctl);
98 int mds_quota_get_version(struct obd_device *obd, lustre_quota_version_t *ver);
99 int mds_quota_set_version(struct obd_device *obd, lustre_quota_version_t ver);
100 int mds_quota_invalidate(struct obd_device *obd, struct obd_quotactl *oqctl);
101 int mds_quota_finvalidate(struct obd_device *obd, struct obd_quotactl *oqctl);
102
103 int mds_admin_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl);
104 int mds_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl);
105 int mds_quota_off(struct obd_device *obd, struct obd_quotactl *oqctl);
106 int mds_admin_quota_off(struct obd_device *obd, struct obd_quotactl *oqctl);
107 int mds_set_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl);
108 int mds_get_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl);
109 int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl);
110 int mds_get_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl);
111 int mds_quota_recovery(struct obd_device *obd);
112 int mds_get_obd_quota(struct obd_device *obd, struct obd_quotactl *oqctl);
113 int dquot_create_oqaq(struct lustre_quota_ctxt *qctxt, struct lustre_dquot
114                       *dquot, __u32 ost_num, __u32 mdt_num, int type,
115                       struct quota_adjust_qunit *oqaq);
116 #endif
117
118 /* quota_ctl.c */
119 int mds_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
120 int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
121 int client_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
122 int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
123
124 /* quota_chk.c */
125 int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
126 int client_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
127 int lov_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
128 int client_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk);
129
130 #ifdef LPROCFS
131 void lprocfs_quotactl_test_init_vars(struct lprocfs_static_vars *lvars);
132 void lprocfs_quotacheck_test_init_vars(struct lprocfs_static_vars *lvars);
133 #else
134 static inline void lprocfs_quotactl_test_init_vars
135                                 (struct lprocfs_static_vars *lvars)
136 {
137         memset(lvars, 0, sizeof(*lvars));
138 }
139 static inline void lprocfs_quotacheck_test_init_vars
140                                 (struct lprocfs_static_vars *lvars)
141 {
142         memset(lvars, 0, sizeof(*lvars));
143 }
144 #endif
145
146 /* quota_adjust_qunit.c */
147 int client_quota_adjust_qunit(struct obd_export *exp, struct
148                               quota_adjust_qunit *oqaq);
149 int lov_quota_adjust_qunit(struct obd_export *exp, struct
150                            quota_adjust_qunit *oqaq);
151 int quota_adjust_slave_lqs(struct quota_adjust_qunit *oqaq, struct
152                           lustre_quota_ctxt *qctxt);
153 void qdata_to_oqaq(struct qunit_data *qdata,
154                    struct quota_adjust_qunit *oqaq);
155 #ifdef __KERNEL__
156 int quota_search_lqs(struct qunit_data *qdata,
157                      struct quota_adjust_qunit *oqaq,
158                      struct lustre_quota_ctxt *qctxt,
159                      struct lustre_qunit_size **lqs_return);
160 int quota_create_lqs(struct qunit_data *qdata,
161                      struct quota_adjust_qunit *oqaq,
162                      struct lustre_quota_ctxt *qctxt,
163                      struct lustre_qunit_size **lqs_return);
164 void quota_compute_lqs(struct qunit_data *qdata, struct lustre_qunit_size *lqs,
165                        int is_chk, int is_acq);
166
167
168 extern int quote_get_qdata(struct ptlrpc_request *req, struct qunit_data *qdata,
169                            int is_req, int is_exp);
170 extern int quote_copy_qdata(struct ptlrpc_request *req, struct qunit_data *qdata,
171                             int is_req, int is_exp);
172 int filter_quota_adjust_qunit(struct obd_export *exp, struct
173                               quota_adjust_qunit *oqaq);
174 #endif
175
176 #define LQS_BLK_DECREASE 1
177 #define LQS_BLK_INCREASE 2
178 #define LQS_INO_DECREASE 4
179 #define LQS_INO_INCREASE 8
180
181
182 #endif