This patch fixed a couple of issues in AT proc read:
- calculate of buffer offset is wrong
- current lustre proc read must be less than one page
Signed-off-by: Liang Zhen <liang@whamcloud.com>
Change-Id: Ieef8ad458ca70a4146e0b61fbe8a32b35577ccdf
Reviewed-on: http://review.whamcloud.com/3365
Reviewed-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-by: wangdi <di.wang@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
-#define PTLRPC_AT_LINE_SIZE 128
-
/* See also lprocfs_rd_timeouts */
static int ptlrpc_lprocfs_rd_timeouts(char *page, char **start, off_t off,
int count, int *eof, void *data)
/* See also lprocfs_rd_timeouts */
static int ptlrpc_lprocfs_rd_timeouts(char *page, char **start, off_t off,
int count, int *eof, void *data)
unsigned int worst;
int nob = 0;
int rc = 0;
unsigned int worst;
int nob = 0;
int rc = 0;
int i;
LASSERT(svc->srv_parts != NULL);
int i;
LASSERT(svc->srv_parts != NULL);
rc += snprintf(page + rc, count - rc,
"adaptive timeouts off, using obd_timeout %u\n",
obd_timeout);
rc += snprintf(page + rc, count - rc,
"adaptive timeouts off, using obd_timeout %u\n",
obd_timeout);
- cpt = ((unsigned)off) / PTLRPC_AT_LINE_SIZE;
-
ptlrpc_service_for_each_part(svcpt, i, svc) {
ptlrpc_service_for_each_part(svcpt, i, svc) {
- if (i < cpt)
- continue;
-
cur = at_get(&svcpt->scp_at_estimate);
worst = svcpt->scp_at_estimate.at_worst_ever;
worstt = svcpt->scp_at_estimate.at_worst_time;
s2dhms(&ts, cfs_time_current_sec() - worstt);
cur = at_get(&svcpt->scp_at_estimate);
worst = svcpt->scp_at_estimate.at_worst_ever;
worstt = svcpt->scp_at_estimate.at_worst_time;
s2dhms(&ts, cfs_time_current_sec() - worstt);
- nob = snprintf(page + rc, count - rc,
+ nob = snprintf(page, count,
"%10s : cur %3u worst %3u (at %ld, "
DHMS_FMT" ago) ", "service",
cur, worst, worstt, DHMS_VARS(&ts));
"%10s : cur %3u worst %3u (at %ld, "
DHMS_FMT" ago) ", "service",
cur, worst, worstt, DHMS_VARS(&ts));
- nob += lprocfs_at_hist_helper(page, count, rc + nob,
- &svcpt->scp_at_estimate);
- LASSERT(nob < PTLRPC_AT_LINE_SIZE);
- /* fill the whole line with spaces, so we can locate
- * partition by offset on the next call... */
- memset(page + rc + nob, ' ', PTLRPC_AT_LINE_SIZE - nob);
- page[rc + PTLRPC_AT_LINE_SIZE - 1] = '\n';
- rc += PTLRPC_AT_LINE_SIZE;
-
- if (count - rc < PTLRPC_AT_LINE_SIZE)
+ nob = lprocfs_at_hist_helper(page, count, nob,
+ &svcpt->scp_at_estimate);
+ rc += nob;
+ page += nob;
+ count -= nob;
+
+ /*
+ * NB: for lustre proc read, the read count must be less
+ * than PAGE_SIZE, please see details in lprocfs_fops_read.
+ * It's unlikely that we exceed PAGE_SIZE at here because
+ * it means the service has more than 50 partitions.
+ */
+ if (count <= 0) {
+ CWARN("Can't fit AT information of %s in one page, "
+ "please contact with developer to fix this.\n",
+ svc->srv_name);
- if (i == svc->srv_ncpts - 1)
- *eof = 1;
-
}
static int ptlrpc_lprocfs_wr_hp_ratio(struct file *file, const char *buffer,
}
static int ptlrpc_lprocfs_wr_hp_ratio(struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, void *data)
{
struct ptlrpc_service *svc = data;
int rc;
{
struct ptlrpc_service *svc = data;
int rc;