Whamcloud - gitweb
LU-13065 tests: clean up runtests
[fs/lustre-release.git] / lustre / ptlrpc / sec_lproc.c
index 2ba29c4..2f06143 100644 (file)
@@ -69,16 +69,16 @@ static char *sec_flags2str(unsigned long flags, char *buf, int bufsize)
 
 static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v)
 {
-        struct obd_device *dev = seq->private;
-        struct client_obd *cli = &dev->u.cli;
-        struct ptlrpc_sec *sec = NULL;
-        char               str[32];
+       struct obd_device *obd = seq->private;
+       struct client_obd *cli = &obd->u.cli;
+       struct ptlrpc_sec *sec = NULL;
+       char               str[32];
 
-       LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
-               strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
-               strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0 ||
-               strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) == 0 ||
-               strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) == 0);
+       LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
+               strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
+               strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME) == 0 ||
+               strcmp(obd->obd_type->typ_name, LUSTRE_LWP_NAME) == 0 ||
+               strcmp(obd->obd_type->typ_name, LUSTRE_OSP_NAME) == 0);
 
         if (cli->cl_import)
                 sec = sptlrpc_import_sec_ref(cli->cl_import);
@@ -111,15 +111,15 @@ LPROC_SEQ_FOPS_RO(sptlrpc_info_lprocfs);
 
 static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v)
 {
-        struct obd_device *dev = seq->private;
-        struct client_obd *cli = &dev->u.cli;
-        struct ptlrpc_sec *sec = NULL;
+       struct obd_device *obd = seq->private;
+       struct client_obd *cli = &obd->u.cli;
+       struct ptlrpc_sec *sec = NULL;
 
-       LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
-               strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
-               strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0 ||
-               strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) == 0 ||
-               strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) == 0);
+       LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
+               strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
+               strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME) == 0 ||
+               strcmp(obd->obd_type->typ_name, LUSTRE_LWP_NAME) == 0 ||
+               strcmp(obd->obd_type->typ_name, LUSTRE_OSP_NAME) == 0);
 
         if (cli->cl_import)
                 sec = sptlrpc_import_sec_ref(cli->cl_import);
@@ -141,8 +141,8 @@ lprocfs_sptlrpc_sepol_seq_write(struct file *file, const char __user *buffer,
                                size_t count, void *data)
 {
        struct seq_file *seq = file->private_data;
-       struct obd_device *dev = seq->private;
-       struct client_obd *cli = &dev->u.cli;
+       struct obd_device *obd = seq->private;
+       struct client_obd *cli = &obd->u.cli;
        struct obd_import *imp = cli->cl_import;
        struct sepol_downcall_data *param;
        int size = sizeof(*param);
@@ -150,7 +150,7 @@ lprocfs_sptlrpc_sepol_seq_write(struct file *file, const char __user *buffer,
 
        if (count < size) {
                CERROR("%s: invalid data count = %lu, size = %d\n",
-                      dev->obd_name, (unsigned long) count, size);
+                      obd->obd_name, (unsigned long) count, size);
                return -EINVAL;
        }
 
@@ -159,20 +159,20 @@ lprocfs_sptlrpc_sepol_seq_write(struct file *file, const char __user *buffer,
                return -ENOMEM;
 
        if (copy_from_user(param, buffer, size)) {
-               CERROR("%s: bad sepol data\n", dev->obd_name);
+               CERROR("%s: bad sepol data\n", obd->obd_name);
                GOTO(out, rc = -EFAULT);
        }
 
        if (param->sdd_magic != SEPOL_DOWNCALL_MAGIC) {
                CERROR("%s: sepol downcall bad params\n",
-                      dev->obd_name);
+                      obd->obd_name);
                GOTO(out, rc = -EINVAL);
        }
 
        if (param->sdd_sepol_len == 0 ||
            param->sdd_sepol_len >= sizeof(imp->imp_sec->ps_sepol)) {
                CERROR("%s: invalid sepol data returned\n",
-                      dev->obd_name);
+                      obd->obd_name);
                GOTO(out, rc = -EINVAL);
        }
        rc = param->sdd_sepol_len; /* save sdd_sepol_len */
@@ -187,14 +187,14 @@ lprocfs_sptlrpc_sepol_seq_write(struct file *file, const char __user *buffer,
                return -ENOMEM;
 
        if (copy_from_user(param, buffer, size)) {
-               CERROR("%s: bad sepol data\n", dev->obd_name);
+               CERROR("%s: bad sepol data\n", obd->obd_name);
                GOTO(out, rc = -EFAULT);
        }
 
        spin_lock(&imp->imp_sec->ps_lock);
        snprintf(imp->imp_sec->ps_sepol, param->sdd_sepol_len + 1, "%s",
                 param->sdd_sepol);
-       imp->imp_sec->ps_sepol_mtime = param->sdd_sepol_mtime;
+       imp->imp_sec->ps_sepol_mtime = ktime_set(param->sdd_sepol_mtime, 0);
        spin_unlock(&imp->imp_sec->ps_lock);
 
 out:
@@ -205,43 +205,26 @@ out:
 }
 LPROC_SEQ_FOPS_WR_ONLY(srpc, sptlrpc_sepol);
 
-int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
+int sptlrpc_lprocfs_cliobd_attach(struct obd_device *obd)
 {
-       int     rc;
-
-       if (strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 &&
-           strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 &&
-           strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) != 0 &&
-           strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) != 0 &&
-           strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) != 0) {
+       if (strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 &&
+           strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 &&
+           strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME) != 0 &&
+           strcmp(obd->obd_type->typ_name, LUSTRE_LWP_NAME) != 0 &&
+           strcmp(obd->obd_type->typ_name, LUSTRE_OSP_NAME) != 0) {
                CERROR("can't register lproc for obd type %s\n",
-                      dev->obd_type->typ_name);
+                      obd->obd_type->typ_name);
                return -EINVAL;
        }
 
-       rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "srpc_info", 0444,
-                                &sptlrpc_info_lprocfs_fops, dev);
-       if (rc) {
-               CERROR("create proc entry srpc_info for %s: %d\n",
-                      dev->obd_name, rc);
-               return rc;
-       }
+       debugfs_create_file("srpc_info", 0444, obd->obd_debugfs_entry, obd,
+                           &sptlrpc_info_lprocfs_fops);
 
-       rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "srpc_contexts",
-                                0444, &sptlrpc_ctxs_lprocfs_fops, dev);
-       if (rc) {
-               CERROR("create proc entry srpc_contexts for %s: %d\n",
-                      dev->obd_name, rc);
-               return rc;
-       }
+       debugfs_create_file("srpc_contexts", 0444, obd->obd_debugfs_entry, obd,
+                           &sptlrpc_ctxs_lprocfs_fops);
 
-       rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "srpc_sepol",
-                                0200, &srpc_sptlrpc_sepol_fops, dev);
-       if (rc) {
-               CERROR("create proc entry srpc_sepol for %s: %d\n",
-                      dev->obd_name, rc);
-               return rc;
-       }
+       debugfs_create_file("srpc_sepol", 0200, obd->obd_debugfs_entry, obd,
+                           &srpc_sptlrpc_sepol_fops);
 
        return 0;
 }
@@ -258,25 +241,35 @@ static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
 struct dentry *sptlrpc_debugfs_dir;
 EXPORT_SYMBOL(sptlrpc_debugfs_dir);
 
+struct proc_dir_entry *sptlrpc_lprocfs_dir;
+EXPORT_SYMBOL(sptlrpc_lprocfs_dir);
+
 int sptlrpc_lproc_init(void)
 {
        int rc;
 
        LASSERT(sptlrpc_debugfs_dir == NULL);
 
-       sptlrpc_debugfs_dir = ldebugfs_register("sptlrpc", debugfs_lustre_root,
-                                               sptlrpc_lprocfs_vars, NULL);
-       if (IS_ERR_OR_NULL(sptlrpc_debugfs_dir)) {
-               rc = sptlrpc_debugfs_dir ? PTR_ERR(sptlrpc_debugfs_dir)
-                                        : -ENOMEM;
-               sptlrpc_debugfs_dir = NULL;
-               return rc;
+       sptlrpc_debugfs_dir = debugfs_create_dir("sptlrpc",
+                                                debugfs_lustre_root);
+       ldebugfs_add_vars(sptlrpc_debugfs_dir, sptlrpc_lprocfs_vars, NULL);
+
+       sptlrpc_lprocfs_dir = lprocfs_register("sptlrpc", proc_lustre_root,
+                                              NULL, NULL);
+       if (IS_ERR_OR_NULL(sptlrpc_lprocfs_dir)) {
+               rc = PTR_ERR(sptlrpc_lprocfs_dir);
+               rc = sptlrpc_lprocfs_dir ? PTR_ERR(sptlrpc_lprocfs_dir)
+                       : -ENOMEM;
+               sptlrpc_lprocfs_dir = NULL;
        }
        return 0;
 }
 
 void sptlrpc_lproc_fini(void)
 {
-       if (!IS_ERR_OR_NULL(sptlrpc_debugfs_dir))
-               ldebugfs_remove(&sptlrpc_debugfs_dir);
+       debugfs_remove_recursive(sptlrpc_debugfs_dir);
+       sptlrpc_debugfs_dir = NULL;
+
+       if (!IS_ERR_OR_NULL(sptlrpc_lprocfs_dir))
+               lprocfs_remove(&sptlrpc_lprocfs_dir);
 }