diff mbox

[2/3] Btrfs: do not merge rbios if their fail stripe index are not identical

Message ID 20171204224037.7556-3-bo.li.liu@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Liu Bo Dec. 4, 2017, 10:40 p.m. UTC
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 index are different, otherwise, one of the two
reconstructions would fail.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 fs/btrfs/raid56.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

David Sterba Dec. 5, 2017, 6:24 p.m. UTC | #1
On Mon, Dec 04, 2017 at 03:40:36PM -0700, Liu Bo wrote:
> 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 index are different, otherwise, one of the two
> reconstructions would fail.
> 
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> ---
>  fs/btrfs/raid56.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
> index c4188fb..8d09535 100644
> --- a/fs/btrfs/raid56.c
> +++ b/fs/btrfs/raid56.c
> @@ -601,6 +601,15 @@ 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 < last->failb) ? last->faila : last->failb;
> +		int fb = (last->faila < last->failb) ? last->failb : last->faila;
> +		int cur_fa = (cur->faila < cur->failb) ? cur->faila : cur->failb;
> +		int cur_fb = (cur->faila < cur->failb) ? cur->failb : cur->faila;

Can you please convert it to if/else? All the lines look very similar.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index c4188fb..8d09535 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -601,6 +601,15 @@  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 < last->failb) ? last->faila : last->failb;
+		int fb = (last->faila < last->failb) ? last->failb : last->faila;
+		int cur_fa = (cur->faila < cur->failb) ? cur->faila : cur->failb;
+		int cur_fb = (cur->faila < cur->failb) ? cur->failb : cur->faila;
+
+		if (fa != cur_fa || fb != cur_fb)
+			return 0;
+	}
 	return 1;
 }