[Devel] [PATCH RHEL8 COMMIT] ploop: Add interface to get mask of partial backup from userspace

Konstantin Khorenko khorenko at virtuozzo.com
Fri Oct 25 19:15:18 MSK 2019


The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.2.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.2.3
------>
commit d14712c9a4c330c6151566b043ccc6002c0a2da6
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Oct 25 19:15:16 2019 +0300

    ploop: Add interface to get mask of partial backup from userspace
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 230ded562312..c687d7f6fa02 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1336,14 +1336,24 @@ void ploop_free_pb(struct push_backup *pb)
 	kfree(pb);
 }
 
-static int ploop_setup_pb_map(struct ploop *ploop, struct push_backup *pb)
+static int ploop_setup_pb_map(struct push_backup *pb, void __user *mask)
 {
-	unsigned int i, nr_bat_entries = ploop->nr_bat_entries;
+	unsigned int i, size, nr_bat_entries;
+	struct ploop *ploop = pb->ploop;
+
+	nr_bat_entries = ploop->nr_bat_entries;
 
-	/* Full backup */
-	memset(pb->ppb_map, 0xff, nr_bat_entries / 8);
-	for (i = round_down(nr_bat_entries, 8); i < nr_bat_entries; i++)
-		set_bit(i, pb->ppb_map);
+	if (!mask) {
+		/* Full backup */
+		memset(pb->ppb_map, 0xff, nr_bat_entries / 8);
+		for (i = round_down(nr_bat_entries, 8); i < nr_bat_entries; i++)
+			set_bit(i, pb->ppb_map);
+	} else {
+		/* Partial backup */
+		size = DIV_ROUND_UP(nr_bat_entries, 8);
+		if (copy_from_user(pb->ppb_map, mask, size))
+			return -EFAULT;
+	}
 
 	return 0;
 }
@@ -1359,9 +1369,6 @@ static int ploop_push_backup_start(struct ploop *ploop, char *uuid,
 	cmd.type = PLOOP_CMD_SET_PUSH_BACKUP;
 	cmd.ploop = ploop;
 
-	if (mask)
-		return -ENOPROTOOPT; /* TODO */
-
 	if (ploop->pb)
 		return -EEXIST;
 	/*
@@ -1382,7 +1389,7 @@ static int ploop_push_backup_start(struct ploop *ploop, char *uuid,
 	pb = ploop_alloc_pb(ploop, uuid);
 	if (!pb)
 		return -ENOMEM;
-	ret = ploop_setup_pb_map(ploop, pb);
+	ret = ploop_setup_pb_map(pb, mask);
 	if (ret)
 		goto err_free;
 



More information about the Devel mailing list