[Devel] [PATCH RHEL9 COMMIT] dm-qcow2: Return empty string instead of -ENOENT in qcow2_get_fd()

Konstantin Khorenko khorenko at virtuozzo.com
Tue Dec 7 17:43:04 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 rh9-5.14.0-4.vz9.10.33
------>
commit 58ef201790467c2045dcdd271fb8b49ecda8349d
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Tue Dec 7 17:43:03 2021 +0300

    dm-qcow2: Return empty string instead of -ENOENT in qcow2_get_fd()
    
    Unification with qcow2_get_img_name(). Also rename this function.
    
    Feature: dm-qcow2: block device over QCOW2 file driver
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-qcow2-cmd.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-qcow2-cmd.c b/drivers/md/dm-qcow2-cmd.c
index 458a2d5d71e4..486d2212652e 100644
--- a/drivers/md/dm-qcow2-cmd.c
+++ b/drivers/md/dm-qcow2-cmd.c
@@ -223,8 +223,8 @@ static int qcow2_merge_backward(struct qcow2_target *tgt)
 	return ret;
 }
 
-static int qcow2_get_fd(struct qcow2_target *tgt, u32 img_id,
-			char *result, unsigned int maxlen)
+static int qcow2_get_img_fd(struct qcow2_target *tgt, u32 img_id,
+			    char *result, unsigned int maxlen)
 {
 	struct qcow2 *qcow2 = tgt->top;
 	unsigned int sz = 0;
@@ -239,8 +239,10 @@ static int qcow2_get_fd(struct qcow2_target *tgt, u32 img_id,
 		skip--;
 	}
 
-	if (!qcow2 || skip)
-		return -ENOENT;
+	if (!qcow2 || skip) {
+		result[0] = 0; /* empty output */
+		return 1;
+	}
 
 	fd = get_unused_fd_flags(0);
 	if (fd < 0)
@@ -315,7 +317,7 @@ int qcow2_message(struct dm_target *ti, unsigned int argc, char **argv,
 			ret = -EINVAL;
 			goto unlock;
 		}
-		ret = qcow2_get_fd(tgt, val, result, maxlen);
+		ret = qcow2_get_img_fd(tgt, val, result, maxlen);
 	} else if (!strcmp(argv[0], "get_img_name")) {
 		if (argc != 2 || kstrtou32(argv[1], 10, &val)) {
 			ret = -EINVAL;


More information about the Devel mailing list