[Devel] [PATCH RHEL9 COMMIT] block/blk-cbt: fix cbt_ioc_init()
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Jan 29 19:51:23 MSK 2025
The commit is pushed to "branch-rh9-5.14.0-427.44.1.vz9.80.x-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh9-5.14.0-427.44.1.vz9.80.10
------>
commit dc9150bd0a3462b201097e7ab6b136a38b7c25a8
Author: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Date: Wed Jan 29 19:28:39 2025 +0300
block/blk-cbt: fix cbt_ioc_init()
err_mtx mark was deleted in v1 along with some checks. In v2
and later new error checks were added (that cbt already exists
or we hit a limit) but we forgot to release the mutex.
Re-introduce err_mtx.
Fixes: e10d691405b5 ("block/blk-cbt: allow multiple cbts in a single queue")
https://virtuozzo.atlassian.net/browse/VSTOR-96269
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Feature: cbt: changed block tracking (for backup)
---
block/blk-cbt.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index fa472aa5d006..0ebde7157ba6 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -633,11 +633,15 @@ static int cbt_ioc_init(struct block_device *bdev, struct blk_user_cbt_info __us
q = bdev_get_queue(bdev);
mutex_lock(&cbt_mutex);
- if (blk_cbt_find(q, ci.ci_name))
- return -EEXIST;
+ if (blk_cbt_find(q, ci.ci_name)) {
+ ret = -EEXIST;
+ goto err_mtx;
+ }
- if (list_count_nodes(&q->cbt_list) == CBT_MAX_ENTRIES)
- return -E2BIG;
+ if (list_count_nodes(&q->cbt_list) == CBT_MAX_ENTRIES) {
+ ret = -E2BIG;
+ goto err_mtx;
+ }
cbt = do_cbt_alloc(q, ci.ci_name, i_size_read(bdev->bd_inode), ci.ci_blksize);
if (IS_ERR(cbt))
@@ -645,6 +649,7 @@ static int cbt_ioc_init(struct block_device *bdev, struct blk_user_cbt_info __us
else
list_add_tail_rcu(&cbt->list, &q->cbt_list);
+err_mtx:
mutex_unlock(&cbt_mutex);
return ret;
}
More information about the Devel
mailing list