Whamcloud - gitweb
LU-14546 tests: set smbpasswd correctly
[fs/lustre-release.git] / lustre / osp / lproc_osp.c
index 2aa77f5..19a3e98 100644 (file)
@@ -55,11 +55,11 @@ static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
                                            dd_kobj);
        struct lu_device *lu = dt2lu_dev(dt);
        struct obd_device *obd = lu->ld_obd;
+       struct obd_import *imp;
        int rc;
 
-       LPROCFS_CLIMP_CHECK(obd);
-       rc = sprintf(buf, "%d\n", !obd->u.cli.cl_import->imp_deactive);
-       LPROCFS_CLIMP_EXIT(obd);
+       with_imp_locked(obd, imp, rc)
+               rc = sprintf(buf, "%d\n", !imp->imp_deactive);
        return rc;
 }
 
@@ -80,6 +80,7 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
                                            dd_kobj);
        struct lu_device *lu = dt2lu_dev(dt);
        struct obd_device *obd = lu->ld_obd;
+       struct obd_import *imp, *imp0;
        bool val;
        int rc;
 
@@ -87,16 +88,20 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
        if (rc)
                return rc;
 
-       LPROCFS_CLIMP_CHECK(obd);
+       with_imp_locked(obd, imp0, rc)
+               imp = class_import_get(imp0);
+       if (rc)
+               return rc;
        /* opposite senses */
-       if (obd->u.cli.cl_import->imp_deactive == val)
-               rc = ptlrpc_set_import_active(obd->u.cli.cl_import, val);
+       if (imp->imp_deactive == val)
+               rc = ptlrpc_set_import_active(imp, val);
        else
                CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n",
                       (unsigned int)val);
 
-       LPROCFS_CLIMP_EXIT(obd);
-       return count;
+       class_import_put(imp);
+
+       return rc ?: count;
 }
 LUSTRE_RW_ATTR(active);
 
@@ -758,9 +763,7 @@ ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
        struct obd_device *obd = lu->ld_obd;
        int rc;
 
-       LPROCFS_CLIMP_CHECK(obd);
        rc = ptlrpc_obd_ping(obd);
-       LPROCFS_CLIMP_EXIT(obd);
 
        return rc;
 }
@@ -773,17 +776,18 @@ ssize_t osp_conn_uuid_show(struct kobject *kobj, struct attribute *attr,
                                            dd_kobj);
        struct lu_device *lu = dt2lu_dev(dt);
        struct obd_device *obd = lu->ld_obd;
+       struct obd_import *imp;
        struct ptlrpc_connection *conn;
        ssize_t count;
 
-       LPROCFS_CLIMP_CHECK(obd);
-       conn = obd->u.cli.cl_import->imp_connection;
-       if (conn && obd->u.cli.cl_import)
-               count = sprintf(buf, "%s\n", conn->c_remote_uuid.uuid);
-       else
-               count = sprintf(buf, "%s\n", "<none>");
+       with_imp_locked(obd, imp, count) {
+               conn = imp->imp_connection;
+               if (conn)
+                       count = sprintf(buf, "%s\n", conn->c_remote_uuid.uuid);
+               else
+                       count = sprintf(buf, "%s\n", "<none>");
+       }
 
-       LPROCFS_CLIMP_EXIT(obd);
        return count;
 }
 
@@ -794,7 +798,7 @@ LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, connect_flags);
 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, server_uuid);
 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, timeouts);
 
-LPROC_SEQ_FOPS_RW_TYPE(osp, import);
+LDEBUGFS_SEQ_FOPS_RW_TYPE(osp, import);
 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, state);
 
 /**
@@ -952,7 +956,7 @@ static ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
 }
 LUSTRE_WO_ATTR(force_sync);
 
-static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
+static struct ldebugfs_vars ldebugfs_osp_obd_vars[] = {
        { .name =       "connect_flags",
          .fops =       &osp_connect_flags_fops         },
        { .name =       "ost_server_uuid",
@@ -970,7 +974,7 @@ static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
        { NULL }
 };
 
-static struct lprocfs_vars lprocfs_osp_md_vars[] = {
+static struct ldebugfs_vars ldebugfs_osp_md_vars[] = {
        { .name =       "connect_flags",
          .fops =       &osp_connect_flags_fops         },
        { .name =       "mdt_server_uuid",
@@ -1059,10 +1063,10 @@ void osp_tunables_init(struct osp_device *osp)
 
        if (osp->opd_connect_mdt) {
                osp->opd_dt_dev.dd_ktype.default_attrs = osp_md_attrs;
-               obd->obd_vars = lprocfs_osp_md_vars;
+               obd->obd_debugfs_vars = ldebugfs_osp_md_vars;
        } else {
                osp->opd_dt_dev.dd_ktype.default_attrs = osp_obd_attrs;
-               obd->obd_vars = lprocfs_osp_obd_vars;
+               obd->obd_debugfs_vars = ldebugfs_osp_obd_vars;
        }
 
        rc = dt_tunables_init(&osp->opd_dt_dev, obd->obd_type, obd->obd_name,
@@ -1076,18 +1080,9 @@ void osp_tunables_init(struct osp_device *osp)
        /* Since we register the obd device with ptlrpc / sptlrpc we
         * have to register debugfs with obd_device
         */
-       obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
-                                                  obd->obd_type->typ_debugfs_entry,
-                                                  obd->obd_vars, obd);
-       if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
-               rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
-                                           : -ENOMEM;
-               CERROR("%s: error %d setting up debugfs\n",
-                      obd->obd_name, rc);
-               obd->obd_debugfs_entry = NULL;
-               dt_tunables_fini(&osp->opd_dt_dev);
-               return;
-       }
+       obd->obd_debugfs_entry = debugfs_create_dir(
+               obd->obd_name, obd->obd_type->typ_debugfs_entry);
+       ldebugfs_add_vars(obd->obd_debugfs_entry, obd->obd_debugfs_vars, obd);
 
        sptlrpc_lprocfs_cliobd_attach(obd);
        ptlrpc_lprocfs_register_obd(obd);