From: Liu Bo Date: Mon, 11 Dec 2017 21:56:31 +0000 (-0700) Subject: Btrfs: do not merge rbios if their fail stripe index are not identical X-Git-Tag: v4.19~1424^2~57 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cc54ff626a56fdd7c22febd55ed24676fda8ed83;p=platform%2Fkernel%2Flinux-rpi.git Btrfs: do not merge rbios if their fail stripe index are not identical Since fail stripe index in rbio would be used to decide which algorithm reconstruction would be run, we cannot merge rbios if their's fail striped indexes are different, otherwise, one of the two reconstructions would fail. Signed-off-by: Liu Bo Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 945e940..7b382ee 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -600,6 +600,25 @@ static int rbio_can_merge(struct btrfs_raid_bio *last, if (last->operation == BTRFS_RBIO_REBUILD_MISSING) return 0; + if (last->operation == BTRFS_RBIO_READ_REBUILD) { + int fa = last->faila; + int fb = last->failb; + int cur_fa = cur->faila; + int cur_fb = cur->failb; + + if (last->faila >= last->failb) { + fa = last->failb; + fb = last->faila; + } + + if (cur->faila >= cur->failb) { + cur_fa = cur->failb; + cur_fb = cur->faila; + } + + if (fa != cur_fa || fb != cur_fb) + return 0; + } return 1; }