From 580c6efaf91f89fae1efda53892df41ae1e41559 Mon Sep 17 00:00:00 2001 From: Liu Bo Date: Thu, 22 Mar 2018 09:20:11 +0800 Subject: Btrfs: replace: cache rbio when rebuild data on missing device Rebuild on missing device is as same as recover, after it's done, rbio has data which is consistent with on-disk data, so it can be cached to avoid further reads. Signed-off-by: Liu Bo Signed-off-by: Liu Bo Signed-off-by: David Sterba --- fs/btrfs/raid56.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'fs') diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 002bddc7fa09..c3a2bc8af675 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1987,7 +1987,13 @@ cleanup: kfree(pointers); cleanup_io: - if (rbio->operation == BTRFS_RBIO_READ_REBUILD) { + /* + * Similar to READ_REBUILD, REBUILD_MISSING at this point also has a + * valid rbio which is consistent with ondisk content, thus such a + * valid rbio can be cached to avoid further disk reads. + */ + if (rbio->operation == BTRFS_RBIO_READ_REBUILD || + rbio->operation == BTRFS_RBIO_REBUILD_MISSING) { /* * - In case of two failures, where rbio->failb != -1: * @@ -2008,8 +2014,6 @@ cleanup_io: else clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags); - rbio_orig_end_io(rbio, err); - } else if (rbio->operation == BTRFS_RBIO_REBUILD_MISSING) { rbio_orig_end_io(rbio, err); } else if (err == BLK_STS_OK) { rbio->faila = -1; -- cgit v1.2.3