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.zhadche...@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

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to