From patchwork Wed May 31 07:53:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13261702 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 D2658C7EE24 for ; Wed, 31 May 2023 07:56:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234861AbjEaH4D (ORCPT ); Wed, 31 May 2023 03:56:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234830AbjEaHzf (ORCPT ); Wed, 31 May 2023 03:55:35 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D062EE54 for ; Wed, 31 May 2023 00:54:18 -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=0DsSmdQxV9I1c7ri+g1bPN3CHuAbjhAdNusqmLCn3nQ=; b=roG0xDcz0G+JqIBfZL+J7W7YBK AAO4rE3HjWbECnNOTsonrfhsoStcKCnrIM2pPeoYoUN2YVH9ski3ApaGNIV8bYzNgPLERDcndFgzt yhODsJXIreneUdpZhy+EwPfXa9Qvc82GWmb7qNPTg5LE6lFx12gLiwMm+Bdro45wu5aGREWWMga9e uFxMmJQX6R6MYygqPve7ovq4OCJJ4agE6nagilmX+CRBFcgJQRktYhbDefnGObiL0Mo118dSZos6b NwMGHrdCGvHkCKgcKs64Jd10HEA8Mz0l+KuMsNaz9wDuQZdwYRnhGhajJ/+KVFqW0I01KdzRkqNhP MDN52p4Q==; Received: from [2001:4bb8:182:6d06:f5c3:53d7:b5aa:b6a7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q4Get-00GWpP-2y; Wed, 31 May 2023 07:54:16 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, Johannes Thumshirn Subject: [PATCH 01/17] btrfs: fix file_offset for REQ_BTRFS_ONE_ORDERED bios that get split Date: Wed, 31 May 2023 09:53:54 +0200 Message-Id: <20230531075410.480499-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531075410.480499-1-hch@lst.de> References: <20230531075410.480499-1-hch@lst.de> MIME-Version: 1.0 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 If a bio gets split, it needs to have a proper file_offset for checksum validation and repair to work properly. Based on feedback from Josef, commit 852eee62d31a ("btrfs: allow btrfs_submit_bio to split bios") skipped this adjustment for ONE_ORDERED bios. But if we actually ever need to split a ONE_ORDERED read bio, this will lead to a wrong file offset in the repair code. Right now the only user of the file_offset is logging of an error message so this is mostly harmless, but the wrong offset might be more problematic for additional users in the future. Fixes: 852eee62d31a ("btrfs: allow btrfs_submit_bio to split bios") Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- fs/btrfs/bio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index ae6345668d2d01..42c0ded42fafe5 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -81,8 +81,7 @@ static struct btrfs_bio *btrfs_split_bio(struct btrfs_fs_info *fs_info, btrfs_bio_init(bbio, fs_info, NULL, orig_bbio); bbio->inode = orig_bbio->inode; bbio->file_offset = orig_bbio->file_offset; - if (!(orig_bbio->bio.bi_opf & REQ_BTRFS_ONE_ORDERED)) - orig_bbio->file_offset += map_length; + orig_bbio->file_offset += map_length; atomic_inc(&orig_bbio->pending_ios); return bbio;