* [PATCH v2 0/2] fix wrong value when user modify nr_request by sysfs
@ 2017-09-21 15:16 weiping zhang
2017-09-21 15:17 ` [PATCH v2 1/2] blk-mq: fix nr_requests wrong value when modify it from sysfs weiping zhang
2017-09-21 15:17 ` [PATCH v2 2/2] blk-sysfs: return EINVAL when user modify nr_request less than BLKDEV_MIN_RQ weiping zhang
0 siblings, 2 replies; 7+ messages in thread
From: weiping zhang @ 2017-09-21 15:16 UTC (permalink / raw)
To: axboe; +Cc: linux-block
Hi Jens,
This is v2 of fixing nr_request.
v1 -> v2:
blk-mq: fix nr_requests wrong value when modify it from sysfs
this patch return -EINVAL when user write a value that's too large.
blk-sysfs: return EINVAL when user modify nr_request less than
BLKDEV_MIN_RQ
In order to keep same behavior with former patch, also return EINVAL
when user write a value less than BLKDEV_MIN_RQ
weiping zhang (2):
blk-mq: fix nr_requests wrong value when modify it from sysfs
blk-sysfs: return EINVAL when user modify nr_request less than
BLKDEV_MIN_RQ
block/blk-mq.c | 8 ++++++--
block/blk-sysfs.c | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
--
2.9.4
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2 1/2] blk-mq: fix nr_requests wrong value when modify it from sysfs 2017-09-21 15:16 [PATCH v2 0/2] fix wrong value when user modify nr_request by sysfs weiping zhang @ 2017-09-21 15:17 ` weiping zhang 2017-09-21 16:37 ` Jens Axboe 2017-09-21 15:17 ` [PATCH v2 2/2] blk-sysfs: return EINVAL when user modify nr_request less than BLKDEV_MIN_RQ weiping zhang 1 sibling, 1 reply; 7+ messages in thread From: weiping zhang @ 2017-09-21 15:17 UTC (permalink / raw) To: axboe; +Cc: linux-block if blk-mq use "none" io scheduler, nr_request get a wrong value when input a number > tag_set->queue_depth. blk_mq_tag_update_depth will get the smaller one min(nr, set->queue_depth), and then q->nr_request get a wrong value. Reproduce: echo none > /sys/block/nvme0n1/queue/ioscheduler echo 1000000 > /sys/block/nvme0n1/queue/nr_requests cat /sys/block/nvme0n1/queue/nr_requests 1000000 Signed-off-by: weiping zhang <zhangweiping@didichuxing.com> --- block/blk-mq.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 98a1860..479c35a 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2642,8 +2642,12 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr) * queue depth. This is similar to what the old code would do. */ if (!hctx->sched_tags) { - ret = blk_mq_tag_update_depth(hctx, &hctx->tags, - min(nr, set->queue_depth), + if (nr > set->queue_depth) { + ret = -EINVAL; + break; + } + + ret = blk_mq_tag_update_depth(hctx, &hctx->tags, nr, false); } else { ret = blk_mq_tag_update_depth(hctx, &hctx->sched_tags, -- 2.9.4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] blk-mq: fix nr_requests wrong value when modify it from sysfs 2017-09-21 15:17 ` [PATCH v2 1/2] blk-mq: fix nr_requests wrong value when modify it from sysfs weiping zhang @ 2017-09-21 16:37 ` Jens Axboe 2017-09-21 17:09 ` weiping zhang 0 siblings, 1 reply; 7+ messages in thread From: Jens Axboe @ 2017-09-21 16:37 UTC (permalink / raw) To: weiping zhang; +Cc: linux-block On 09/21/2017 09:17 AM, weiping zhang wrote: > if blk-mq use "none" io scheduler, nr_request get a wrong value when > input a number > tag_set->queue_depth. blk_mq_tag_update_depth will get > the smaller one min(nr, set->queue_depth), and then q->nr_request get a > wrong value. > > Reproduce: > > echo none > /sys/block/nvme0n1/queue/ioscheduler > echo 1000000 > /sys/block/nvme0n1/queue/nr_requests > cat /sys/block/nvme0n1/queue/nr_requests > 1000000 > > Signed-off-by: weiping zhang <zhangweiping@didichuxing.com> > --- > block/blk-mq.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/block/blk-mq.c b/block/blk-mq.c > index 98a1860..479c35a 100644 > --- a/block/blk-mq.c > +++ b/block/blk-mq.c > @@ -2642,8 +2642,12 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr) > * queue depth. This is similar to what the old code would do. > */ > if (!hctx->sched_tags) { > - ret = blk_mq_tag_update_depth(hctx, &hctx->tags, > - min(nr, set->queue_depth), > + if (nr > set->queue_depth) { > + ret = -EINVAL; > + break; > + } > + > + ret = blk_mq_tag_update_depth(hctx, &hctx->tags, nr, > false); What am I missing here? blk_mq_tag_update_depth() should already return -EINVAL for the case where we can't grow the tags. Looks like this patch should simply remove the min(nr, set->queue_depth) and just pass in 'nr'. Should not need the duplicated check for depth. -- Jens Axboe ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] blk-mq: fix nr_requests wrong value when modify it from sysfs 2017-09-21 16:37 ` Jens Axboe @ 2017-09-21 17:09 ` weiping zhang 0 siblings, 0 replies; 7+ messages in thread From: weiping zhang @ 2017-09-21 17:09 UTC (permalink / raw) To: Jens Axboe; +Cc: linux-block On Thu, Sep 21, 2017 at 10:37:48AM -0600, Jens Axboe wrote: > On 09/21/2017 09:17 AM, weiping zhang wrote: > > if blk-mq use "none" io scheduler, nr_request get a wrong value when > > input a number > tag_set->queue_depth. blk_mq_tag_update_depth will get > > the smaller one min(nr, set->queue_depth), and then q->nr_request get a > > wrong value. > > > > Reproduce: > > > > echo none > /sys/block/nvme0n1/queue/ioscheduler > > echo 1000000 > /sys/block/nvme0n1/queue/nr_requests > > cat /sys/block/nvme0n1/queue/nr_requests > > 1000000 > > > > Signed-off-by: weiping zhang <zhangweiping@didichuxing.com> > > --- > > block/blk-mq.c | 8 ++++++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/block/blk-mq.c b/block/blk-mq.c > > index 98a1860..479c35a 100644 > > --- a/block/blk-mq.c > > +++ b/block/blk-mq.c > > @@ -2642,8 +2642,12 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr) > > * queue depth. This is similar to what the old code would do. > > */ > > if (!hctx->sched_tags) { > > - ret = blk_mq_tag_update_depth(hctx, &hctx->tags, > > - min(nr, set->queue_depth), > > + if (nr > set->queue_depth) { > > + ret = -EINVAL; > > + break; > > + } > > + > > + ret = blk_mq_tag_update_depth(hctx, &hctx->tags, nr, > > false); > > What am I missing here? blk_mq_tag_update_depth() should already return > -EINVAL for the case where we can't grow the tags. Looks like this patch > should simply remove the min(nr, set->queue_depth) and just pass in 'nr'. > Should not need the duplicated check for depth. > Ya, you are right, I will send V3 later. Thanks ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] blk-sysfs: return EINVAL when user modify nr_request less than BLKDEV_MIN_RQ 2017-09-21 15:16 [PATCH v2 0/2] fix wrong value when user modify nr_request by sysfs weiping zhang 2017-09-21 15:17 ` [PATCH v2 1/2] blk-mq: fix nr_requests wrong value when modify it from sysfs weiping zhang @ 2017-09-21 15:17 ` weiping zhang 2017-09-21 16:38 ` Jens Axboe 1 sibling, 1 reply; 7+ messages in thread From: weiping zhang @ 2017-09-21 15:17 UTC (permalink / raw) To: axboe; +Cc: linux-block Signed-off-by: weiping zhang <zhangweiping@didichuxing.com> --- block/blk-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index b8362c0..03a6e19 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -75,7 +75,7 @@ queue_requests_store(struct request_queue *q, const char *page, size_t count) return ret; if (nr < BLKDEV_MIN_RQ) - nr = BLKDEV_MIN_RQ; + return -EINVAL; if (q->request_fn) err = blk_update_nr_requests(q, nr); -- 2.9.4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] blk-sysfs: return EINVAL when user modify nr_request less than BLKDEV_MIN_RQ 2017-09-21 15:17 ` [PATCH v2 2/2] blk-sysfs: return EINVAL when user modify nr_request less than BLKDEV_MIN_RQ weiping zhang @ 2017-09-21 16:38 ` Jens Axboe 2017-09-21 17:12 ` weiping zhang 0 siblings, 1 reply; 7+ messages in thread From: Jens Axboe @ 2017-09-21 16:38 UTC (permalink / raw) To: weiping zhang; +Cc: linux-block On 09/21/2017 09:17 AM, weiping zhang wrote: > Signed-off-by: weiping zhang <zhangweiping@didichuxing.com> > --- > block/blk-sysfs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c > index b8362c0..03a6e19 100644 > --- a/block/blk-sysfs.c > +++ b/block/blk-sysfs.c > @@ -75,7 +75,7 @@ queue_requests_store(struct request_queue *q, const char *page, size_t count) > return ret; > > if (nr < BLKDEV_MIN_RQ) > - nr = BLKDEV_MIN_RQ; > + return -EINVAL; This is potentially breaking existing scripts. -- Jens Axboe ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] blk-sysfs: return EINVAL when user modify nr_request less than BLKDEV_MIN_RQ 2017-09-21 16:38 ` Jens Axboe @ 2017-09-21 17:12 ` weiping zhang 0 siblings, 0 replies; 7+ messages in thread From: weiping zhang @ 2017-09-21 17:12 UTC (permalink / raw) To: Jens Axboe; +Cc: linux-block On Thu, Sep 21, 2017 at 10:38:22AM -0600, Jens Axboe wrote: > On 09/21/2017 09:17 AM, weiping zhang wrote: > > Signed-off-by: weiping zhang <zhangweiping@didichuxing.com> > > --- > > block/blk-sysfs.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c > > index b8362c0..03a6e19 100644 > > --- a/block/blk-sysfs.c > > +++ b/block/blk-sysfs.c > > @@ -75,7 +75,7 @@ queue_requests_store(struct request_queue *q, const char *page, size_t count) > > return ret; > > > > if (nr < BLKDEV_MIN_RQ) > > - nr = BLKDEV_MIN_RQ; > > + return -EINVAL; > > This is potentially breaking existing scripts. > I just want this keep same behavior with the too larger case, If this may make other side effect, I drop this patch. Thanks weiping ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-09-21 17:12 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-09-21 15:16 [PATCH v2 0/2] fix wrong value when user modify nr_request by sysfs weiping zhang 2017-09-21 15:17 ` [PATCH v2 1/2] blk-mq: fix nr_requests wrong value when modify it from sysfs weiping zhang 2017-09-21 16:37 ` Jens Axboe 2017-09-21 17:09 ` weiping zhang 2017-09-21 15:17 ` [PATCH v2 2/2] blk-sysfs: return EINVAL when user modify nr_request less than BLKDEV_MIN_RQ weiping zhang 2017-09-21 16:38 ` Jens Axboe 2017-09-21 17:12 ` weiping zhang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox