From: Josef Bacik <josef@toxicpanda.com>
To: kernel-team@fb.com, axboe@kernel.dk, linux-block@vger.kernel.org
Subject: [PATCH] block: allow us to change max_segments on the fly
Date: Mon, 3 Apr 2017 15:13:18 -0400 [thread overview]
Message-ID: <1491246798-1774-1-git-send-email-jbacik@fb.com> (raw)
For things like NBD we want to be able to experiment with different
sized requests going over the wire. Half of our limit is controled by
max_sectors_kb, but the other half is how many bvec's we can cram into a
request, which is controlled by max_segments. Changing this sysfs knob
to be writeable allows us to be able to control our io limits more
precisely.
Signed-off-by: Josef Bacik <jbacik@fb.com>
---
block/blk-sysfs.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 4585426..e7db3f8 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -116,6 +116,19 @@ static ssize_t queue_max_sectors_show(struct request_queue *q, char *page)
return queue_var_show(max_sectors_kb, (page));
}
+static ssize_t queue_max_segments_store(struct request_queue *q,
+ const char *page, size_t count)
+{
+ unsigned long max_segments;
+ ssize_t ret = queue_var_store(&max_segments, page, count);
+
+ if (ret < 0)
+ return ret;
+
+ q->limits.max_segments = (short)max_segments;
+ return ret;
+}
+
static ssize_t queue_max_segments_show(struct request_queue *q, char *page)
{
return queue_var_show(queue_max_segments(q), (page));
@@ -527,8 +540,9 @@ static struct queue_sysfs_entry queue_max_hw_sectors_entry = {
};
static struct queue_sysfs_entry queue_max_segments_entry = {
- .attr = {.name = "max_segments", .mode = S_IRUGO },
+ .attr = {.name = "max_segments", .mode = S_IRUGO | S_IWUSR },
.show = queue_max_segments_show,
+ .store = queue_max_segments_store,
};
static struct queue_sysfs_entry queue_max_discard_segments_entry = {
--
2.7.4
next reply other threads:[~2017-04-03 19:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-03 19:13 Josef Bacik [this message]
2017-04-03 19:15 ` [PATCH] block: allow us to change max_segments on the fly Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1491246798-1774-1-git-send-email-jbacik@fb.com \
--to=josef@toxicpanda.com \
--cc=axboe@kernel.dk \
--cc=kernel-team@fb.com \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox