X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fquota%2Fqmt_dev.c;h=fe6506597a9aec5c004cf11cef46bae4bd225f3c;hb=fe0e096567ba148d5690316d2bad2226c0cf70bf;hp=3563aebe783b3d5f1e4b6fa01eb7b42c58012929;hpb=9fb46705ae86aa2c0ac29427f0ff24f923560eb7;p=fs%2Flustre-release.git diff --git a/lustre/quota/qmt_dev.c b/lustre/quota/qmt_dev.c index 3563aeb..fe65065 100644 --- a/lustre/quota/qmt_dev.c +++ b/lustre/quota/qmt_dev.c @@ -21,7 +21,7 @@ * GPL HEADER END */ /* - * Copyright (c) 2012 Intel, Inc. + * Copyright (c) 2012, 2017, Intel Corporation. * Use is subject to license terms. * * Author: Johann Lombardi @@ -66,10 +66,6 @@ * mdt_quota_init() for more details. */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - #define DEBUG_SUBSYSTEM S_LQUOTA #include @@ -111,7 +107,8 @@ static struct lu_device *qmt_device_fini(const struct lu_env *env, } /* stop rebalance thread */ - qmt_stop_reba_thread(qmt); + if (!qmt->qmt_child->dd_rdonly) + qmt_stop_reba_thread(qmt); /* disconnect from OSD */ if (qmt->qmt_child_exp != NULL) { @@ -206,12 +203,17 @@ static int qmt_device_init0(const struct lu_env *env, struct qmt_device *qmt, struct lu_device *ld = qmt2lu_dev(qmt); struct obd_device *obd, *mdt_obd; struct obd_type *type; + char *svname = lustre_cfg_string(cfg, 0); int rc; ENTRY; + if (svname == NULL) + RETURN(-EINVAL); + /* record who i am, it might be useful ... */ - strncpy(qmt->qmt_svname, lustre_cfg_string(cfg, 0), - sizeof(qmt->qmt_svname) - 1); + rc = strlcpy(qmt->qmt_svname, svname, sizeof(qmt->qmt_svname)); + if (rc >= sizeof(qmt->qmt_svname)) + RETURN(-E2BIG); /* look-up the obd_device associated with the qmt */ obd = class_name2obd(qmt->qmt_svname); @@ -239,15 +241,17 @@ static int qmt_device_init0(const struct lu_env *env, struct qmt_device *qmt, GOTO(out, rc); /* set up and start rebalance thread */ - thread_set_flags(&qmt->qmt_reba_thread, SVC_STOPPED); - cfs_waitq_init(&qmt->qmt_reba_thread.t_ctl_waitq); - CFS_INIT_LIST_HEAD(&qmt->qmt_reba_list); + thread_set_flags(&qmt->qmt_reba_thread, SVC_STARTING); + init_waitqueue_head(&qmt->qmt_reba_thread.t_ctl_waitq); + INIT_LIST_HEAD(&qmt->qmt_reba_list); spin_lock_init(&qmt->qmt_reba_lock); - rc = qmt_start_reba_thread(qmt); - if (rc) { - CERROR("%s: failed to start rebalance thread (%d)\n", - qmt->qmt_svname, rc); - GOTO(out, rc); + if (!qmt->qmt_child->dd_rdonly) { + rc = qmt_start_reba_thread(qmt); + if (rc) { + CERROR("%s: failed to start rebalance thread (%d)\n", + qmt->qmt_svname, rc); + GOTO(out, rc); + } } /* at the moment there is no linkage between lu_type and obd_type, so @@ -451,7 +455,7 @@ static int qmt_device_prepare(const struct lu_env *env, /* initialize on-disk indexes associated with each pool */ rc = qmt_pool_prepare(env, qmt, qmt_root); - lu_object_put(env, &qmt_root->do_lu); + dt_object_put(env, qmt_root); RETURN(rc); } @@ -470,8 +474,8 @@ int qmt_glb_init(void) int rc; ENTRY; - rc = class_register_type(&qmt_obd_ops, NULL, NULL, LUSTRE_QMT_NAME, - &qmt_device_type); + rc = class_register_type(&qmt_obd_ops, NULL, true, NULL, + LUSTRE_QMT_NAME, &qmt_device_type); RETURN(rc); }