+ with_imp_locked(obd, imp, rc) {
+ if (idle_debug) {
+ imp->imp_idle_debug = idle_debug;
+ } else {
+ if (!val) {
+ /* initiate the connection if it's in IDLE state */
+ req = ptlrpc_request_alloc(imp,
+ &RQF_OST_STATFS);
+ if (req != NULL)
+ ptlrpc_req_finished(req);
+ }
+ imp->imp_idle_timeout = val;
+ }
+ }
+
+ return count;
+}
+LUSTRE_RW_ATTR(idle_timeout);
+
+static ssize_t idle_connect_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
+{
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
+ struct obd_import *imp;
+ struct ptlrpc_request *req;
+ int rc;
+
+ with_imp_locked(obd, imp, rc) {
+ /* to initiate the connection if it's in IDLE state */
+ req = ptlrpc_request_alloc(imp, &RQF_OST_STATFS);
+ if (req)
+ ptlrpc_req_finished(req);
+ ptlrpc_pinger_force(imp);
+ }
+
+ return rc ?: count;
+}
+LUSTRE_WO_ATTR(idle_connect);
+
+static ssize_t grant_shrink_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
+ struct obd_import *imp;
+ ssize_t len;
+
+ with_imp_locked(obd, imp, len)
+ len = scnprintf(buf, PAGE_SIZE, "%d\n",
+ !imp->imp_grant_shrink_disabled &&
+ OCD_HAS_FLAG(&imp->imp_connect_data,
+ GRANT_SHRINK));
+
+ return len;
+}
+
+static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
+{
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
+ struct obd_import *imp;
+ bool val;
+ int rc;
+
+ if (obd == NULL)
+ return 0;
+
+ rc = kstrtobool(buffer, &val);
+ if (rc)
+ return rc;
+
+ with_imp_locked(obd, imp, rc) {
+ spin_lock(&imp->imp_lock);
+ imp->imp_grant_shrink_disabled = !val;
+ spin_unlock(&imp->imp_lock);
+ }
+
+ return rc ?: count;
+}
+LUSTRE_RW_ATTR(grant_shrink);
+
+LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
+LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
+LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
+LPROC_SEQ_FOPS_RO_TYPE(osc, state);
+
+LPROC_SEQ_FOPS_RW_TYPE(osc, import);
+LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
+
+struct lprocfs_vars lprocfs_osc_obd_vars[] = {
+ { .name = "connect_flags",
+ .fops = &osc_connect_flags_fops },
+ { .name = "ost_server_uuid",
+ .fops = &osc_server_uuid_fops },
+ { .name = "max_pages_per_rpc",
+ .fops = &osc_obd_max_pages_per_rpc_fops },
+ { .name = "osc_cached_mb",
+ .fops = &osc_cached_mb_fops },
+ { .name = "cur_grant_bytes",
+ .fops = &osc_cur_grant_bytes_fops },
+ { .name = "checksum_type",
+ .fops = &osc_checksum_type_fops },
+ { .name = "timeouts",
+ .fops = &osc_timeouts_fops },
+ { .name = "import",
+ .fops = &osc_import_fops },
+ { .name = "state",
+ .fops = &osc_state_fops },
+ { .name = "pinger_recov",
+ .fops = &osc_pinger_recov_fops },
+ { .name = "unstable_stats",
+ .fops = &osc_unstable_stats_fops },
+ { NULL }
+};
+
+static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
+{
+ struct timespec64 now;
+ struct obd_device *obd = seq->private;
+ struct client_obd *cli = &obd->u.cli;
+ unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
+ int i;
+
+ ktime_get_real_ts64(&now);
+
+ spin_lock(&cli->cl_loi_list_lock);
+
+ seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
+ (s64)now.tv_sec, now.tv_nsec);
+ seq_printf(seq, "read RPCs in flight: %d\n",
+ cli->cl_r_in_flight);
+ seq_printf(seq, "write RPCs in flight: %d\n",
+ cli->cl_w_in_flight);
+ seq_printf(seq, "pending write pages: %d\n",
+ atomic_read(&cli->cl_pending_w_pages));
+ seq_printf(seq, "pending read pages: %d\n",
+ atomic_read(&cli->cl_pending_r_pages));
+
+ seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
+ seq_printf(seq, "pages per rpc rpcs %% cum %% |");
+ seq_printf(seq, " rpcs %% cum %%\n");
+
+ read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist);
+ write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist);
+
+ read_cum = 0;
+ write_cum = 0;
+ for (i = 0; i < OBD_HIST_MAX; i++) {
+ unsigned long r = cli->cl_read_page_hist.oh_buckets[i];
+ unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
+
+ read_cum += r;
+ write_cum += w;
+ 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),
+ pct(write_cum, write_tot));
+ if (read_cum == read_tot && write_cum == write_tot)
+ break;
+ }
+
+ seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
+ seq_printf(seq, "rpcs in flight rpcs %% cum %% |");
+ seq_printf(seq, " rpcs %% cum %%\n");
+
+ read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist);
+ write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist);