[Devel] [PATCH RHEL COMMIT] dm-tracking: Add tracking_clear cmd
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Sep 30 21:36:08 MSK 2021
The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 89097b096862ae4cc7fa700e7ca3b487f086f4b2
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Thu Sep 30 21:36:07 2021 +0300
dm-tracking: Add tracking_clear cmd
Command to ACK ordered copied cluster.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-tracking.c | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-tracking.c b/drivers/md/dm-tracking.c
index e9cf0a4ae298..d723596fee44 100644
--- a/drivers/md/dm-tracking.c
+++ b/drivers/md/dm-tracking.c
@@ -168,6 +168,14 @@ static void dmt_dtr(struct dm_target *ti)
dmt_destroy(ti->private);
}
+static int tracking_clear(struct dm_tracking *dmt, u64 clu)
+{
+ spin_lock_irq(&dmt->lock);
+ clear_bit(clu, dmt->bitmap);
+ spin_unlock_irq(&dmt->lock);
+ return 0;
+}
+
static int tracking_get_next(struct dm_tracking *dmt, char *result,
unsigned int maxlen)
{
@@ -197,10 +205,24 @@ static int tracking_get_next(struct dm_tracking *dmt, char *result,
}
static int dmt_cmd(struct dm_tracking *dmt, const char *suffix,
+ int argc, char *argv[],
char *result, unsigned int maxlen)
{
unsigned int nr_clus, size;
void *bitmap = NULL;
+ u64 val;
+
+ if (!strcmp(suffix, "clear")) {
+ if (argc != 1 || kstrtou64(argv[0], 10, &val) < 0 ||
+ val >= dmt->nr_clus)
+ return -EINVAL;
+ if (!dmt->bitmap)
+ return -ENOENT;
+ return tracking_clear(dmt, val);
+ }
+
+ if (argc != 0)
+ return -EINVAL;
if (!strcmp(suffix, "get_next")) {
if (!dmt->bitmap)
@@ -248,13 +270,14 @@ static int dmt_message(struct dm_target *ti, unsigned int argc, char **argv,
return -EPERM;
mutex_lock(&dmt->ctl_mutex);
+ ret = -EINVAL;
+ if (argc < 1)
+ goto unlock;
ret = -ENOTSUPP;
if (strncmp(argv[0], "tracking_", 9))
goto unlock;
- ret = -EINVAL;
- if (argc != 1)
- goto unlock;
- ret = dmt_cmd(dmt, argv[0] + 9, result, maxlen);
+ ret = dmt_cmd(dmt, argv[0] + 9, argc - 1,
+ &argv[1], result, maxlen);
unlock:
mutex_unlock(&dmt->ctl_mutex);
More information about the Devel
mailing list