1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/quota/quota_internal.h
6 * Copyright (c) 2001-2005 Cluster File Systems, Inc.
8 * This file is part of Lustre, http://www.lustre.org.
10 * No redistribution or use is permitted outside of Cluster File Systems, Inc.
14 #ifndef __QUOTA_INTERNAL_H
15 #define __QUOTA_INTERNAL_H
17 #include <lustre_quota.h>
19 /* QUSG covnert bytes to blocks when counting block quota */
20 #define QUSG(count, isblk) (isblk ? toqb(count) : count)
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
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, \
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);
47 #define QDATA_DEBUG(qd, fmt, arg...) \
48 CDEBUG(D_QUOTA, "id(%u) type(%lu) count("LPU64") isblk(%lu):" \
49 fmt, qd->qd_id, qd->qd_flags & QUOTA_IS_GRP, qd->qd_count, \
50 (qd->qd_flags & QUOTA_IS_BLOCK) >> 1, \
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 int compute_remquota(struct obd_device *obd,
67 struct lustre_quota_ctxt *qctxt, struct qunit_data *qdata);
69 int lustre_dquot_init(void);
70 void lustre_dquot_exit(void);
71 int dqacq_handler(struct obd_device *obd, struct qunit_data *qdata, int opc);
72 int mds_quota_adjust(struct obd_device *obd, unsigned int qcids[],
73 unsigned int qpids[], int rc, int opc);
74 int filter_quota_adjust(struct obd_device *obd, unsigned int qcids[],
75 unsigned int qpids[], int rc, int opc);
76 int init_admin_quotafiles(struct obd_device *obd, struct obd_quotactl *oqctl);
77 int mds_admin_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl);
78 int mds_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl);
79 int mds_quota_off(struct obd_device *obd, struct obd_quotactl *oqctl);
80 int mds_set_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl);
81 int mds_get_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl);
82 int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl);
83 int mds_get_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl);
84 int mds_quota_recovery(struct obd_device *obd);
85 int mds_get_obd_quota(struct obd_device *obd, struct obd_quotactl *oqctl);
89 int mds_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
90 int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
91 int client_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
92 int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl);
95 int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
96 int client_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
97 int lov_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
98 int client_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk);
101 void lprocfs_quotactl_test_init_vars(struct lprocfs_static_vars *lvars);
102 void lprocfs_quotacheck_test_init_vars(struct lprocfs_static_vars *lvars);
104 static inline void lprocfs_quotactl_test_init_vars
105 (struct lprocfs_static_vars *lvars)
107 memset(lvars, 0, sizeof(*lvars));
109 static inline void lprocfs_quotacheck_test_init_vars
110 (struct lprocfs_static_vars *lvars)
112 memset(lvars, 0, sizeof(*lvars));