Btrfs: replace: cache rbio when rebuild data on missing device
PATCH 1/1 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.
--- fs/btrfs/raid56.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/raid56.c +2 -3
@@ -1986,7 +1986,8 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)kfree (pointers); cleanup_io: -if (rbio->operation ==BTRFS_RBIO_READ_REBUILD ) { +if (rbio->operation ==BTRFS_RBIO_READ_REBUILD || + rbio->operation ==BTRFS_RBIO_REBUILD_MISSING ) {/* * - In case of two failures, where rbio->failb != -1: *
@@ -2008,8 +2009,6 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)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 ; rbio->failb =-1 ;
Signature · 1 line
2.9.4
Quoted 3 lines · Liu Bo
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.
Please add a comment that describes why the READ and REBUILD can be merged together, it's not obvious from the code.
Quoted 7 lines · David Sterba
Quoted 3 lines · Liu Bo
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.
Please add a comment that describes why the READ and REBUILD can be merged together, it's not obvious from the code.
Will update it.
Thanks,
-liubo
PATCH v2 1/1 Btrfs: replace: cache rbio when rebuild data on missing device
In reply to Liu BoRebuild 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.
---
v2: Add comments to explain why REBUILD needs to be merged.
fs/btrfs/raid56.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/btrfs/raid56.c +7 -3
@@ -1987,7 +1987,13 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)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 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)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 ;
Signature · 1 line
2.14.1.40.g8e62ba1
Quoted 6 lines · Liu Bo
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 <[email protected]>Signed-off-by Liu Bo <[email protected]>
Added to next, thanks.