From mboxrd@z Thu Jan 1 00:00:00 1970 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 8AB2FEB64DC for ; Sun, 9 Jul 2023 11:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230376AbjGILT2 (ORCPT ); Sun, 9 Jul 2023 07:19:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbjGILT1 (ORCPT ); Sun, 9 Jul 2023 07:19:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE916B5 for ; Sun, 9 Jul 2023 04:19:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 66D6560BEB for ; Sun, 9 Jul 2023 11:19:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74B04C433C8; Sun, 9 Jul 2023 11:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1688901565; bh=wIDjWhyOgdYnH1+qBDyWt/fNT/CuYZ+3Y6INCqz6IMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SCO0Zuf5xhTV8NKWQEv3bu2C319CB4x9Q1aTQ4J/qccXjJm5EXYoSAKJd+dP6hKP/ rNzC2sWnJMPKqeQ60o304WUT4HuiYKRsbazovLqgR40C0hax02ROrdXxzOLcPPHZkd DuesZ5mkzNmgAKjq0yr2RK3nO14lWZDDrhQsZZA4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johannes Thumshirn , Josef Bacik , Christoph Hellwig , David Sterba , Sasha Levin Subject: [PATCH 6.3 037/431] btrfs: fix file_offset for REQ_BTRFS_ONE_ORDERED bios that get split Date: Sun, 9 Jul 2023 13:09:45 +0200 Message-ID: <20230709111451.966395548@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230709111451.101012554@linuxfoundation.org> References: <20230709111451.101012554@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Christoph Hellwig [ Upstream commit c731cd0b6d255e4855a7cac9f276864032ab2387 ] 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") Reviewed-by: Johannes Thumshirn Reviewed-by: Josef Bacik Signed-off-by: Christoph Hellwig Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- 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 67e5156f940d3..4bb2c6f4ad0e7 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -79,8 +79,7 @@ static struct btrfs_bio *btrfs_split_bio(struct btrfs_fs_info *fs_info, btrfs_bio_init(bbio, orig_bbio->inode, NULL, orig_bbio); 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; -- 2.39.2