[Devel] [PATCH RHEL8 COMMIT] ploop: Change cmds return values

Konstantin Khorenko khorenko at virtuozzo.com
Fri Oct 25 16:37:02 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 b9052ab77203d1e6e8cb81f0f6c47ea71446d22c
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Oct 25 16:36:42 2019 +0300

    ploop: Change cmds return values
    
    Make get_delta_name, ploop_push_backup_read and push_backup_get_uuid
    return empty string in case of there is no delta or there is no bios,
    or there is no backup started to simplify parsing in userspace.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 9c8ca8102774..98e5e0525a1b 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -902,11 +902,13 @@ static int ploop_get_delta_name_cmd(struct ploop *ploop, u8 level,
 				char *result, unsigned int maxlen)
 {
 	struct file *file;
-	int len, ret;
+	int len, ret = 1;
 	char *p;
 
-	if (level >= ploop->nr_deltas)
-		return -ENOENT;
+	if (level >= ploop->nr_deltas) {
+		result[0] = '\0';
+		goto out;
+	}
 
 	/*
 	 * Nobody can change deltas in parallel, since
@@ -918,7 +920,6 @@ static int ploop_get_delta_name_cmd(struct ploop *ploop, u8 level,
 	read_unlock_irq(&ploop->bat_rwlock);
 
 	p = file_path(file, result, maxlen);
-	ret = 1;
 	if (p == ERR_PTR(-ENAMETOOLONG)) {
 		/* Notify target_message(), there is not enough space */
 		memset(result, 'x', maxlen - 1);
@@ -933,6 +934,7 @@ static int ploop_get_delta_name_cmd(struct ploop *ploop, u8 level,
 	}
 
 	fput(file);
+out:
 	return ret;
 }
 
@@ -1391,7 +1393,7 @@ static int ploop_push_backup_stop(struct ploop *ploop, char *uuid,
 	cmd.ploop = ploop;
 
 	if (!ploop->pb)
-		return -ENOENT;
+		return -EBADF;
 	if (strcmp(ploop->pb->uuid, uuid))
 		return -EINVAL;
 
@@ -1412,10 +1414,10 @@ static int ploop_push_backup_get_uuid(struct ploop *ploop, char *result,
 	struct push_backup *pb = ploop->pb;
 	unsigned int sz = 0;
 
-	if (!pb)
-		return -EBADF;
-
-	DMEMIT("%s", pb->uuid);
+	if (pb)
+		DMEMIT("%s", pb->uuid);
+	else
+		result[0] = '\0';
 	return 1;
 }
 
@@ -1426,7 +1428,7 @@ static int ploop_push_backup_read(struct ploop *ploop, char *uuid,
 	struct push_backup *pb = ploop->pb;
 	unsigned int left, right, sz = 0;
 	struct rb_node *node;
-	int ret;
+	int ret = 1;
 
 	if (!pb)
 		return -EBADF;
@@ -1436,10 +1438,11 @@ static int ploop_push_backup_read(struct ploop *ploop, char *uuid,
 		return -ESTALE;
 
 	spin_lock_irq(&ploop->pb_lock);
-	ret = -ENOENT;
 	h = orig_h = list_first_entry_or_null(&pb->pending, typeof(*h), list);
-	if (!h)
+	if (!h) {
+		result[0] = '\0';
 		goto unlock;
+	}
 	list_del_init(&h->list);
 
 	left = right = h->cluster;
@@ -1461,7 +1464,6 @@ static int ploop_push_backup_read(struct ploop *ploop, char *uuid,
 	}
 
 	DMEMIT("%u:%u", left, right - left + 1);
-	ret = 1;
 unlock:
 	spin_unlock_irq(&ploop->pb_lock);
 	return ret;



More information about the Devel mailing list