block/rnbd-clt: Dynamically allocate sglist for rnbd_iu
authorGioh Kim <gi-oh.kim@cloud.ionos.com>
Thu, 10 Dec 2020 10:18:25 +0000 (11:18 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 16 Dec 2020 14:19:59 +0000 (07:19 -0700)
commit9d0caa3e24bcd42f7761697a98722bd5fa6e9820
tree1bc2ebea39a25ea2943898d6a9d73fa7b8f76697
parent70d26e1aed58a82e422d6ba4f76976478f7feaf4
block/rnbd-clt: Dynamically allocate sglist for rnbd_iu

The BMAX_SEGMENT static array for scatterlist is embedded in
rnbd_iu structure to avoid memory allocation in hot IO path.
In many cases, we do need only several sg entries because many IOs
have only several segments.

This patch change rnbd_iu to check the number of segments in the request
and allocate sglist dynamically.

For io path, use sg_alloc_table_chained to allocate sg list faster.

First it makes two sg entries after pdu of request.
The sg_alloc_table_chained uses the pre-allocated sg entries
if the number of segments of the request is less than two.
So it reduces the number of memory allocation.

Signed-off-by: Gioh Kim <gi-oh.kim@cloud.ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/rnbd/rnbd-clt.c
drivers/block/rnbd/rnbd-clt.h