[Devel] [PATCH RH9 v2 4/8] dm/dm-qcow2: add calc_front_qio_bytes() helper

Alexander Atanasov alexander.atanasov at virtuozzo.com
Mon Aug 21 17:39:53 MSK 2023


On 16.08.23 12:32, Andrey Zhadchenko wrote:
> Move code that calculates qio front bytes type and amount into a new
> helper. It will be used later for llseek_hole()
> 
> Feature: dm: implement SEEK_HOLE for dm-qcow2 and dm-ploop
> https://jira.vzint.dev/browse/PSBM-145746
> Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
> ---
>   drivers/md/dm-qcow2-map.c | 46 ++++++++++++++++++++++++++++-----------
>   1 file changed, 33 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
> index a779889c6970..8c1620c11137 100644
> --- a/drivers/md/dm-qcow2-map.c
> +++ b/drivers/md/dm-qcow2-map.c
> @@ -3341,27 +3341,47 @@ static int handle_metadata(struct qcow2 *qcow2, struct qio **qio,
>   	return ret;
>   }
>   
> +struct calc_front_bytes_ret {
> +	bool unmapped;
> +	bool zeroes;
> +	bool try_lower;
> +};
> +
> +static inline u32 calc_front_qio_bytes(struct qcow2 *qcow2, struct qio *qio,
> +				       struct qcow2_map *map,
> +				       struct calc_front_bytes_ret *arg)
> +{
> +	bool zeroes, unmapped = false, try_lower = false;
> +	u32 size;
> +
> +	zeroes = (size = qio_all_zeroes_size(qcow2, qio, map));
> +	if (!size)
> +		unmapped = (size = qio_unmapped_size(qcow2, qio, map));

https://docs.kernel.org/process/coding-style.html?highlight=coding+style
"Don't put multiple assignments on a single line either. Kernel coding 
style is super simple. Avoid tricky expressions."



> +	if (!size)
> +		size = qio_mapped_not_zeroes_size(qcow2, qio, map);
> +
> +	if (unmapped)
> +		try_lower = maybe_mapped_in_lower_delta(qcow2, qio);
> +
> +	arg->unmapped = unmapped;
> +	arg->zeroes = zeroes;
> +	arg->try_lower = try_lower;


why do we need temporary variables ?


-- 
Regards,
Alexander Atanasov



More information about the Devel mailing list