Whamcloud - gitweb
LU-8066 sysfs: make ping sysfs file read and writable
[fs/lustre-release.git] / lustre / osc / lproc_osc.c
index 463c179..727e930 100644 (file)
@@ -186,9 +186,10 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj,
 }
 LUSTRE_RW_ATTR(max_dirty_mb);
 
+LUSTRE_ATTR(ost_conn_uuid, 0444, conn_uuid_show, NULL);
 LUSTRE_RO_ATTR(conn_uuid);
 
-LUSTRE_WO_ATTR(ping);
+LUSTRE_RW_ATTR(ping);
 
 static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
 {
@@ -630,24 +631,35 @@ static ssize_t idle_timeout_store(struct kobject *kobj, struct attribute *attr,
                                              obd_kset.kobj);
        struct client_obd *cli = &dev->u.cli;
        struct ptlrpc_request *req;
+       unsigned int idle_debug = 0;
        unsigned int val;
        int rc;
 
-       rc = kstrtouint(buffer, 10, &val);
-       if (rc)
-               return rc;
+       if (strncmp(buffer, "debug", 5) == 0) {
+               idle_debug = D_CONSOLE;
+       } else if (strncmp(buffer, "nodebug", 6) == 0) {
+               idle_debug = D_HA;
+       } else {
+               rc = kstrtouint(buffer, 10, &val);
+               if (rc)
+                       return rc;
 
-       if (val > CONNECTION_SWITCH_MAX)
-               return -ERANGE;
+               if (val > CONNECTION_SWITCH_MAX)
+                       return -ERANGE;
+       }
 
        LPROCFS_CLIMP_CHECK(dev);
-       cli->cl_import->imp_idle_timeout = val;
-
-       /* to initiate the connection if it's in IDLE state */
-       if (!val) {
-               req = ptlrpc_request_alloc(cli->cl_import, &RQF_OST_STATFS);
-               if (req != NULL)
-                       ptlrpc_req_finished(req);
+       if (idle_debug) {
+               cli->cl_import->imp_idle_debug = idle_debug;
+       } else {
+               if (!val) {
+                       /* initiate the connection if it's in IDLE state */
+                       req = ptlrpc_request_alloc(cli->cl_import,
+                                                  &RQF_OST_STATFS);
+                       if (req != NULL)
+                               ptlrpc_req_finished(req);
+               }
+               cli->cl_import->imp_idle_timeout = val;
        }
        LPROCFS_CLIMP_EXIT(dev);
 
@@ -769,8 +781,6 @@ struct lprocfs_vars lprocfs_osc_obd_vars[] = {
        { NULL }
 };
 
-#define pct(a,b) (b ? a * 100 / b : 0)
-
 static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
 {
        struct timespec64 now;
@@ -809,7 +819,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
 
                read_cum += r;
                write_cum += w;
-               seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n",
+               seq_printf(seq, "%d:\t\t%10lu %3u %3u   | %10lu %3u %3u\n",
                           1 << i, r, pct(r, read_tot),
                           pct(read_cum, read_tot), w,
                           pct(w, write_tot),
@@ -832,7 +842,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
                 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
                 read_cum += r;
                 write_cum += w;
-               seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n",
+               seq_printf(seq, "%d:\t\t%10lu %3u %3u   | %10lu %3u %3u\n",
                           i, r, pct(r, read_tot),
                           pct(read_cum, read_tot), w,
                           pct(w, write_tot),
@@ -855,10 +865,10 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
                 unsigned long w = cli->cl_write_offset_hist.oh_buckets[i];
                 read_cum += r;
                 write_cum += w;
-                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n",
-                           (i == 0) ? 0 : 1 << (i - 1),
-                           r, pct(r, read_tot), pct(read_cum, read_tot),
-                           w, pct(w, write_tot), pct(write_cum, write_tot));
+               seq_printf(seq, "%d:\t\t%10lu %3u %3u   | %10lu %3u %3u\n",
+                          (i == 0) ? 0 : 1 << (i - 1),
+                          r, pct(r, read_tot), pct(read_cum, read_tot),
+                          w, pct(w, write_tot), pct(write_cum, write_tot));
                 if (read_cum == read_tot && write_cum == write_tot)
                         break;
         }
@@ -867,7 +877,6 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
 
         return 0;
 }
-#undef pct
 
 static ssize_t osc_rpc_stats_seq_write(struct file *file,
                                       const char __user *buf,
@@ -949,6 +958,7 @@ static struct attribute *osc_attrs[] = {
        &lustre_attr_max_rpcs_in_flight.attr,
        &lustre_attr_short_io_bytes.attr,
        &lustre_attr_resend_count.attr,
+       &lustre_attr_ost_conn_uuid.attr,
        &lustre_attr_conn_uuid.attr,
        &lustre_attr_ping.attr,
        &lustre_attr_idle_timeout.attr,