Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
LU-2360 ptlrpc: a few fixes for req_history read
[fs/lustre-release.git]
/
lustre
/
ptlrpc
/
lproc_ptlrpc.c
diff --git
a/lustre/ptlrpc/lproc_ptlrpc.c
b/lustre/ptlrpc/lproc_ptlrpc.c
index
50a981f
..
ab7d146
100644
(file)
--- a/
lustre/ptlrpc/lproc_ptlrpc.c
+++ b/
lustre/ptlrpc/lproc_ptlrpc.c
@@
-111,6
+111,7
@@
struct ll_rpc_opcode {
{ OBD_PING, "obd_ping" },
{ OBD_LOG_CANCEL, "llog_origin_handle_cancel" },
{ OBD_QC_CALLBACK, "obd_quota_callback" },
+ { OBD_IDX_READ, "dt_index_read" },
{ LLOG_ORIGIN_HANDLE_CREATE, "llog_origin_handle_create" },
{ LLOG_ORIGIN_HANDLE_NEXT_BLOCK, "llog_origin_handle_next_block" },
{ LLOG_ORIGIN_HANDLE_READ_HEADER,"llog_origin_handle_read_header" },
@@
-302,14
+303,14
@@
ptlrpc_lprocfs_write_req_history_max(struct file *file, const char *buffer,
if (val > cfs_num_physpages/(2 * bufpages))
return -ERANGE;
-
cfs_
spin_lock(&svc->srv_lock);
+ spin_lock(&svc->srv_lock);
if (val == 0)
svc->srv_hist_nrqbds_cpt_max = 0;
else
svc->srv_hist_nrqbds_cpt_max = max(1, (val / svc->srv_ncpts));
-
cfs_
spin_unlock(&svc->srv_lock);
+ spin_unlock(&svc->srv_lock);
return count;
}
@@
-338,15
+339,15
@@
ptlrpc_lprocfs_wr_threads_min(struct file *file, const char *buffer,
if (val / svc->srv_ncpts < PTLRPC_NTHRS_INIT)
return -ERANGE;
-
cfs_
spin_lock(&svc->srv_lock);
+ spin_lock(&svc->srv_lock);
if (val > svc->srv_nthrs_cpt_limit * svc->srv_ncpts) {
-
cfs_
spin_unlock(&svc->srv_lock);
+ spin_unlock(&svc->srv_lock);
return -ERANGE;
}
svc->srv_nthrs_cpt_init = val / svc->srv_ncpts;
-
cfs_
spin_unlock(&svc->srv_lock);
+ spin_unlock(&svc->srv_lock);
return count;
}
@@
-391,15
+392,15
@@
ptlrpc_lprocfs_wr_threads_max(struct file *file, const char *buffer,
if (val / svc->srv_ncpts < PTLRPC_NTHRS_INIT)
return -ERANGE;
-
cfs_
spin_lock(&svc->srv_lock);
+ spin_lock(&svc->srv_lock);
if (val < svc->srv_nthrs_cpt_init * svc->srv_ncpts) {
-
cfs_
spin_unlock(&svc->srv_lock);
+ spin_unlock(&svc->srv_lock);
return -ERANGE;
}
svc->srv_nthrs_cpt_limit = val / svc->srv_ncpts;
-
cfs_
spin_unlock(&svc->srv_lock);
+ spin_unlock(&svc->srv_lock);
return count;
}
@@
-427,7
+428,10
@@
ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service_part *svcpt,
* Since the service history is LRU (i.e. culled reqs will
* be near the head), we shouldn't have to do long
* re-scans */
- LASSERT (srhi->srhi_seq == srhi->srhi_req->rq_history_seq);
+ LASSERTF(srhi->srhi_seq == srhi->srhi_req->rq_history_seq,
+ "%s:%d: seek seq "LPU64", request seq "LPU64"\n",
+ svcpt->scp_service->srv_name, svcpt->scp_cpt,
+ srhi->srhi_seq, srhi->srhi_req->rq_history_seq);
LASSERTF(!cfs_list_empty(&svcpt->scp_hist_reqs),
"%s:%d: seek offset "LPU64", request seq "LPU64", "
"last culled "LPU64"\n",
@@
-453,15
+457,55
@@
ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service_part *svcpt,
return -ENOENT;
}
+/*
+ * ptlrpc history sequence is used as "position" of seq_file, in some case,
+ * seq_read() will increase "position" to indicate reading the next
+ * element, however, low bits of history sequence are reserved for CPT id
+ * (check the details from comments before ptlrpc_req_add_history), which
+ * means seq_read() might change CPT id of history sequence and never
+ * finish reading of requests on a CPT. To make it work, we have to shift
+ * CPT id to high bits and timestamp to low bits, so seq_read() will only
+ * increase timestamp which can correctly indicate the next position.
+ */
+
+/* convert seq_file pos to cpt */
+#define PTLRPC_REQ_POS2CPT(svc, pos) \
+ ((svc)->srv_cpt_bits == 0 ? 0 : \
+ (__u64)(pos) >> (64 - (svc)->srv_cpt_bits))
+
+/* make up seq_file pos from cpt */
+#define PTLRPC_REQ_CPT2POS(svc, cpt) \
+ ((svc)->srv_cpt_bits == 0 ? 0 : \
+ (cpt) << (64 - (svc)->srv_cpt_bits))
+
+/* convert sequence to position */
+#define PTLRPC_REQ_SEQ2POS(svc, seq) \
+ ((svc)->srv_cpt_bits == 0 ? (seq) : \
+ ((seq) >> (svc)->srv_cpt_bits) | \
+ ((seq) << (64 - (svc)->srv_cpt_bits)))
+
+/* convert position to sequence */
+#define PTLRPC_REQ_POS2SEQ(svc, pos) \
+ ((svc)->srv_cpt_bits == 0 ? (pos) : \
+ ((__u64)(pos) << (svc)->srv_cpt_bits) | \
+ ((__u64)(pos) >> (64 - (svc)->srv_cpt_bits)))
+
static void *
ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
{
struct ptlrpc_service *svc = s->private;
struct ptlrpc_service_part *svcpt;
struct ptlrpc_srh_iterator *srhi;
+ unsigned int cpt;
int rc;
int i;
+ if (sizeof(loff_t) != sizeof(__u64)) { /* can't support */
+ CWARN("Failed to read request history because size of loff_t "
+ "%d can't match size of u64\n", (int)sizeof(loff_t));
+ return NULL;
+ }
+
OBD_ALLOC(srhi, sizeof(*srhi));
if (srhi == NULL)
return NULL;
@@
-469,14
+513,21
@@
ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
srhi->srhi_seq = 0;
srhi->srhi_req = NULL;
- ptlrpc_service_for_each_part(svcpt, i, svc) {
- srhi->srhi_idx = i;
+ cpt = PTLRPC_REQ_POS2CPT(svc, *pos);
- cfs_spin_lock(&svcpt->scp_lock);
- rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi, *pos);
- cfs_spin_unlock(&svcpt->scp_lock);
+ ptlrpc_service_for_each_part(svcpt, i, svc) {
+ if (i < cpt) /* skip */
+ continue;
+ if (i > cpt) /* make up the lowest position for this CPT */
+ *pos = PTLRPC_REQ_CPT2POS(svc, i);
+
+ spin_lock(&svcpt->scp_lock);
+ rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi,
+ PTLRPC_REQ_POS2SEQ(svc, *pos));
+ spin_unlock(&svcpt->scp_lock);
if (rc == 0) {
- *pos = srhi->srhi_seq;
+ *pos = PTLRPC_REQ_SEQ2POS(svc, srhi->srhi_seq);
+ srhi->srhi_idx = i;
return srhi;
}
}
@@
-501,28
+552,32
@@
ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s,
struct ptlrpc_service *svc = s->private;
struct ptlrpc_srh_iterator *srhi = iter;
struct ptlrpc_service_part *svcpt;
- int rc = 0;
+ __u64 seq;
+ int rc;
int i;
for (i = srhi->srhi_idx; i < svc->srv_ncpts; i++) {
svcpt = svc->srv_parts[i];
- srhi->srhi_idx = i;
+ if (i > srhi->srhi_idx) { /* reset iterator for a new CPT */
+ srhi->srhi_req = NULL;
+ seq = srhi->srhi_seq = 0;
+ } else { /* the next sequence */
+ seq = srhi->srhi_seq + (1 << svc->srv_cpt_bits);
+ }
- cfs_spin_lock(&svcpt->scp_lock);
- rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi, *pos + 1);
- cfs_spin_unlock(&svcpt->scp_lock);
- if (rc == 0)
- break;
+ spin_lock(&svcpt->scp_lock);
+ rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi, seq);
+ spin_unlock(&svcpt->scp_lock);
+ if (rc == 0) {
+ *pos = PTLRPC_REQ_SEQ2POS(svc, srhi->srhi_seq);
+ srhi->srhi_idx = i;
+ return srhi;
+ }
}
- if (rc != 0) {
- OBD_FREE(srhi, sizeof(*srhi));
- return NULL;
- }
-
- *pos = srhi->srhi_seq;
- return srhi;
+ OBD_FREE(srhi, sizeof(*srhi));
+ return NULL;
}
/* common ost/mdt so_req_printer */
@@
-567,7
+622,7
@@
static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter)
svcpt = svc->srv_parts[srhi->srhi_idx];
-
cfs_
spin_lock(&svcpt->scp_lock);
+ spin_lock(&svcpt->scp_lock);
rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi, srhi->srhi_seq);
@@
-593,7
+648,7
@@
static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter)
svc->srv_ops.so_req_printer(s, srhi->srhi_req);
}
-
cfs_
spin_unlock(&svcpt->scp_lock);
+ spin_unlock(&svcpt->scp_lock);
return rc;
}
@@
-701,9
+756,9
@@
static int ptlrpc_lprocfs_wr_hp_ratio(struct file *file, const char *buffer,
if (val < 0)
return -ERANGE;
-
cfs_
spin_lock(&svc->srv_lock);
+ spin_lock(&svc->srv_lock);
svc->srv_hpreq_ratio = val;
-
cfs_
spin_unlock(&svc->srv_lock);
+ spin_unlock(&svc->srv_lock);
return count;
}
@@
-865,8
+920,8
@@
int lprocfs_wr_evict_client(struct file *file, const char *buffer,
* the proc entries under the being destroyed export{}, so I have
* to drop the lock at first here.
* - jay, jxiong@clusterfs.com */
- class_incref(obd, __FUNCTION__, cfs_current());
LPROCFS_EXIT();
+ class_incref(obd, __FUNCTION__, cfs_current());
if (strncmp(tmpbuf, "nid:", 4) == 0)
obd_export_evict_by_nid(obd, tmpbuf + 4);
@@
-875,8
+930,8
@@
int lprocfs_wr_evict_client(struct file *file, const char *buffer,
else
obd_export_evict_by_uuid(obd, tmpbuf);
+ class_decref(obd, __FUNCTION__, cfs_current());
LPROCFS_ENTRY();
- class_decref(obd, __FUNCTION__, cfs_current());
out:
OBD_FREE(kbuf, BUFLEN);
@@
-1008,12
+1063,12
@@
int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
return -ERANGE;
LPROCFS_CLIMP_CHECK(obd);
-
cfs_
spin_lock(&imp->imp_lock);
-
imp->imp_no_pinger_recover = !val;
-
cfs_
spin_unlock(&imp->imp_lock);
-
LPROCFS_CLIMP_EXIT(obd);
+ spin_lock(&imp->imp_lock);
+ imp->imp_no_pinger_recover = !val;
+ spin_unlock(&imp->imp_lock);
+ LPROCFS_CLIMP_EXIT(obd);
-
return count;
+ return count;
}
EXPORT_SYMBOL(lprocfs_wr_pinger_recov);