* [PATCH] block: bvec_nr_vecs() returns value for wrong slab
@ 2018-08-08 19:27 Greg Edwards
2018-08-09 14:28 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Greg Edwards @ 2018-08-08 19:27 UTC (permalink / raw)
To: linux-block; +Cc: Jens Axboe, Christoph Hellwig, Greg Edwards
In commit ed996a52c868 ("block: simplify and cleanup bvec pool
handling"), the value of the slab index is incremented by one in
bvec_alloc() after the allocation is done to indicate an index value of
0 does not need to be later freed.
bvec_nr_vecs() was not updated accordingly, and thus returns the wrong
value. Decrement idx before performing the lookup.
Fixes: ed996a52c868 ("block: simplify and cleanup bvec pool handling")
Signed-off-by: Greg Edwards <gedwards@ddn.com>
---
block/bio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/bio.c b/block/bio.c
index 047c5dca6d90..ff94640bc734 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -156,7 +156,7 @@ static void bio_put_slab(struct bio_set *bs)
unsigned int bvec_nr_vecs(unsigned short idx)
{
- return bvec_slabs[idx].nr_vecs;
+ return bvec_slabs[--idx].nr_vecs;
}
void bvec_free(mempool_t *pool, struct bio_vec *bv, unsigned int idx)
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] block: bvec_nr_vecs() returns value for wrong slab
2018-08-08 19:27 [PATCH] block: bvec_nr_vecs() returns value for wrong slab Greg Edwards
@ 2018-08-09 14:28 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2018-08-09 14:28 UTC (permalink / raw)
To: Greg Edwards, linux-block; +Cc: Christoph Hellwig
On 8/8/18 1:27 PM, Greg Edwards wrote:
> In commit ed996a52c868 ("block: simplify and cleanup bvec pool
> handling"), the value of the slab index is incremented by one in
> bvec_alloc() after the allocation is done to indicate an index value of
> 0 does not need to be later freed.
>
> bvec_nr_vecs() was not updated accordingly, and thus returns the wrong
> value. Decrement idx before performing the lookup.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-09 14:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-08 19:27 [PATCH] block: bvec_nr_vecs() returns value for wrong slab Greg Edwards
2018-08-09 14:28 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.