Whamcloud - gitweb
1c957f1fb05c4f1cab0f2d505c6474d576c0702a
[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, qd->qd_qunit, ## arg);
52
53 #define QAQ_DEBUG(qaq, fmt, arg...)                                           \
54         CDEBUG(D_QUOTA, "id(%u) flag(%u) type(%c) bunit("LPU64") "            \
55                "iunit("LPU64"): " fmt, qaq->qaq_id, qaq->qaq_flags,           \
56                QAQ_IS_GRP(qaq) ? 'g': 'u', qaq->qaq_bunit_sz,                 \
57                qaq->qaq_iunit_sz, ## arg);
58
59 #define LQS_DEBUG(lqs, fmt, arg...)                                           \
60         CDEBUG(D_QUOTA, "lqs(%p) id(%u) flag(%lu) type(%c) bunit(%lu) "       \
61                "btune(%lu) iunit(%lu) itune(%lu) lqs_bwrite_pending(%lu) "    \
62                "lqs_iwrite_pending(%lu) ino_rec("LPD64") blk_rec("LPD64" )"   \
63                "refcount(%d): "                                               \
64                fmt, lqs, lqs->lqs_id, lqs->lqs_flags,                         \
65                LQS_IS_GRP(lqs) ? 'g' : 'u',                                   \
66                lqs->lqs_bunit_sz, lqs->lqs_btune_sz, lqs->lqs_iunit_sz,       \
67                lqs->lqs_itune_sz, lqs->lqs_bwrite_pending,                    \
68                lqs->lqs_iwrite_pending, lqs->lqs_ino_rec,                     \
69                lqs->lqs_blk_rec, atomic_read(&lqs->lqs_refcount), ## arg);
70
71
72 /* quota_context.c */
73 void qunit_cache_cleanup(void);
74 int qunit_cache_init(void);
75 int qctxt_adjust_qunit(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
76                        uid_t uid, gid_t gid, __u32 isblk, int wait);
77 int qctxt_wait_pending_dqacq(struct lustre_quota_ctxt *qctxt, unsigned int id,
78                              unsigned short type, int isblk);
79 int qctxt_init(struct lustre_quota_ctxt *qctxt, struct super_block *sb,
80                dqacq_handler_t handler);
81 void qctxt_cleanup(struct lustre_quota_ctxt *qctxt, int force);
82 void qslave_start_recovery(struct obd_device *obd,
83                            struct lustre_quota_ctxt *qctxt);
84 int compute_remquota(struct obd_device *obd,
85                      struct lustre_quota_ctxt *qctxt, struct qunit_data *qdata,
86                      int isblk);
87 /* quota_master.c */
88 int lustre_dquot_init(void);
89 void lustre_dquot_exit(void);
90 int dqacq_handler(struct obd_device *obd, struct qunit_data *qdata, int opc);
91 int mds_quota_adjust(struct obd_device *obd, unsigned int qcids[],
92                      unsigned int qpids[], int rc, int opc);
93 int filter_quota_adjust(struct obd_device *obd, unsigned int qcids[],
94                         unsigned int qpids[], int rc, int opc);
95 int init_admin_quotafiles(struct obd_device *obd, struct obd_quotactl *oqctl);
96 int mds_quota_get_version(struct obd_device *obd, lustre_quota_version_t *ver);
97 int mds_quota_set_version(struct obd_device *obd, lustre_quota_version_t ver);
98 int mds_quota_invalidate(struct obd_device *obd, struct obd_quotactl *oqctl);
99
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 int dquot_create_oqaq(struct lustre_quota_ctxt *qctxt, struct lustre_dquot
110                       *dquot, __u32 ost_num, __u32 mdt_num, int type,
111                       struct quota_adjust_qunit *oqaq);
112 #endif
113
114 /* quota_ctl.c */
115 int mds_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
116 int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
117 int client_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
118 int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
119
120 /* quota_chk.c */
121 int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
122 int client_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
123 int lov_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
124 int client_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk);
125
126 #ifdef LPROCFS
127 void lprocfs_quotactl_test_init_vars(struct lprocfs_static_vars *lvars);
128 void lprocfs_quotacheck_test_init_vars(struct lprocfs_static_vars *lvars);
129 #else
130 static inline void lprocfs_quotactl_test_init_vars
131                                 (struct lprocfs_static_vars *lvars)
132 {
133         memset(lvars, 0, sizeof(*lvars));
134 }
135 static inline void lprocfs_quotacheck_test_init_vars
136                                 (struct lprocfs_static_vars *lvars)
137 {
138         memset(lvars, 0, sizeof(*lvars));
139 }
140 #endif
141
142 /* quota_adjust_qunit.c */
143 int client_quota_adjust_qunit(struct obd_export *exp, struct
144                               quota_adjust_qunit *oqaq);
145 int lov_quota_adjust_qunit(struct obd_export *exp, struct
146                            quota_adjust_qunit *oqaq);
147 int quota_adjust_slave_lqs(struct quota_adjust_qunit *oqaq, struct
148                           lustre_quota_ctxt *qctxt);
149 void qdata_to_oqaq(struct qunit_data *qdata,
150                    struct quota_adjust_qunit *oqaq);
151 #ifdef __KERNEL__
152 int quota_search_lqs(struct qunit_data *qdata,
153                      struct quota_adjust_qunit *oqaq,
154                      struct lustre_quota_ctxt *qctxt,
155                      struct lustre_qunit_size **lqs_return);
156 int quota_create_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 void quota_compute_lqs(struct qunit_data *qdata, struct lustre_qunit_size *lqs,
161                        int is_chk, int is_acq);
162
163
164 extern int quote_get_qdata(struct ptlrpc_request *req, struct qunit_data *qdata,
165                            int is_req, int is_exp);
166 extern int quote_copy_qdata(struct ptlrpc_request *req, struct qunit_data *qdata,
167                             int is_req, int is_exp);
168 int filter_quota_adjust_qunit(struct obd_export *exp, struct
169                               quota_adjust_qunit *oqaq);
170 #endif
171
172 #define LQS_BLK_DECREASE 1
173 #define LQS_BLK_INCREASE 2
174 #define LQS_INO_DECREASE 4
175 #define LQS_INO_INCREASE 8
176
177
178 #endif