[Devel] [PATCH hci-8.1 1/7] drivers/md/dm-qcow2: repeat md page lookup if it was inserted in parallel

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Thu Oct 29 17:03:40 MSK 2026


teach __handle_md_page() to work around -EEXIST by retrying.

https://virtuozzo.atlassian.net/browse/VSTOR-95494
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 drivers/md/dm-qcow2-map.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 78ee7cf5e8817..fed6ce75e98ad 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -1596,20 +1596,23 @@ static int submit_read_md_page(struct qcow2 *qcow2, struct qio **qio,
 /*
  * This may be called with @qio == NULL, in case of we are
  * interesting in searching cached in memory md only.
- * This is aimed to be called not only from main kwork
- * for L1/L2 pages, so all callers looking for L1/L2
- * must care about submit_read_md_page() may return EEXIST.
  */
 static int __handle_md_page(struct qcow2 *qcow2, u64 page_id,
 			    struct qio **qio, struct md_page **ret_md)
 {
 	struct md_page *md;
+	int ret;
 
 	lockdep_assert_held(&qcow2->md_pages_lock);
+again:
 	md = qcow2_md_page_find_or_postpone(qcow2, page_id, qio);
 	if (!md) {
-		if (qio && *qio)
-			return submit_read_md_page(qcow2, qio, page_id);
+		if (qio && *qio) {
+			ret = submit_read_md_page(qcow2, qio, page_id);
+			if (unlikely(ret == -EEXIST))
+				goto again;
+			return ret;
+		}
 		return 0;
 	}
 
-- 
2.43.5



More information about the Devel mailing list