]> git.baikalelectronics.ru Git - kernel.git/commit
block: ublk: check IO buffer based on flag need_get_data
authorLiu Xiaodong <xiaodong.liu@intel.com>
Fri, 10 Feb 2023 14:13:56 +0000 (09:13 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:32:46 +0000 (09:32 +0100)
commita3fb0c2e54902a08a8e4b58bf2f789c44982386b
treef5ad8d7aa437fb866c59d573d36c16f83dc8d05e
parent0c19b3d87b00a5486efe0a19fa4372f837b524c4
block: ublk: check IO buffer based on flag need_get_data

[ Upstream commit 73633ffc2121f7c608ce69f90842d5cd5c6175c6 ]

Currently, uring_cmd with UBLK_IO_FETCH_REQ or
UBLK_IO_COMMIT_AND_FETCH_REQ is always checked whether
userspace server has provided IO buffer even flag
UBLK_F_NEED_GET_DATA is configured.

This is a excessive check. If UBLK_F_NEED_GET_DATA is
configured, FETCH_RQ doesn't need to provide IO buffer;
COMMIT_AND_FETCH_REQ also doesn't need to do that if
the IO type is not READ.

Check ub_cmd->addr together with ublk_need_get_data()
and IO type in ublk_ch_uring_cmd().

With this fix, userspace server doesn't need to preserve
buffers for every ublk_io when flag UBLK_F_NEED_GET_DATA
is configured, in order to save memory.

Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Fixes: 91ffa9d31c09 ("ublk_drv: add support for UBLK_IO_NEED_GET_DATA")
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230210141356.112321-1-xiaodong.liu@intel.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/block/ublk_drv.c