提交 615d1eb9 编写于 作者: M Mike Snitzer 提交者: Alasdair G Kergon

dm snapshot: create function for chunk_is_tracked wait

Move the __chunk_is_tracked() loop into a separate function as we will
also need to call it from the write path in the rare case of conflicting
writes to the same chunk.

Originally introduced in commit a8d41b59
("dm snapshot: fix race during exception creation").
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
上级 9eaae8ff
...@@ -233,6 +233,16 @@ static int __chunk_is_tracked(struct dm_snapshot *s, chunk_t chunk) ...@@ -233,6 +233,16 @@ static int __chunk_is_tracked(struct dm_snapshot *s, chunk_t chunk)
return found; return found;
} }
/*
* This conflicting I/O is extremely improbable in the caller,
* so msleep(1) is sufficient and there is no need for a wait queue.
*/
static void __check_for_conflicting_io(struct dm_snapshot *s, chunk_t chunk)
{
while (__chunk_is_tracked(s, chunk))
msleep(1);
}
/* /*
* One of these per registered origin, held in the snapshot_origins hash * One of these per registered origin, held in the snapshot_origins hash
*/ */
...@@ -1102,12 +1112,8 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success) ...@@ -1102,12 +1112,8 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success)
goto out; goto out;
} }
/* /* Check for conflicting reads */
* Check for conflicting reads. This is extremely improbable, __check_for_conflicting_io(s, pe->e.old_chunk);
* so msleep(1) is sufficient and there is no need for a wait queue.
*/
while (__chunk_is_tracked(s, pe->e.old_chunk))
msleep(1);
/* /*
* Add a proper exception, and remove the * Add a proper exception, and remove the
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册