[Devel] [PATCH RHEL9 COMMIT] dm-qcow2: Move qcow2_get_img_name() and qcow2_get_img_fd() out of mutex
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Dec 7 17:44:59 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 2f9eb1ee8e6e1b1cbe4c3c0c392c752ac58f6f05
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Tue Dec 7 17:44:59 2021 +0300
dm-qcow2: Move qcow2_get_img_name() and qcow2_get_img_fd() out of mutex
Now it is protected by target ref, so we move them out.
This allows to avoid long hang in case of this functions
are called in parallel with backup.
Feature: dm-qcow2: block device over QCOW2 file driver
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-qcow2-cmd.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/md/dm-qcow2-cmd.c b/drivers/md/dm-qcow2-cmd.c
index c64ea325e52e..bb541e4707cf 100644
--- a/drivers/md/dm-qcow2-cmd.c
+++ b/drivers/md/dm-qcow2-cmd.c
@@ -315,24 +315,28 @@ int qcow2_message(struct dm_target *ti, unsigned int argc, char **argv,
if (argc < 1)
goto out;
- ret = mutex_lock_killable(&tgt->ctl_mutex);
- if (ret)
- goto out;
-
- if (!strcmp(argv[0], "get_errors")) {
- ret = qcow2_get_errors(tgt, result, maxlen);
- } else if (!strcmp(argv[0], "get_img_fd")) {
+ if (!strcmp(argv[0], "get_img_fd")) {
if (argc != 2 || kstrtou32(argv[1], 10, &val)) {
ret = -EINVAL;
- goto unlock;
+ goto out;
}
ret = qcow2_get_img_fd(tgt, val, result, maxlen);
+ goto out;
} else if (!strcmp(argv[0], "get_img_name")) {
if (argc != 2 || kstrtou32(argv[1], 10, &val)) {
ret = -EINVAL;
- goto unlock;
+ goto out;
}
ret = qcow2_get_img_name(tgt, val, result, maxlen);
+ goto out;
+ }
+
+ ret = mutex_lock_killable(&tgt->ctl_mutex);
+ if (ret)
+ goto out;
+
+ if (!strcmp(argv[0], "get_errors")) {
+ ret = qcow2_get_errors(tgt, result, maxlen);
} else if (!tgt->service_operations_allowed) {
ret = -EBUSY; /* Suspended */
/* Service operations goes below: */
@@ -343,7 +347,7 @@ int qcow2_message(struct dm_target *ti, unsigned int argc, char **argv,
} else {
ret = -ENOTTY;
}
-unlock:
+
mutex_unlock(&tgt->ctl_mutex);
out:
return ret;
More information about the Devel
mailing list