Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid extra memory copies during mirror scrub. #13593

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions module/zfs/vdev_mirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ typedef struct mirror_map {
boolean_t mm_resilvering;
boolean_t mm_rebuilding;
boolean_t mm_root;
boolean_t mm_got_data;
mirror_child_t mm_child[];
} mirror_map_t;

Expand Down Expand Up @@ -451,17 +452,17 @@ vdev_mirror_scrub_done(zio_t *zio)
mirror_child_t *mc = zio->io_private;

if (zio->io_error == 0) {
zio_t *pio;
zio_link_t *zl = NULL;

mutex_enter(&zio->io_lock);
while ((pio = zio_walk_parents(zio, &zl)) != NULL) {
mutex_enter(&pio->io_lock);
ASSERT3U(zio->io_size, >=, pio->io_size);
zio_t *pio = zio_unique_parent(zio);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original algorithm walked all parents to do the copy... while it seems reasonable that there should generally be only a single parent here, do you have a reason to believe that is an invariant? Why did the original algorithm assume the possibility of multiple parents?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what the original author was thinking about. zio_unique_parent() actually verifies there are not other parents, and the assertion didn't fire on my tests. My best guess is that it was some paranoia, same as unneeded locking.

mirror_map_t *mm = pio->io_vsd;
mutex_enter(&pio->io_lock);
if (!mm->mm_got_data) {
mm->mm_got_data = B_TRUE;
mutex_exit(&pio->io_lock);
ASSERT3U(zio->io_size, ==, pio->io_size);
abd_copy(pio->io_abd, zio->io_abd, pio->io_size);
} else {
mutex_exit(&pio->io_lock);
}
mutex_exit(&zio->io_lock);
}

abd_free(zio->io_abd);
Expand Down