Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp66692rdb; Mon, 4 Dec 2023 21:02:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFtrWXpZy05kqHwlh5grxOidS/r3R8vMt1gZs5KxZIKP9C4F9liWCncKZ/hf021OYnkMXL X-Received: by 2002:a05:6358:9106:b0:170:302b:545f with SMTP id q6-20020a056358910600b00170302b545fmr3129611rwq.56.1701752523076; Mon, 04 Dec 2023 21:02:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701752523; cv=none; d=google.com; s=arc-20160816; b=vw7DGRxTyznKM2sRh9UN5xjAvq59ycFBJAhPbrTxuwfyQi5KQbI0LxcJfFpxeUm0u4 exvzXPAFLkaFUVdfSVmewTZzhey+MU6bquV4EdBwIhWMgNVS6G7iu8aGMo/Bm+KFS8zq gzL/SsGTjf4hTgXpBB2g/huG3vagrdV/UVmalnagSN09PFhwKBOtw32QPxzKR/kZeBce me8X8AVlWnPhK2lcOU06MoMgTFqA0HH/ThoOWONasPUgk2DUsjNau7xbW47xD7hwwJoZ 2lnsgoCZgma1pPMP67US2RCb99u90qG+J0E9kjoY8e/cv4p9Y1+VnRNmR73FXev/Kb9M SZXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ylB6tl8v6jO1VPySOnRISUwym4+3Pn1Vco6nga8IZeA=; fh=m20MDshkels+oIHnSVH7Va0Fufc79C8rdRPTA7Sbuss=; b=kA8MgQSKP2Q7GUCB6eOyVbte1kTJCmGJWPJON7LaDdvayNNwZ6qAMyosNCNFhsklix jfWhgLUOSmzdS/GgMT+WI+xi0RhQn8Gtbgi6+uDK9rnUZ4dwu7E8E+2DvlrMCBJYmr7R 1drDu27Fvvk0ua1du+wvJd3U3nXxsQ2EQ8kQUStv0RFuKBPPFPTEPFoj9O+/7kgytCYs Dkepw3esfvAEDLTKlS8dNpwp/eMs5pO6+sGizAussjyYYI/jhTYqcSGf1KJgYuctVbYi pmz4IFs36oZJauYWxA/n3SCfWSBRpa2Nqt4pThxEoCkUc4avvo82CLbK8wtWIZgE3GXw 5mtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=evI5LMcF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id r7-20020a635d07000000b005bdf59618e3si9451950pgb.497.2023.12.04.21.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 21:02:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=evI5LMcF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 069E8807C769; Mon, 4 Dec 2023 21:01:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229914AbjLEFBM (ORCPT + 99 others); Tue, 5 Dec 2023 00:01:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbjLEFBK (ORCPT ); Tue, 5 Dec 2023 00:01:10 -0500 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9853CA; Mon, 4 Dec 2023 21:01:16 -0800 (PST) Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-daf26d84100so3519792276.3; Mon, 04 Dec 2023 21:01:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701752476; x=1702357276; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ylB6tl8v6jO1VPySOnRISUwym4+3Pn1Vco6nga8IZeA=; b=evI5LMcFMoH5+BP1H1fwNz7ImKcLeRMKba16mx9W07v7h8XukDlqdo75hCaVMVskZm o78iGJ5YLOMFv3r0Xr7Jhh01xbAIMWFqEqH87RiKEFDPK8LnlZLY4mVtj4vxdWv1P2Rl uQC2cUufAWBMkTe+/Hm24XH3Msab26mmJ/P5RHUlto9WEwBKClWhDv8kmO4eT2BgYDqw qWVqUZptTYu1+5h+YoSkthiIWhuLKGvpZbpxag0R+fwjqzSV3h6yZapzn0qT95K9Txf8 d96cjqUohCjAdM/pzGR2n8bYQxEyo4Tvr4UyIU+fhwldre/VV5wEdUmXDvJGENO1HTyu srsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701752476; x=1702357276; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ylB6tl8v6jO1VPySOnRISUwym4+3Pn1Vco6nga8IZeA=; b=AOI3mMZ5TMIVa7L+L67UsSvruT6HvV3s7/njQOC8mlEiv2+zRwP/arzm0knzagRgSX gH2yP4y0wBZ+FqL+f3da73wP9d/4yMIv7A8LNapgUmZ5LFrhMTagUh2PaGYbj15ILKLn r6RV/KXVAM1eC8JA66WvrvY/Y0/cHWompEsFvIbhobRLU5bXwfzY0aSQmZH60AVz/Giy 8JLFbvrTp0ovsCCs5q+dUVcOnE0Ty+ReqUJ2uZ5heZZ0+87nJeNPNd13kkLSGsZ6+h0O hQg8JOmPjHlaZiHPYnixncPJ6bAxARLvj9eAxID5JmMBhUEVMEHNbt4oMHh9ATd9BKzm keQw== X-Gm-Message-State: AOJu0YymPzoWtfayuWZrcXSyMapLWPKbt4HLUxkhVBxgkAKA02ditj2M +ICtP6OxkrfND0gn90u3ghwyZuIzqEklc1H8ENs= X-Received: by 2002:a25:8d0b:0:b0:d9b:eb86:2b26 with SMTP id n11-20020a258d0b000000b00d9beb862b26mr3204170ybl.21.1701752475945; Mon, 04 Dec 2023 21:01:15 -0800 (PST) MIME-Version: 1.0 References: <20231130141624.3338942-4-amir73il@gmail.com> <20231205001620.4566-1-spasswolf@web.de> In-Reply-To: From: Amir Goldstein Date: Tue, 5 Dec 2023 07:01:04 +0200 Message-ID: Subject: Re: [PATCH] fs: read_write: make default in vfs_copy_file_range() reachable To: Bert Karwatzki , Christian Brauner Cc: Jan Kara , axboe@kernel.dk, dhowells@redhat.com, hch@lst.de, jlayton@kernel.org, josef@toxicpanda.com, linux-fsdevel@vger.kernel.org, miklos@szeredi.hu, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Content-Type: multipart/mixed; boundary="000000000000d341cf060bbc1fb5" X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 04 Dec 2023 21:01:29 -0800 (PST) --000000000000d341cf060bbc1fb5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Dec 5, 2023 at 5:45=E2=80=AFAM Amir Goldstein = wrote: > > On Tue, Dec 5, 2023 at 2:16=E2=80=AFAM Bert Karwatzki = wrote: > > > > If vfs_copy_file_range() is called with (flags & COPY_FILE_SPLICE =3D= =3D 0) > > and both file_out->f_op->copy_file_range and file_in->f_op->remap_file_= range > > are NULL, too, the default call to do_splice_direct() cannot be reached= . > > This patch adds an else clause to make the default reachable in all > > cases. > > > > Signed-off-by: Bert Karwatzki > > Hi Bert, > > Thank you for testing and reporting this so early!! > > I would edit the commit message differently, but anyway, I think that > the fix should be folded into commit 05ee2d85cd4a ("fs: use > do_splice_direct() for nfsd/ksmbd server-side-copy"). > > Since I end up making a mistake every time I touch this code, > I also added a small edit to your patch below, that should make the logic > more clear to readers. Hopefully, that will help me avoid making a mistak= e > the next time I touch this code... > > Would you mind testing my revised fix, so we can add: > Tested-by: Bert Karwatzki > when folding it into the original patch? > Attached an even cleaner version of the fix patch for you to test. I tested fstests check -g copy_range on ext4. My fault was that I had tested earlier only on xfs and overlayfs (the two other cases in the if/else if statement). Thanks, Amir. > > --- > > fs/read_write.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/fs/read_write.c b/fs/read_write.c > > index e0c2c1b5962b..3599c54bd26d 100644 > > --- a/fs/read_write.c > > +++ b/fs/read_write.c > > @@ -1554,6 +1554,8 @@ ssize_t vfs_copy_file_range(struct file *file_in,= loff_t pos_in, > > /* fallback to splice */ > > if (ret <=3D 0) > > splice =3D true; > > + } else { > > This is logically correct because of the earlier "same sb" check in > generic_copy_file_checks(), but we better spell out the logic here as wel= l: > > + } else if (file_inode(file_in)->i_sb =3D=3D > file_inode(file_out)->i_sb) { > + /* Fallback to splice for same sb copy for > backward compat */ > > > + splice =3D true; > > } > > > > file_end_write(file_out); > > -- > > 2.39.2 > > > > Since linux-next-20231204 I noticed that it was impossible to start the > > game Path of Exile (using the steam client). I bisected the error to > > commit 05ee2d85cd4ace5cd37dc24132e3fd7f5142ebef. Reverting this commit > > in linux-next-20231204 made the game start again and after inserting > > printks into vfs_copy_file_range() I found that steam (via python3) > > calls this function with (flags & COPY_FILE_SPLICE =3D=3D 0), > > file_out->f_op->copy_file_range =3D=3D NULL and > > file_in->f_op->remap_file_range =3D=3D NULL so the default is never rea= ched. > > This patch adds a catch all else clause so the default is reached in > > all cases. This patch fixes the describe issue with steam and Path of > > Exile. > > > > Bert Karwatzki --000000000000d341cf060bbc1fb5 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-fs-fix-vfs_copy_file_range-for-files-on-same-sb.patch" Content-Disposition: attachment; filename="0001-fs-fix-vfs_copy_file_range-for-files-on-same-sb.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lprvdg970 RnJvbSAzM2ViM2NhZWFjYjUyYTQ2ZjgwODk4NDk2OWM4MDg1MjhkMTBlZTAxIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBBbWlyIEdvbGRzdGVpbiA8YW1pcjczaWxAZ21haWwuY29tPgpE YXRlOiBUdWUsIDUgRGVjIDIwMjMgMDY6MjY6NTcgKzAyMDAKU3ViamVjdDogW1BBVENIXSBmczog Zml4IHZmc19jb3B5X2ZpbGVfcmFuZ2UoKSBmb3IgZmlsZXMgb24gc2FtZSBzYgoKY29weV9maWxl LXJhbmdlKCkgc2hvdWxkIGZhbGxiYWNrIHRvIHNwbGljZSB3aXRoIHR3byBmaWxlcyBvbiBzYW1l IHNiCnRoYXQgZG9lcyBub3QgaW1wbGVtZW50IC0+Y29weV9maWxlX3JhbmdlKCkgbm9yIC0+cmVt YXBfZmlsZV9yYW5nZSgpLgoKRml4ZXM6IDA0MmU0ZDlkMTdhZSAoImZzOiB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