Skip to content

Commit 35d6b31

Browse files
Martin LindsayCQ Bot
authored andcommitted
[fshost] Verify open success during migration recursive copy.
Without verifying this we can race in the tests because the file or directory may not actually be created by the time we verify it. More than that, src may be empty which means that we never interact with the dst copy again and never verify that it was successfully created before destroying the old filesystem. Bug: 405230091 Change-Id: I9bb1324f04285bb65f449c76afe43cbc87f635b2 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1234224 Commit-Queue: Martin Lindsay <[email protected]> Reviewed-by: Aaron Drew <[email protected]>
1 parent 66dbab6 commit 35d6b31

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/storage/fshost/src/copier.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ pub fn recursive_copy<'a>(
2323
fio::PERM_READABLE,
2424
)
2525
.context("open src dir")?;
26-
let dst = fuchsia_fs::directory::open_directory_async(
26+
// Verifying the OnOpen event when creating the destination directory, otherwise we
27+
// never confirm that this directory was successfully created if the source
28+
// directory turns out to be empty.
29+
let dst = fuchsia_fs::directory::open_directory(
2730
dst,
2831
entry.name.as_str(),
2932
fio::Flags::FLAG_MAYBE_CREATE | fio::PERM_WRITABLE,
3033
)
34+
.await
3135
.context("open dst dir")?;
3236
recursive_copy(&src, &dst)
3337
.await
@@ -39,11 +43,15 @@ pub fn recursive_copy<'a>(
3943
fio::PERM_READABLE,
4044
)
4145
.context("open src file")?;
42-
let dst = fuchsia_fs::directory::open_file_async(
46+
// Verifying the OnOpen event when creating the destination file, otherwise we never
47+
// confirm that this file was successfully created if the source file turns out to
48+
// be empty.
49+
let dst = fuchsia_fs::directory::open_file(
4350
dst,
4451
entry.name.as_str(),
4552
fio::Flags::FLAG_MAYBE_CREATE | fio::PERM_WRITABLE,
4653
)
54+
.await
4755
.context("open dst file")?;
4856
loop {
4957
let bytes = src

0 commit comments

Comments
 (0)