[PATCH v5 4/5] ublk: add helper to check if device supports user copy

Andreas Hindborg posted 5 patches 2 years, 7 months ago
There is a newer version of this series
[PATCH v5 4/5] ublk: add helper to check if device supports user copy
Posted by Andreas Hindborg 2 years, 7 months ago
From: Andreas Hindborg <a.hindborg@samsung.com>

This will be used by ublk zoned storage support.

Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com>
---
 drivers/block/ublk.c | 2 +-
 drivers/block/ublk.h | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/block/ublk.c b/drivers/block/ublk.c
index a0453619bf67..0b1ec102aaae 100644
--- a/drivers/block/ublk.c
+++ b/drivers/block/ublk.c
@@ -1947,7 +1947,7 @@ static int ublk_ctrl_add_dev(struct io_uring_cmd *cmd)
 		UBLK_F_URING_CMD_COMP_IN_TASK;
 
 	/* GET_DATA isn't needed any more with USER_COPY */
-	if (ub->dev_info.flags & UBLK_F_USER_COPY)
+	if (ublk_dev_is_user_copy(ub))
 		ub->dev_info.flags &= ~UBLK_F_NEED_GET_DATA;
 
 	/* We are not ready to support zero copy */
diff --git a/drivers/block/ublk.h b/drivers/block/ublk.h
index 2a4ab721d513..fcbcc6b02aa0 100644
--- a/drivers/block/ublk.h
+++ b/drivers/block/ublk.h
@@ -100,4 +100,9 @@ struct ublk_io {
 	struct io_uring_cmd *cmd;
 };
 
+static inline bool ublk_dev_is_user_copy(const struct ublk_device *ub)
+{
+	return ub->dev_info.flags & UBLK_F_USER_COPY;
+}
+
 #endif
-- 
2.41.0
Re: [PATCH v5 4/5] ublk: add helper to check if device supports user copy
Posted by Damien Le Moal 2 years, 7 months ago
On 7/5/23 01:52, Andreas Hindborg wrote:
> From: Andreas Hindborg <a.hindborg@samsung.com>
> 
> This will be used by ublk zoned storage support.
> 
> Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com>

Looks good.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

> ---
>  drivers/block/ublk.c | 2 +-
>  drivers/block/ublk.h | 5 +++++
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/ublk.c b/drivers/block/ublk.c
> index a0453619bf67..0b1ec102aaae 100644
> --- a/drivers/block/ublk.c
> +++ b/drivers/block/ublk.c
> @@ -1947,7 +1947,7 @@ static int ublk_ctrl_add_dev(struct io_uring_cmd *cmd)
>  		UBLK_F_URING_CMD_COMP_IN_TASK;
>  
>  	/* GET_DATA isn't needed any more with USER_COPY */
> -	if (ub->dev_info.flags & UBLK_F_USER_COPY)
> +	if (ublk_dev_is_user_copy(ub))
>  		ub->dev_info.flags &= ~UBLK_F_NEED_GET_DATA;
>  
>  	/* We are not ready to support zero copy */
> diff --git a/drivers/block/ublk.h b/drivers/block/ublk.h
> index 2a4ab721d513..fcbcc6b02aa0 100644
> --- a/drivers/block/ublk.h
> +++ b/drivers/block/ublk.h
> @@ -100,4 +100,9 @@ struct ublk_io {
>  	struct io_uring_cmd *cmd;
>  };
>  
> +static inline bool ublk_dev_is_user_copy(const struct ublk_device *ub)
> +{
> +	return ub->dev_info.flags & UBLK_F_USER_COPY;
> +}
> +
>  #endif

-- 
Damien Le Moal
Western Digital Research