Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1015891iog; Wed, 15 Jun 2022 18:23:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vCnYA0oTIdO/lJcpRcn8CcB+U+EgQymyNFMR8QIy2Pke5o6oMH0zKDsxdVZtvnbrDQlzKR X-Received: by 2002:a63:d013:0:b0:3fc:e50f:8e2a with SMTP id z19-20020a63d013000000b003fce50f8e2amr2267434pgf.283.1655342596796; Wed, 15 Jun 2022 18:23:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655342596; cv=none; d=google.com; s=arc-20160816; b=0ZyyfXcd8p5noS+bMDo8wrjqwsBQ/UNX01QXBm+yNoieOsjQnEF9o4CDwTl3kuaRTz lNjjxqBOt8pY6vnbhsLu8T5qTWV/yReS0Y3vE9xVanT0oih4cPOooc45DW5Hw4yxLLAG 8HZbwbGkudnsuA7ZJvndlz+lSuKu4lgDZuyfzI6tpbvJbmXgnEkQf5f4bc2t2yjfcy/h xFey34SnYiQNjjhOlDf/KDEnH5jdpOvdmQED2jbakqnKdpAXDRZ/M3baOLuHabRB2moC QFLcwgbbc6U9Une0mafjlrB+SLJfa4W45tYROJrbSdpvveIvAlatfYCTy1LJzn4z2ab0 ak3g== 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:references :in-reply-to:mime-version:dkim-signature; bh=dm9KKdzRhGSnjO19slJ0Aa3kagafxD8QQfDLc9/TW4s=; b=KkqTC4gDEsDn1tdukUTg9UVThHaPEYFJh9bywteAIwOFeJbp11l9bEu3E2FEoV+4Ol bwN1/7et8r7SsXYxtCpExDUCiAmJBhKP/LU4j1Pb8jJy7Fwa8/Z+4ywaJB+N3XUCA3hk ZSe3q7l45gdmdLL3qJEU+GgqrA5dekpy8p3BZuHAkU6zXh5VkNDwjY0V2i+oqRMwAaEt nTDdlB6H8k9+hxHCcQGSU35SYJaB72W/4Ygg7O4cSjuUNUIcbSaML0XypT/xzbMCGvRg qY4sq63lo4houOcPoqH1xe8NbfXV1qSr5p4dJeWHS/JiZ4O5UxCAM3HfOO7k7qmjHBzV xiuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jLFtxxOQ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a170902cad400b00156b24c4bb6si813727pld.120.2022.06.15.18.22.53; Wed, 15 Jun 2022 18:23:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jLFtxxOQ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245094AbiFPBOX (ORCPT + 99 others); Wed, 15 Jun 2022 21:14:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233633AbiFPBOV (ORCPT ); Wed, 15 Jun 2022 21:14:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C45BD4D605; Wed, 15 Jun 2022 18:14:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7D087B8216A; Thu, 16 Jun 2022 01:14:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22244C341C0; Thu, 16 Jun 2022 01:14:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655342057; bh=F5tbGSVtmtyru8j/GWLjm1O7l/KXlL/Ji+cKQzlskVs=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=jLFtxxOQKCdXV8qk551IPgiKVerltRCjnRn4oVHnXb5MSfuH0gPMV97T6qlCq06eZ b3K9IJYiQysKGurpBS7ZWL9RiR7OQnu06f8BYKMBGQ8CmQqAcPqB0YWMk0JpTI3aH1 vOeEAJcoKlL/Hh+CsGP6Xttr7UDeFpGPcf4AlCekuLn7d+OS2PqUiwq8tQD8aF4x4n LW25DJMMKfTXHfoeK0nd4rhH8Cvrdxsy4yHhxb4YxblevhlFeZe+PjkQbNktbohh55 bNze0GUNmnL+NPZoNspsDDHTID/VT+Lqd4Qv9sUG/QkPNzszf0Ism77lrpOsXqwhw5 Dg3ctmoetnb5g== Received: by mail-wr1-f47.google.com with SMTP id g4so849145wrh.11; Wed, 15 Jun 2022 18:14:17 -0700 (PDT) X-Gm-Message-State: AJIora9i/IW0p+VQayOpSzM4dfA2t+uqBBR5zc/Q6V0FIuDcilHuCOmp wGRZhbmB+ULNdGECkxyqoi6m8S8306MnFjmiMgg= X-Received: by 2002:a5d:64c7:0:b0:216:5021:687f with SMTP id f7-20020a5d64c7000000b002165021687fmr2276576wri.295.1655342055301; Wed, 15 Jun 2022 18:14:15 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6000:18ad:0:0:0:0 with HTTP; Wed, 15 Jun 2022 18:14:14 -0700 (PDT) In-Reply-To: <20220615130014.1490661-1-amir73il@gmail.com> References: <20220615130014.1490661-1-amir73il@gmail.com> From: Namjae Jeon Date: Thu, 16 Jun 2022 10:14:14 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v15] vfs: fix copy_file_range() regression in cross-fs copies To: Amir Goldstein Cc: Steve French , Olga Kornievskaia , Luis Henriques , Al Viro , Dave Chinner , "Darrick J . Wong" , He Zhe , Paul Gortmaker , linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, Nicolas Boichat , kernel test robot , Luis Henriques Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 2022-06-15 22:00 GMT+09:00, Amir Goldstein : > A regression has been reported by Nicolas Boichat, found while using the > copy_file_range syscall to copy a tracefs file. Before commit > 5dae222a5ff0 ("vfs: allow copy_file_range to copy across devices") the > kernel would return -EXDEV to userspace when trying to copy a file across > different filesystems. After this commit, the syscall doesn't fail anymore > and instead returns zero (zero bytes copied), as this file's content is > generated on-the-fly and thus reports a size of zero. > > Another regression has been reported by He Zhe - the assertion of > WARN_ON_ONCE(ret == -EOPNOTSUPP) can be triggered from userspace when > copying from a sysfs file whose read operation may return -EOPNOTSUPP. > > Since we do not have test coverage for copy_file_range() between any > two types of filesystems, the best way to avoid these sort of issues > in the future is for the kernel to be more picky about filesystems that > are allowed to do copy_file_range(). > > This patch restores some cross-filesystem copy restrictions that existed > prior to commit 5dae222a5ff0 ("vfs: allow copy_file_range to copy across > devices"), namely, cross-sb copy is not allowed for filesystems that do > not implement ->copy_file_range(). > > Filesystems that do implement ->copy_file_range() have full control of > the result - if this method returns an error, the error is returned to > the user. Before this change this was only true for fs that did not > implement the ->remap_file_range() operation (i.e. nfsv3). > > Filesystems that do not implement ->copy_file_range() still fall-back to > the generic_copy_file_range() implementation when the copy is within the > same sb. This helps the kernel can maintain a more consistent story > about which filesystems support copy_file_range(). > > nfsd and ksmbd servers are modified to fall-back to the > generic_copy_file_range() implementation in case vfs_copy_file_range() > fails with -EOPNOTSUPP or -EXDEV, which preserves behavior of > server-side-copy. > > fall-back to generic_copy_file_range() is not implemented for the smb > operation FSCTL_DUPLICATE_EXTENTS_TO_FILE, which is arguably a correct > change of behavior. > > Fixes: 5dae222a5ff0 ("vfs: allow copy_file_range to copy across devices") > Link: > https://lore.kernel.org/linux-fsdevel/20210212044405.4120619-1-drinkcat@chromium.org/ > Link: > https://lore.kernel.org/linux-fsdevel/CANMq1KDZuxir2LM5jOTm0xx+BnvW=ZmpsG47CyHFJwnw7zSX6Q@mail.gmail.com/ > Link: > https://lore.kernel.org/linux-fsdevel/20210126135012.1.If45b7cdc3ff707bc1efa17f5366057d60603c45f@changeid/ > Link: > https://lore.kernel.org/linux-fsdevel/20210630161320.29006-1-lhenriques@suse.de/ > Reported-by: Nicolas Boichat > Reported-by: kernel test robot > Signed-off-by: Luis Henriques > Fixes: 64bf5ff58dff ("vfs: no fallback for ->copy_file_range") > Link: > https://lore.kernel.org/linux-fsdevel/20f17f64-88cb-4e80-07c1-85cb96c83619@windriver.com/ > Reported-by: He Zhe > Signed-off-by: Amir Goldstein > --- > Hi Luis, Namje, > > Thank you for testing v14 [1]. Unfortunately (or fortunately), > kernel test robot has alerted me on LTP test failure [2] with v14. > > The patch had changed behavior of same sb case when it should not have. > So I did not apply you Tested-by and I would like to request from you > to test v15. Works fine. You can add tested-by tag for ksmbd. Tested-by: Namjae Jeon Thanks!