[Devel] [PATCH RHEL8 COMMIT] ploop: Move add_delta iterating code to separate function
Konstantin Khorenko
khorenko at virtuozzo.com
Tue May 4 16:59:27 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.25
------>
commit c9dad35fe479d4e198df537625803dcf88af42ad
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Tue May 4 16:59:27 2021 +0300
ploop: Move add_delta iterating code to separate function
To_merge: 3e892fb36c57 ("dm: Interpreter of ploop1 format (ploop driver)")
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
=====================
Patchset description:
ploop: Preparation to kill-loop from dm-ploop (series 1)
Currently, ploop requires underlining loop for top delta. This is overkill,
since we may submit bios directly to fs, without using it.
Initially there was a possibility, we may use device-mapper format snapshots
instead of ploop-based. But we don't do that, so we have to use loop for top
delta and directly submit bios to the rest of deltas. So, these two ways to do
the same actions are wrong.
This is preparations#1 for further series.
Let's this goes to testing earlier.
Kirill Tkhai (7):
ploop: Kill "add_delta" interface
ploop: Refactor ploop_add_delta()
ploop: Move check in ploop_ctr()
ploop: Call add_delta directly
ploop: Move add_delta iterating code to separate function
ploop: Allocate deltas in only place
ploop: Add ignore_signature_disk_in_use parameter
https://jira.sw.ru/browse/PSBM-123654
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-ploop-target.c | 52 +++++++++++++++++++++++++++-----------------
1 file changed, 32 insertions(+), 20 deletions(-)
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 97683231b0a5..b4a21840fba7 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -109,16 +109,42 @@ static int ploop_check_origin_dev(struct dm_target *ti, struct ploop *ploop)
return 0;
}
+static int ploop_add_deltas_stack(struct ploop *ploop, char **argv, int argc)
+{
+ int i, delta_fd, ret;
+ const char *arg;
+ bool is_raw;
+
+ ret = -EINVAL;
+ for (i = 0; i < argc; i++) {
+ arg = argv[i];
+ is_raw = false;
+ if (strncmp(arg, "raw@", 4) == 0) {
+ if (i != 0)
+ goto out;
+ arg += 4;
+ is_raw = true;
+ }
+ if (kstrtos32(arg, 10, &delta_fd) < 0)
+ goto out;
+
+ ret = ploop_add_delta(ploop, delta_fd, is_raw);
+ if (ret < 0)
+ goto out;
+ }
+
+ ret = 0;
+out:
+ return ret;
+}
/*
* <data dev>
*/
static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
{
percpu_ref_func_t *release;
- int i, delta_fd, ret;
struct ploop *ploop;
- bool is_raw;
- char *arg;
+ int i, ret;
if (argc < 2)
return -EINVAL;
@@ -195,23 +221,9 @@ static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto err;
}
- ret = -EINVAL;
- for (i = 2; i < argc; i++) {
- arg = argv[i];
- is_raw = false;
- if (strncmp(arg, "raw@", 4) == 0) {
- if (i != 2)
- goto err;
- arg += 4;
- is_raw = true;
- }
- if (kstrtos32(arg, 10, &delta_fd) < 0)
- goto err;
-
- ret = ploop_add_delta(ploop, delta_fd, is_raw);
- if (ret < 0)
- goto err;
- }
+ ret = ploop_add_deltas_stack(ploop, &argv[2], argc - 2);
+ if (ret)
+ goto err;
ti->per_io_data_size = sizeof(struct dm_ploop_endio_hook);
ti->num_flush_bios = 1;
More information about the Devel
mailing list