Whamcloud - gitweb
LU-17592 build: kernel 6.8 removed strlcpy()
[fs/lustre-release.git] / lustre / quota / qmt_dev.c
index 25684fd..3126355 100644 (file)
@@ -97,6 +97,11 @@ static struct lu_device *qmt_device_fini(const struct lu_env *env,
        CDEBUG(D_QUOTA, "%s: initiating QMT shutdown\n", qmt->qmt_svname);
        qmt->qmt_stopping = true;
 
+       if (qmt_lvbo_free_wq) {
+               destroy_workqueue(qmt_lvbo_free_wq);
+               qmt_lvbo_free_wq = NULL;
+       }
+
        /* kill pool instances, if any */
        qmt_pool_fini(env, qmt);
 
@@ -107,7 +112,13 @@ 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);
+
+       if (qmt->qmt_root) {
+               dt_object_put(env, qmt->qmt_root);
+               qmt->qmt_root = NULL;
+       }
 
        /* disconnect from OSD */
        if (qmt->qmt_child_exp != NULL) {
@@ -210,9 +221,9 @@ static int qmt_device_init0(const struct lu_env *env, struct qmt_device *qmt,
                RETURN(-EINVAL);
 
        /* record who i am, it might be useful ... */
-       rc = strlcpy(qmt->qmt_svname, svname, sizeof(qmt->qmt_svname));
-       if (rc >= sizeof(qmt->qmt_svname))
-               RETURN(-E2BIG);
+       rc = strscpy(qmt->qmt_svname, svname, sizeof(qmt->qmt_svname));
+       if (rc < 0)
+               RETURN(rc);
 
        /* look-up the obd_device associated with the qmt */
        obd = class_name2obd(qmt->qmt_svname);
@@ -240,8 +251,6 @@ 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);
-       init_waitqueue_head(&qmt->qmt_reba_thread.t_ctl_waitq);
        INIT_LIST_HEAD(&qmt->qmt_reba_list);
        spin_lock_init(&qmt->qmt_reba_lock);
        if (!qmt->qmt_child->dd_rdonly) {
@@ -258,6 +267,9 @@ static int qmt_device_init0(const struct lu_env *env, struct qmt_device *qmt,
        type = class_search_type(LUSTRE_QMT_NAME);
        LASSERT(type != NULL);
 
+       /* put reference taken by class_search_type */
+       kobject_put(&type->typ_kobj);
+
        /* register proc directory associated with this qmt */
        qmt->qmt_proc = lprocfs_register(qmt->qmt_svname, type->typ_procroot,
                                         NULL, NULL);
@@ -272,6 +284,15 @@ static int qmt_device_init0(const struct lu_env *env, struct qmt_device *qmt,
        rc = qmt_pool_init(env, qmt);
        if (rc)
                GOTO(out, rc);
+
+       qmt_lvbo_free_wq = alloc_workqueue("qmt_lvbo_free", WQ_UNBOUND, 0);
+       if (!qmt_lvbo_free_wq) {
+               rc = -ENOMEM;
+               CERROR("%s: failed to start qmt_lvbo_free workqueue: rc = %d\n",
+                      qmt->qmt_svname, rc);
+               goto out;
+       }
+
        EXIT;
 out:
        if (rc)
@@ -347,7 +368,7 @@ LU_CONTEXT_KEY_DEFINE(qmt, LCT_MD_THREAD);
 /*
  * lu device type operations associated with the master target.
  */
-static struct lu_device_type_operations qmt_device_type_ops = {
+static const struct lu_device_type_operations qmt_device_type_ops = {
        .ldto_init              = qmt_type_init,
        .ldto_fini              = qmt_type_fini,
 
@@ -415,10 +436,14 @@ static int qmt_device_obd_disconnect(struct obd_export *exp)
 /*
  * obd device operations associated with the master target.
  */
-struct obd_ops qmt_obd_ops = {
+static const struct obd_ops qmt_obd_ops = {
        .o_owner        = THIS_MODULE,
        .o_connect      = qmt_device_obd_connect,
        .o_disconnect   = qmt_device_obd_disconnect,
+       .o_pool_new     = qmt_pool_new,
+       .o_pool_rem     = qmt_pool_rem,
+       .o_pool_add     = qmt_pool_add,
+       .o_pool_del     = qmt_pool_del,
 };
 
 /*
@@ -451,10 +476,9 @@ static int qmt_device_prepare(const struct lu_env *env,
                RETURN(rc);
        }
 
+       qmt->qmt_root = qmt_root;
        /* initialize on-disk indexes associated with each pool */
-       rc = qmt_pool_prepare(env, qmt, qmt_root);
-
-       dt_object_put(env, qmt_root);
+       rc = qmt_pool_prepare(env, qmt, qmt_root, NULL);
        RETURN(rc);
 }
 
@@ -473,7 +497,7 @@ int qmt_glb_init(void)
        int rc;
        ENTRY;
 
-       rc = class_register_type(&qmt_obd_ops, NULL, true, NULL,
+       rc = class_register_type(&qmt_obd_ops, NULL, true,
                                 LUSTRE_QMT_NAME, &qmt_device_type);
        RETURN(rc);
 }