Whamcloud - gitweb
LU-8066 sysfs: make ping sysfs file read and writable
[fs/lustre-release.git] / lustre / ptlrpc / lproc_ptlrpc.c
index 8d081e2..4e009e0 100644 (file)
@@ -1309,8 +1309,8 @@ void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd)
 }
 EXPORT_SYMBOL(ptlrpc_lprocfs_unregister_obd);
 
-ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
-                  const char *buffer, size_t count)
+ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
+                 char *buffer)
 {
        struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
@@ -1329,36 +1329,17 @@ ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
        rc = ptlrpc_queue_wait(req);
        ptlrpc_req_finished(req);
 
-       RETURN(rc >= 0 ? count : rc);
+       RETURN(rc);
 }
-EXPORT_SYMBOL(ping_store);
+EXPORT_SYMBOL(ping_show);
 
-ssize_t
-lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
-                      size_t count, loff_t *off)
+/* kept for older verison of tools. */
+ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
+                  const char *buffer, size_t count)
 {
-       struct seq_file         *m = file->private_data;
-       struct obd_device       *obd = m->private;
-       struct ptlrpc_request   *req;
-       int                     rc;
-       ENTRY;
-
-       LPROCFS_CLIMP_CHECK(obd);
-       req = ptlrpc_prep_ping(obd->u.cli.cl_import);
-       LPROCFS_CLIMP_EXIT(obd);
-       if (req == NULL)
-               RETURN(-ENOMEM);
-
-       req->rq_send_state = LUSTRE_IMP_FULL;
-
-       rc = ptlrpc_queue_wait(req);
-
-       ptlrpc_req_finished(req);
-       if (rc >= 0)
-               RETURN(count);
-       RETURN(rc);
+       return ping_show(kobj, attr, (char *)buffer);
 }
-EXPORT_SYMBOL(lprocfs_ping_seq_write);
+EXPORT_SYMBOL(ping_store);
 
 /* Write the connection UUID to this file to attempt to connect to that node.
  * The connection UUID is a node's primary NID. For example,
@@ -1397,14 +1378,14 @@ lprocfs_import_seq_write(struct file *file, const char __user *buffer,
        uuid = kbuf + prefix_len;
        ptr = strstr(uuid, "::");
        if (ptr) {
-               __u32 inst;
-               char *endptr;
+               u32 inst;
+               int rc;
 
                *ptr = 0;
                do_reconn = 0;
                ptr += 2; /* Skip :: */
-               inst = simple_strtol(ptr, &endptr, 10);
-               if (*endptr) {
+               rc = kstrtouint(ptr, 10, &inst);
+               if (rc) {
                        CERROR("config: wrong instance # %s\n", ptr);
                } else if (inst != imp->imp_connect_data.ocd_instance) {
                        CDEBUG(D_INFO, "IR: %s is connecting to an obsoleted "