4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * lustre/mdd/mdd_quota.c
36 * Lustre Metadata Server (mdd) routines
38 * Author: Fan Yong <Yong.Fan@Sun.Com>
41 #ifdef HAVE_QUOTA_SUPPORT
43 #include "mdd_internal.h"
45 int mdd_quota_notify(const struct lu_env *env, struct md_device *m)
47 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
48 struct obd_device *obd = mdd->mdd_obd_dev;
51 lquota_setinfo(mds_quota_interface_ref, obd, (void *)1);
55 int mdd_quota_setup(const struct lu_env *env, struct md_device *m,
58 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
59 struct obd_device *obd = mdd->mdd_obd_dev;
60 struct dt_device *dt = mdd->mdd_child;
64 LASSERT(obd->obd_fsops != NULL);
65 dt->dd_ops->dt_init_quota_ctxt(env, dt, (void *)obd, data);
66 rc = lquota_setup(mds_quota_interface_ref, obd);
70 int mdd_quota_cleanup(const struct lu_env *env, struct md_device *m)
72 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
73 struct obd_device *obd = mdd->mdd_obd_dev;
77 rc1 = lquota_cleanup(mds_quota_interface_ref, obd);
78 rc2 = lquota_fs_cleanup(mds_quota_interface_ref, obd);
82 int mdd_quota_recovery(const struct lu_env *env, struct md_device *m)
84 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
85 struct obd_device *obd = mdd->mdd_obd_dev;
89 rc = lquota_recovery(mds_quota_interface_ref, obd);
93 int mdd_quota_check(const struct lu_env *env, struct md_device *m,
96 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
97 struct obd_device *obd = mdd->mdd_obd_dev;
98 struct obd_export *exp = md_quota(env)->mq_exp;
99 struct obd_quotactl *oqctl = &mdd_env_info(env)->mti_oqctl;
103 oqctl->qc_type = type;
104 rc = lquota_check(mds_quota_interface_ref, obd, exp, oqctl);
108 int mdd_quota_on(const struct lu_env *env, struct md_device *m,
111 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
112 struct obd_device *obd = mdd->mdd_obd_dev;
113 struct obd_quotactl *oqctl = &mdd_env_info(env)->mti_oqctl;
117 oqctl->qc_cmd = Q_QUOTAON;
118 oqctl->qc_type = type;
119 rc = lquota_ctl(mds_quota_interface_ref, obd, oqctl);
123 int mdd_quota_off(const struct lu_env *env, struct md_device *m,
126 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
127 struct obd_device *obd = mdd->mdd_obd_dev;
128 struct obd_quotactl *oqctl = &mdd_env_info(env)->mti_oqctl;
132 oqctl->qc_cmd = Q_QUOTAOFF;
133 oqctl->qc_type = type;
134 rc = lquota_ctl(mds_quota_interface_ref, obd, oqctl);
138 int mdd_quota_setinfo(const struct lu_env *env, struct md_device *m,
139 __u32 type, __u32 id, struct obd_dqinfo *dqinfo)
141 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
142 struct obd_device *obd = mdd->mdd_obd_dev;
143 struct obd_quotactl *oqctl = &mdd_env_info(env)->mti_oqctl;
147 oqctl->qc_cmd = Q_SETINFO;
148 oqctl->qc_type = type;
150 oqctl->qc_dqinfo = *dqinfo;
151 rc = lquota_ctl(mds_quota_interface_ref, obd, oqctl);
155 int mdd_quota_getinfo(const struct lu_env *env, const struct md_device *m,
156 __u32 type, __u32 id, struct obd_dqinfo *dqinfo)
158 struct mdd_device *mdd = lu2mdd_dev(
159 &((struct md_device *)m)->md_lu_dev);
160 struct obd_device *obd = mdd->mdd_obd_dev;
161 struct obd_quotactl *oqctl = &mdd_env_info(env)->mti_oqctl;
165 oqctl->qc_cmd = Q_GETINFO;
166 oqctl->qc_type = type;
168 rc = lquota_ctl(mds_quota_interface_ref, obd, oqctl);
169 *dqinfo = oqctl->qc_dqinfo;
173 int mdd_quota_setquota(const struct lu_env *env, struct md_device *m,
174 __u32 type, __u32 id, struct obd_dqblk *dqblk)
176 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
177 struct obd_device *obd = mdd->mdd_obd_dev;
178 struct obd_quotactl *oqctl = &mdd_env_info(env)->mti_oqctl;
182 oqctl->qc_cmd = Q_SETQUOTA;
183 oqctl->qc_type = type;
185 oqctl->qc_dqblk = *dqblk;
186 rc = lquota_ctl(mds_quota_interface_ref, obd, oqctl);
190 int mdd_quota_getquota(const struct lu_env *env, const struct md_device *m,
191 __u32 type, __u32 id, struct obd_dqblk *dqblk)
193 struct mdd_device *mdd = lu2mdd_dev(
194 &((struct md_device *)m)->md_lu_dev);
195 struct obd_device *obd = mdd->mdd_obd_dev;
196 struct obd_quotactl *oqctl = &mdd_env_info(env)->mti_oqctl;
200 oqctl->qc_cmd = Q_GETQUOTA;
201 oqctl->qc_type = type;
203 rc = lquota_ctl(mds_quota_interface_ref, obd, oqctl);
204 *dqblk = oqctl->qc_dqblk;
208 int mdd_quota_getoinfo(const struct lu_env *env, const struct md_device *m,
209 __u32 type, __u32 id, struct obd_dqinfo *dqinfo)
211 struct mdd_device *mdd = lu2mdd_dev(
212 &((struct md_device *)m)->md_lu_dev);
213 struct obd_device *obd = mdd->mdd_obd_dev;
214 struct obd_quotactl *oqctl = &mdd_env_info(env)->mti_oqctl;
218 oqctl->qc_cmd = Q_GETOINFO;
219 oqctl->qc_type = type;
221 rc = lquota_ctl(mds_quota_interface_ref, obd, oqctl);
222 *dqinfo = oqctl->qc_dqinfo;
226 int mdd_quota_getoquota(const struct lu_env *env, const struct md_device *m,
227 __u32 type, __u32 id, struct obd_dqblk *dqblk)
229 struct mdd_device *mdd = lu2mdd_dev(
230 &((struct md_device *)m)->md_lu_dev);
231 struct obd_device *obd = mdd->mdd_obd_dev;
232 struct obd_quotactl *oqctl = &mdd_env_info(env)->mti_oqctl;
236 oqctl->qc_cmd = Q_GETOQUOTA;
237 oqctl->qc_type = type;
239 rc = lquota_ctl(mds_quota_interface_ref, obd, oqctl);
240 *dqblk = oqctl->qc_dqblk;
244 int mdd_quota_invalidate(const struct lu_env *env, struct md_device *m,
247 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
248 struct obd_device *obd = mdd->mdd_obd_dev;
249 struct obd_quotactl *oqctl = &mdd_env_info(env)->mti_oqctl;
253 oqctl->qc_cmd = LUSTRE_Q_INVALIDATE;
254 oqctl->qc_type = type;
255 rc = lquota_ctl(mds_quota_interface_ref, obd, oqctl);
259 int mdd_quota_finvalidate(const struct lu_env *env, struct md_device *m,
262 struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
263 struct obd_device *obd = mdd->mdd_obd_dev;
264 struct obd_quotactl *oqctl = &mdd_env_info(env)->mti_oqctl;
268 oqctl->qc_cmd = LUSTRE_Q_FINVALIDATE;
269 oqctl->qc_type = type;
270 rc = lquota_ctl(mds_quota_interface_ref, obd, oqctl);