/* This sanity check is more of an insanity check; we can still
* hose a kernel by allowing the request history to grow too
- * far. */
- bufpages = (svc->srv_buf_size + PAGE_SIZE - 1) >>
+ * far. The roundup to the next power of two is an empirical way
+ * to take care that request buffer is allocated in Slab and thus
+ * will be upgraded */
+ bufpages = (roundup_pow_of_two(svc->srv_buf_size) + PAGE_SIZE - 1) >>
PAGE_SHIFT;
- if (val > totalram_pages/(2 * bufpages))
+ /* do not allow history to consume more than half max number of rqbds */
+ if ((svc->srv_nrqbds_max == 0 && val > totalram_pages/(2 * bufpages)) ||
+ val > svc->srv_nrqbds_max/2)
return -ERANGE;
spin_lock(&svc->srv_lock);
}
LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_history_max);
+static int
+ptlrpc_lprocfs_req_buffers_max_seq_show(struct seq_file *m, void *n)
+{
+ struct ptlrpc_service *svc = m->private;
+
+ seq_printf(m, "%d\n", svc->srv_nrqbds_max);
+ return 0;
+}
+
+static ssize_t
+ptlrpc_lprocfs_req_buffers_max_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
+{
+ struct seq_file *m = file->private_data;
+ struct ptlrpc_service *svc = m->private;
+ __s64 val;
+ int rc;
+
+ rc = lprocfs_str_to_s64(buffer, count, &val);
+ if (rc < 0)
+ return rc;
+
+ if (val < 0 || val > INT_MAX)
+ return -ERANGE;
+
+ if (val < svc->srv_nbuf_per_group)
+ return -ERANGE;
+
+ spin_lock(&svc->srv_lock);
+
+ svc->srv_nrqbds_max = (uint)val;
+
+ spin_unlock(&svc->srv_lock);
+
+ return count;
+}
+LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_buffers_max);
+
static ssize_t threads_min_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
for (i = 0; i < svc->srv_nbuf_per_group; i++) {
/* NB: another thread might have recycled enough rqbds, we
* need to make sure it wouldn't over-allocate, see LU-1212. */
- if (svcpt->scp_nrqbds_posted >= svc->srv_nbuf_per_group)
+ if (test_req_buffer_pressure ||
+ svcpt->scp_nrqbds_posted >= svc->srv_nbuf_per_group ||
+ (svc->srv_nrqbds_max != 0 &&
+ svcpt->scp_nrqbds_total > svc->srv_nrqbds_max))
break;
rqbd = ptlrpc_alloc_rqbd(svcpt);
/* buffer configuration */
service->srv_nbuf_per_group = test_req_buffer_pressure ?
1 : conf->psc_buf.bc_nbufs;
+ /* do not limit max number of rqbds by default */
+ service->srv_nrqbds_max = 0;
+
service->srv_max_req_size = conf->psc_buf.bc_req_max_size +
SPTLRPC_MAX_PAYLOAD;
service->srv_buf_size = conf->psc_buf.bc_buf_size;
*/
LASSERT(atomic_read(&rqbd->rqbd_req.rq_refcount) == 0);
if (svcpt->scp_nrqbds_posted >=
- svc->srv_nbuf_per_group &&
- !test_req_buffer_pressure) {
+ svc->srv_nbuf_per_group ||
+ (svc->srv_nrqbds_max != 0 &&
+ svcpt->scp_nrqbds_total > svc->srv_nrqbds_max) ||
+ test_req_buffer_pressure) {
/* like in ptlrpc_free_rqbd() */
svcpt->scp_nrqbds_total--;
OBD_FREE_LARGE(rqbd->rqbd_buffer,