Whamcloud - gitweb
land b1_5 onto HEAD
[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(%u) curspace("LPX64") ihardlimit(%u) "             \
31                "curinodes(%u): " 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) type(%lu) count(%llu) isblk(%lu):"            \
49                fmt, qd->qd_id, qd->qd_flags & QUOTA_IS_GRP, qd->qd_count,     \
50                (qd->qd_flags & QUOTA_IS_BLOCK) >> 1,       \
51                ## arg);
52
53
54 /* quota_context.c */
55 void qunit_cache_cleanup(void);
56 int qunit_cache_init(void);
57 int qctxt_adjust_qunit(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
58                        uid_t uid, gid_t gid, __u32 isblk, int wait);
59 int qctxt_wait_pending_dqacq(struct lustre_quota_ctxt *qctxt, unsigned int id,
60                              unsigned short type, int isblk);
61 int qctxt_init(struct lustre_quota_ctxt *qctxt, struct super_block *sb,
62                dqacq_handler_t handler);
63 void qctxt_cleanup(struct lustre_quota_ctxt *qctxt, int force);
64 void qslave_start_recovery(struct obd_device *obd, 
65                            struct lustre_quota_ctxt *qctxt);
66 /* quota_master.c */
67 int lustre_dquot_init(void);
68 void lustre_dquot_exit(void);
69 int dqacq_handler(struct obd_device *obd, struct qunit_data *qdata, int opc);
70 int mds_quota_adjust(struct obd_device *obd, unsigned int qcids[],
71                      unsigned int qpids[], int rc, int opc);
72 int filter_quota_adjust(struct obd_device *obd, unsigned int qcids[],
73                         unsigned int qpids[], int rc, int opc);
74 int init_admin_quotafiles(struct obd_device *obd, struct obd_quotactl *oqctl);
75 int mds_admin_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl);
76 int mds_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl);
77 int mds_quota_off(struct obd_device *obd, struct obd_quotactl *oqctl);
78 int mds_set_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl);
79 int mds_get_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl);
80 int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl);
81 int mds_get_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl);
82 int mds_quota_recovery(struct obd_device *obd);
83 int mds_get_obd_quota(struct obd_device *obd, struct obd_quotactl *oqctl);
84 #endif
85
86 /* quota_ctl.c */
87 int mds_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
88 int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
89 int client_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
90 int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
91
92 /* quota_chk.c */
93 int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
94 int client_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
95 int lov_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
96 int client_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk);
97
98 #endif