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, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 021110-1307, USA
24 * Copyright (c) 2012 Intel, Inc.
25 * Use is subject to license terms.
27 * Author: Johann Lombardi <johann.lombardi@intel.com>
28 * Author: Niu Yawei <yawei.niu@intel.com>
32 * Quota Slave Driver (QSD) management.
34 * The quota slave feature is implemented under the form of a library called
35 * QSD. Each OSD device should create a QSD instance via qsd_init() which will
36 * be used to manage quota enforcement for this device. This implies:
37 * - completing the reintegration procedure with the quota master (aka QMT, see
38 * qmt_dev.c) to retrieve the latest quota settings and space distribution.
39 * - managing quota locks in order to be notified of configuration changes.
40 * - acquiring space from the QMT when quota space for a given user/group is
41 * close to exhaustion.
42 * - allocating quota space to service threads for local request processing.
44 * Once the QSD instance created, the OSD device should invoke qsd_start()
45 * when recovery is completed. This notifies the QSD that we are about to
46 * process new requests on which quota should be strictly enforced.
47 * Then, qsd_op_begin/end can be used to reserve/release/pre-acquire quota space
48 * for/after each operation until shutdown where the QSD instance should be
49 * freed via qsd_fini().
53 # define EXPORT_SYMTAB
56 #define DEBUG_SUBSYSTEM S_LQUOTA
58 #include <obd_class.h>
59 #include "qsd_internal.h"
61 cfs_mem_cache_t *upd_kmem;
63 struct lu_kmem_descr qsd_caches[] = {
65 .ckd_cache = &upd_kmem,
66 .ckd_name = "upd_kmem",
67 .ckd_size = sizeof(struct qsd_upd_rec)
74 /* define qsd thread key */
75 LU_KEY_INIT_FINI(qsd, struct qsd_thread_info);
76 LU_CONTEXT_KEY_DEFINE(qsd, LCT_MD_THREAD | LCT_DT_THREAD | LCT_LOCAL);
77 LU_KEY_INIT_GENERIC(qsd);
79 /* some procfs helpers */
80 static int lprocfs_qsd_rd_state(char *page, char **start, off_t off,
81 int count, int *eof, void *data)
83 struct qsd_instance *qsd = (struct qsd_instance *)data;
89 memset(enabled, 0, sizeof(enabled));
90 if (qsd_type_enabled(qsd, USRQUOTA))
92 if (qsd_type_enabled(qsd, GRPQUOTA))
94 if (strlen(enabled) == 0)
95 strcat(enabled, "none");
97 rc = snprintf(page, count,
101 "quota enabled: %s\n"
102 "conn to master: %s\n",
103 qsd->qsd_svname, qsd->qsd_pool_id,
104 qsd->qsd_is_md ? "md" : "dt", enabled,
105 qsd->qsd_exp_valid ? "setup" : "not setup yet");
107 if (qsd->qsd_prepared)
108 rc += snprintf(page + rc, count - rc,
109 "user uptodate: glb[%d],slv[%d],reint[%d]\n"
110 "group uptodate: glb[%d],slv[%d],reint[%d]\n",
111 qsd->qsd_type_array[USRQUOTA]->qqi_glb_uptodate,
112 qsd->qsd_type_array[USRQUOTA]->qqi_slv_uptodate,
113 qsd->qsd_type_array[USRQUOTA]->qqi_reint,
114 qsd->qsd_type_array[GRPQUOTA]->qqi_glb_uptodate,
115 qsd->qsd_type_array[GRPQUOTA]->qqi_slv_uptodate,
116 qsd->qsd_type_array[GRPQUOTA]->qqi_reint);
120 static int lprocfs_qsd_rd_enabled(char *page, char **start, off_t off,
121 int count, int *eof, void *data)
123 struct qsd_instance *qsd = (struct qsd_instance *)data;
126 LASSERT(qsd != NULL);
128 memset(enabled, 0, sizeof(enabled));
129 if (qsd_type_enabled(qsd, USRQUOTA))
130 strcat(enabled, "u");
131 if (qsd_type_enabled(qsd, GRPQUOTA))
132 strcat(enabled, "g");
133 if (strlen(enabled) == 0)
134 strcat(enabled, "none");
136 return snprintf(page, count, "%s\n", enabled);
139 /* force reintegration procedure to be executed.
140 * Used for test/debugging purpose */
141 static int lprocfs_qsd_wr_force_reint(struct file *file, const char *buffer,
142 unsigned long count, void *data)
144 struct qsd_instance *qsd = (struct qsd_instance *)data;
147 LASSERT(qsd != NULL);
149 cfs_write_lock(&qsd->qsd_lock);
150 if (qsd->qsd_stopping) {
151 /* don't mess up with shutdown procedure, it is already
152 * complicated enough */
154 } else if (!qsd->qsd_prepared) {
157 /* mark all indexes as stale */
158 for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) {
159 qsd->qsd_type_array[qtype]->qqi_glb_uptodate = false;
160 qsd->qsd_type_array[qtype]->qqi_slv_uptodate = false;
163 cfs_write_unlock(&qsd->qsd_lock);
168 /* kick off reintegration */
169 for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) {
170 rc = qsd_start_reint_thread(qsd->qsd_type_array[qtype]);
174 return rc == 0 ? count : rc;
177 static struct lprocfs_vars lprocfs_quota_qsd_vars[] = {
178 { "info", lprocfs_qsd_rd_state, 0, 0},
179 { "enabled", lprocfs_qsd_rd_enabled, 0, 0},
180 { "force_reint", 0, lprocfs_qsd_wr_force_reint, 0},
185 * Callback function invoked by the OSP layer when the connection to the master
188 * \param data - is a pointer to the qsd_instance
190 * \retval - 0 on success, appropriate error on failure
192 static int qsd_conn_callback(void *data)
194 struct qsd_instance *qsd = (struct qsd_instance *)data;
198 /* qsd_exp should now be valid */
199 LASSERT(qsd->qsd_exp);
201 /* grab reference on namespace */
202 ldlm_namespace_get(class_exp2obd(qsd->qsd_exp)->obd_namespace);
203 qsd->qsd_ns = class_exp2obd(qsd->qsd_exp)->obd_namespace;
205 cfs_write_lock(&qsd->qsd_lock);
206 /* notify that qsd_exp is now valid */
207 qsd->qsd_exp_valid = true;
208 cfs_write_unlock(&qsd->qsd_lock);
210 /* Now that the connection to master is setup, we can initiate the
211 * reintegration procedure for quota types which are enabled.
212 * It is worth noting that, if the qsd_instance hasn't been started
213 * already, then we can only complete the first two steps of the
214 * reintegration procedure (i.e. global lock enqueue and slave
215 * index transfer) since the space usage reconciliation (i.e.
216 * step 3) will have to wait for qsd_start() to be called */
217 for (type = USRQUOTA; type < MAXQUOTAS; type++) {
218 struct qsd_qtype_info *qqi = qsd->qsd_type_array[type];
219 cfs_waitq_signal(&qqi->qqi_reint_thread.t_ctl_waitq);
226 * Release qsd_qtype_info structure which contains data associated with a
227 * given quota type. This releases the accounting objects.
228 * It's called on OSD cleanup when the qsd instance is released.
230 * \param env - is the environment passed by the caller
231 * \param qsd - is the qsd instance managing the qsd_qtype_info structure
233 * \param qtype - is the quota type to be shutdown
235 static void qsd_qtype_fini(const struct lu_env *env, struct qsd_instance *qsd,
238 struct qsd_qtype_info *qqi;
241 if (qsd->qsd_type_array[qtype] == NULL)
243 qqi = qsd->qsd_type_array[qtype];
244 qsd->qsd_type_array[qtype] = NULL;
246 /* all deferred work lists should be empty */
247 LASSERT(cfs_list_empty(&qqi->qqi_deferred_glb));
248 LASSERT(cfs_list_empty(&qqi->qqi_deferred_slv));
250 /* shutdown lquota site */
251 if (qqi->qqi_site != NULL && !IS_ERR(qqi->qqi_site)) {
252 lquota_site_free(env, qqi->qqi_site);
253 qqi->qqi_site = NULL;
256 /* by now, all qqi users should have gone away */
257 LASSERT(cfs_atomic_read(&qqi->qqi_ref) == 1);
258 lu_ref_fini(&qqi->qqi_reference);
260 /* release accounting object */
261 if (qqi->qqi_acct_obj != NULL && !IS_ERR(qqi->qqi_acct_obj)) {
262 lu_object_put(env, &qqi->qqi_acct_obj->do_lu);
263 qqi->qqi_acct_obj = NULL;
266 /* release slv index */
267 if (qqi->qqi_slv_obj != NULL && !IS_ERR(qqi->qqi_slv_obj)) {
268 lu_object_put(env, &qqi->qqi_slv_obj->do_lu);
269 qqi->qqi_slv_obj = NULL;
270 qqi->qqi_slv_ver = 0;
273 /* release global index */
274 if (qqi->qqi_glb_obj != NULL && !IS_ERR(qqi->qqi_glb_obj)) {
275 lu_object_put(env, &qqi->qqi_glb_obj->do_lu);
276 qqi->qqi_glb_obj = NULL;
277 qqi->qqi_glb_ver = 0;
285 * Allocate and initialize a qsd_qtype_info structure for quota type \qtype.
286 * This opens the accounting object and initializes the proc file.
287 * It's called on OSD start when the qsd_prepare() is invoked on the qsd
290 * \param env - the environment passed by the caller
291 * \param qsd - is the qsd instance which will be in charge of the new
292 * qsd_qtype_info instance.
293 * \param qtype - is quota type to set up
295 * \retval - 0 on success and qsd->qsd_type_array[qtype] is allocated,
296 * appropriate error on failure
298 static int qsd_qtype_init(const struct lu_env *env, struct qsd_instance *qsd,
301 struct qsd_qtype_info *qqi;
303 struct obd_uuid uuid;
306 LASSERT(qsd->qsd_type_array[qtype] == NULL);
308 /* allocate structure for this quota type */
312 qsd->qsd_type_array[qtype] = qqi;
313 cfs_atomic_set(&qqi->qqi_ref, 1); /* referenced from qsd */
315 /* set backpointer and other parameters */
317 qqi->qqi_qtype = qtype;
318 lu_ref_init(&qqi->qqi_reference);
319 lquota_generate_fid(&qqi->qqi_fid, qsd->qsd_pool_id, QSD_RES_TYPE(qsd),
321 qqi->qqi_glb_uptodate = false;
322 qqi->qqi_slv_uptodate = false;
323 qqi->qqi_reint = false;
324 cfs_waitq_init(&qqi->qqi_reint_thread.t_ctl_waitq);
325 thread_set_flags(&qqi->qqi_reint_thread, SVC_STOPPED);
326 CFS_INIT_LIST_HEAD(&qqi->qqi_deferred_glb);
327 CFS_INIT_LIST_HEAD(&qqi->qqi_deferred_slv);
328 memset(&qqi->qqi_lockh, 0, sizeof(qqi->qqi_lockh));
330 /* open accounting object */
331 LASSERT(qqi->qqi_acct_obj == NULL);
332 qqi->qqi_acct_obj = acct_obj_lookup(env, qsd->qsd_dev, qtype);
333 if (qqi->qqi_acct_obj == NULL) {
334 LCONSOLE_ERROR("%s: No %s space accounting support. Please use "
335 "tunefs.lustre --quota option to enable quota "
337 qsd->qsd_svname, QTYPE_NAME(qtype));
338 GOTO(out, rc = -ENOENT);
341 /* open global index copy */
342 LASSERT(qqi->qqi_glb_obj == NULL);
343 qqi->qqi_glb_obj = lquota_disk_glb_find_create(env, qsd->qsd_dev,
345 &qqi->qqi_fid, true);
346 if (IS_ERR(qqi->qqi_glb_obj)) {
347 CERROR("%s: can't open global index copy "DFID" %ld\n",
348 qsd->qsd_svname, PFID(&qqi->qqi_fid),
349 PTR_ERR(qqi->qqi_glb_obj));
350 GOTO(out, rc = PTR_ERR(qqi->qqi_glb_obj));
352 qqi->qqi_glb_ver = dt_version_get(env, qqi->qqi_glb_obj);
354 /* open slave index copy */
355 LASSERT(qqi->qqi_slv_obj == NULL);
356 obd_str2uuid(&uuid, qsd->qsd_svname);
357 qqi->qqi_slv_obj = lquota_disk_slv_find_create(env, qsd->qsd_dev,
359 &qqi->qqi_fid, &uuid,
361 if (IS_ERR(qqi->qqi_slv_obj)) {
362 CERROR("%s: can't open slave index copy "DFID" %ld\n",
363 qsd->qsd_svname, PFID(&qqi->qqi_fid),
364 PTR_ERR(qqi->qqi_slv_obj));
365 GOTO(out, rc = PTR_ERR(qqi->qqi_slv_obj));
367 qqi->qqi_slv_ver = dt_version_get(env, qqi->qqi_slv_obj);
370 qqi->qqi_site = lquota_site_alloc(env, qqi, false, qtype, &qsd_lqe_ops);
371 if (IS_ERR(qqi->qqi_site)) {
372 CERROR("%s: can't allocate site "DFID" %ld\n", qsd->qsd_svname,
373 PFID(&qqi->qqi_fid), PTR_ERR(qqi->qqi_site));
374 GOTO(out, rc = PTR_ERR(qqi->qqi_site));
377 /* register proc entry for accounting object */
378 rc = lprocfs_seq_create(qsd->qsd_proc,
379 qtype == USRQUOTA ? "acct_user" : "acct_group",
380 0444, &lprocfs_quota_seq_fops,
383 CERROR("%s: can't add procfs entry for accounting file %d\n",
384 qsd->qsd_svname, rc);
390 qsd_qtype_fini(env, qsd, qtype);
395 * Release a qsd_instance. Companion of qsd_init(). This releases all data
396 * structures associated with the quota slave (on-disk objects, lquota entry
398 * This function should be called when the OSD is shutting down.
400 * \param env - is the environment passed by the caller
401 * \param qsd - is the qsd instance to shutdown
403 void qsd_fini(const struct lu_env *env, struct qsd_instance *qsd)
408 if (unlikely(qsd == NULL))
411 CDEBUG(D_QUOTA, "%s: initiating QSD shutdown\n", qsd->qsd_svname);
412 cfs_write_lock(&qsd->qsd_lock);
413 qsd->qsd_stopping = true;
414 cfs_write_unlock(&qsd->qsd_lock);
416 /* remove from the list of fsinfo */
417 if (!cfs_list_empty(&qsd->qsd_link)) {
418 LASSERT(qsd->qsd_fsinfo != NULL);
419 cfs_down(&qsd->qsd_fsinfo->qfs_sem);
420 cfs_list_del_init(&qsd->qsd_link);
421 cfs_up(&qsd->qsd_fsinfo->qfs_sem);
424 /* remove qsd proc entry */
425 if (qsd->qsd_proc != NULL) {
426 lprocfs_remove(&qsd->qsd_proc);
427 qsd->qsd_proc = NULL;
430 /* stop the writeback thread */
431 qsd_stop_upd_thread(qsd);
433 /* shutdown the reintegration threads */
434 for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) {
435 if (qsd->qsd_type_array[qtype] == NULL)
437 qsd_stop_reint_thread(qsd->qsd_type_array[qtype]);
440 /* release reference on namespace */
441 if (qsd->qsd_ns != NULL) {
442 ldlm_namespace_put(qsd->qsd_ns);
446 /* free per-quota type data */
447 for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++)
448 qsd_qtype_fini(env, qsd, qtype);
450 /* deregister connection to the quota master */
451 qsd->qsd_exp_valid = false;
452 lustre_deregister_osp_item(&qsd->qsd_exp);
454 /* release per-filesystem information */
455 if (qsd->qsd_fsinfo != NULL)
456 qsd_put_fsinfo(qsd->qsd_fsinfo);
458 /* release quota root directory */
459 if (qsd->qsd_root != NULL) {
460 lu_object_put(env, &qsd->qsd_root->do_lu);
461 qsd->qsd_root = NULL;
464 /* release reference on dt_device */
465 if (qsd->qsd_dev != NULL) {
466 lu_ref_del(&qsd->qsd_dev->dd_lu_dev.ld_reference, "qsd", qsd);
467 lu_device_put(&qsd->qsd_dev->dd_lu_dev);
471 CDEBUG(D_QUOTA, "%s: QSD shutdown completed\n", qsd->qsd_svname);
475 EXPORT_SYMBOL(qsd_fini);
478 * Create a new qsd_instance to be associated with backend osd device
479 * identified by \dev.
481 * \param env - the environment passed by the caller
482 * \param svname - is the service name of the OSD device creating this instance
483 * \param dev - is the dt_device where to store quota index files
484 * \param osd_proc - is the procfs parent directory where to create procfs file
485 * related to this new qsd instance
487 * \retval - pointer to new qsd_instance associated with dev \dev on success,
488 * appropriate error on failure
490 struct qsd_instance *qsd_init(const struct lu_env *env, char *svname,
491 struct dt_device *dev,
492 cfs_proc_dir_entry_t *osd_proc)
494 struct qsd_thread_info *qti = qsd_info(env);
495 struct qsd_instance *qsd;
499 /* only configure qsd for MDT & OST */
500 type = server_name2index(svname, &idx, NULL);
501 if (type != LDD_F_SV_TYPE_MDT && type != LDD_F_SV_TYPE_OST)
504 /* allocate qsd instance */
507 RETURN(ERR_PTR(-ENOMEM));
509 /* generic initializations */
510 cfs_rwlock_init(&qsd->qsd_lock);
511 CFS_INIT_LIST_HEAD(&qsd->qsd_link);
512 thread_set_flags(&qsd->qsd_upd_thread, SVC_STOPPED);
513 cfs_waitq_init(&qsd->qsd_upd_thread.t_ctl_waitq);
514 CFS_INIT_LIST_HEAD(&qsd->qsd_upd_list);
515 cfs_spin_lock_init(&qsd->qsd_adjust_lock);
516 CFS_INIT_LIST_HEAD(&qsd->qsd_adjust_list);
517 qsd->qsd_prepared = false;
518 qsd->qsd_started = false;
520 /* copy service name */
521 strncpy(qsd->qsd_svname, svname, MAX_OBD_NAME);
523 /* grab reference on osd device */
524 lu_device_get(&dev->dd_lu_dev);
525 lu_ref_add(&dev->dd_lu_dev.ld_reference, "qsd", qsd);
528 /* we only support pool ID 0 (default data or metadata pool) for the
529 * time being. A different pool ID could be assigned to this target via
530 * the configuration log in the future */
531 qsd->qsd_pool_id = 0;
533 /* get fsname from svname */
534 rc = server_name2fsname(svname, qti->qti_buf, NULL);
536 CERROR("%s: fail to extract filesystem name\n", svname);
540 /* look up quota setting for the filesystem the target belongs to */
541 qsd->qsd_fsinfo = qsd_get_fsinfo(qti->qti_buf, 1);
542 if (qsd->qsd_fsinfo == NULL) {
543 CERROR("%s: failed to locate filesystem information\n", svname);
544 GOTO(out, rc = -EINVAL);
547 /* add in the list of lquota_fsinfo */
548 cfs_down(&qsd->qsd_fsinfo->qfs_sem);
549 list_add_tail(&qsd->qsd_link, &qsd->qsd_fsinfo->qfs_qsd_list);
550 cfs_up(&qsd->qsd_fsinfo->qfs_sem);
552 /* register procfs directory */
553 qsd->qsd_proc = lprocfs_register(QSD_DIR, osd_proc,
554 lprocfs_quota_qsd_vars, qsd);
555 if (IS_ERR(qsd->qsd_proc)) {
556 rc = PTR_ERR(qsd->qsd_proc);
557 qsd->qsd_proc = NULL;
558 CERROR("%s: fail to create quota slave proc entry (%d)\n",
570 EXPORT_SYMBOL(qsd_init);
573 * Initialize on-disk structures in order to manage quota enforcement for
574 * the target associated with the qsd instance \qsd and starts the reintegration
575 * procedure for each quota type as soon as possible.
576 * The last step of the reintegration will be completed once qsd_start() is
577 * called, at which points the space reconciliation with the master will be
579 * This function must be called when the server stack is fully configured,
580 * typically when ->ldo_prepare is called across the stack.
582 * \param env - the environment passed by the caller
583 * \param qsd - is qsd_instance to prepare
585 * \retval - 0 on success, appropriate error on failure
587 int qsd_prepare(const struct lu_env *env, struct qsd_instance *qsd)
589 struct qsd_thread_info *qti = qsd_info(env);
593 if (unlikely(qsd == NULL))
596 cfs_read_lock(&qsd->qsd_lock);
597 if (qsd->qsd_prepared) {
598 CERROR("%s: qsd instance already prepared\n", qsd->qsd_svname);
601 cfs_read_unlock(&qsd->qsd_lock);
605 /* Record whether this qsd instance is managing quota enforcement for a
606 * MDT (i.e. inode quota) or OST (block quota) */
607 if (lu_device_is_md(qsd->qsd_dev->dd_lu_dev.ld_site->ls_top_dev)) {
608 qsd->qsd_is_md = true;
609 qsd->qsd_sync_threshold = LQUOTA_LEAST_QUNIT(LQUOTA_RES_MD);
611 qsd->qsd_sync_threshold = LQUOTA_LEAST_QUNIT(LQUOTA_RES_DT);
614 /* look-up on-disk directory for the quota slave */
615 qsd->qsd_root = lquota_disk_dir_find_create(env, qsd->qsd_dev, NULL,
617 if (IS_ERR(qsd->qsd_root)) {
618 rc = PTR_ERR(qsd->qsd_root);
619 qsd->qsd_root = NULL;
620 CERROR("%s: failed to create quota slave root dir (%d)\n",
621 qsd->qsd_svname, rc);
625 /* initialize per-quota type data */
626 for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) {
627 rc = qsd_qtype_init(env, qsd, qtype);
632 /* pools successfully setup, mark the qsd as prepared */
633 cfs_write_lock(&qsd->qsd_lock);
634 qsd->qsd_prepared = true;
635 cfs_write_unlock(&qsd->qsd_lock);
637 /* start reintegration thread for each type, if required */
638 for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) {
639 struct qsd_qtype_info *qqi = qsd->qsd_type_array[qtype];
641 rc = qsd_start_reint_thread(qqi);
643 CERROR("%s: failed to start reint thread for type %s "
644 "(%d)\n", qsd->qsd_svname, QTYPE_NAME(qtype),
650 /* start writeback thread */
651 rc = qsd_start_upd_thread(qsd);
653 CERROR("%s: failed to start writeback thread (%d)\n",
654 qsd->qsd_svname, rc);
658 /* generate osp name */
659 rc = tgt_name2ospname((char *)qsd->qsd_svname, qti->qti_buf);
661 CERROR("%s: failed to generate ospname (%d)\n",
662 qsd->qsd_svname, rc);
666 /* the connection callback will start the reintegration
667 * procedure if quota is enabled */
668 rc = lustre_register_osp_item(qti->qti_buf, &qsd->qsd_exp,
669 qsd_conn_callback, (void *)qsd);
671 CERROR("%s: fail to get connection to master (%d)\n",
672 qsd->qsd_svname, rc);
678 EXPORT_SYMBOL(qsd_prepare);
681 * Start a qsd instance. This will complete the last step of the reintegration
682 * procedure as soon as possible (provided that the master is reachable).
683 * This should be called when recovery has been completed and quota should now
684 * be enforced on every operations.
686 * \param env - the environment passed by the caller
687 * \param qsd - is the qsd instance associated with the osd device to start
689 int qsd_start(const struct lu_env *env, struct qsd_instance *qsd)
694 if (unlikely(qsd == NULL))
697 cfs_write_lock(&qsd->qsd_lock);
698 if (!qsd->qsd_prepared) {
699 CERROR("%s: can't start qsd instance since it was properly "
700 "initialized\n", qsd->qsd_svname);
702 } else if (qsd->qsd_started) {
703 CERROR("%s: qsd instance already started\n", qsd->qsd_svname);
706 /* notify that the qsd_instance is now started */
707 qsd->qsd_started = true;
709 cfs_write_unlock(&qsd->qsd_lock);
714 /* Trigger the 3rd step of reintegration: If usage > granted, acquire
715 * up to usage; If usage < granted, release down to usage. */
716 for (type = USRQUOTA; type < MAXQUOTAS; type++) {
717 struct qsd_qtype_info *qqi = qsd->qsd_type_array[type];
718 cfs_waitq_signal(&qqi->qqi_reint_thread.t_ctl_waitq);
723 EXPORT_SYMBOL(qsd_start);
725 void lustre_register_quota_process_config(int (*qpc)(struct lustre_cfg *lcfg));
728 * Global initialization performed at module load time
730 int qsd_glb_init(void)
734 rc = lu_kmem_init(qsd_caches);
738 qsd_key_init_generic(&qsd_thread_key, NULL);
739 lu_context_key_register(&qsd_thread_key);
740 lustre_register_quota_process_config(qsd_process_config);
746 * Companion of qsd_glb_init() called at module unload time
748 void qsd_glb_fini(void)
750 lustre_register_quota_process_config(NULL);
751 lu_kmem_fini(qsd_caches);
752 lu_context_key_degister(&qsd_thread_key);