Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB395C433EF for ; Fri, 17 Jun 2022 10:04:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381044AbiFQKE1 (ORCPT ); Fri, 17 Jun 2022 06:04:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380451AbiFQKE0 (ORCPT ); Fri, 17 Jun 2022 06:04:26 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4947E674EA for ; Fri, 17 Jun 2022 03:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=mO9FoubfZv9BVdvzgTMb5OssfQgEMls3JVSZQYyODSI=; b=o8+b6C23gLcwp0snboG6XOfldO /feb92+US86Q4h4ua3CbxA9op1B7rdcxrD1W0Tn5MfHkp/qnoOqgL2u/yGEUAc0ua8DGvK4iWG7kv zxdcwFjAjsuG7rLJDgKUeb40tKbW7PRRAO5BARXBfQBFo6qun5txuqvd8sgij79FHfzvjrTcOtqZs XSNG4yC4ofumMoFQVU5reFFe9NY+hopV9YXtXsM9gWAj9nFsWxTdRENW9MparNTOA8lHySKdDrr0N eUMgc51WMnOUyqWkFQq6heqLWAyxwZoKuFZ4uGbX9IFTEHQwAegmJ3NploM3Gr+uGFzqyYeoUBJDv pilI7qIA==; Received: from [2001:4bb8:180:36f6:9c91:42c8:8d10:d7ed] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1o28pz-006sjH-DC; Fri, 17 Jun 2022 10:04:23 +0000 From: Christoph Hellwig To: David Sterba , Josef Bacik , Qu Wenruo Cc: linux-btrfs@vger.kernel.org, Johannes Thumshirn Subject: [PATCH 02/10] btrfs: return proper mapped length for RAID56 profiles in __btrfs_map_block() Date: Fri, 17 Jun 2022 12:04:06 +0200 Message-Id: <20220617100414.1159680-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220617100414.1159680-1-hch@lst.de> References: <20220617100414.1159680-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Qu Wenruo For profiles other than RAID56, __btrfs_map_block() returns @map_length as min(stripe_end, logical + *length), which is also the same result from btrfs_get_io_geometry(). But for RAID56, __btrfs_map_block() returns @map_length as stripe_len. This strange behavior is going to hurt incoming bio split at btrfs_map_bio() time, as we will use @map_length as bio split size. Fix this behavior by return @map_length by the same calculatioin as other profiles Signed-off-by: Qu Wenruo [hch: rebased] Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 556a18dca6e9f..943ac43f58e9e 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -6476,7 +6476,10 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, num_stripes = map->num_stripes; max_errors = btrfs_chunk_max_errors(map); - *length = map->stripe_len; + /* Return the length to the full stripe end */ + *length = min(raid56_full_stripe_start + em->start + + data_stripes * stripe_len, + logical + *length) - logical; stripe_index = 0; stripe_offset = 0; } else { -- 2.30.2