Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4568633pxb; Sun, 14 Feb 2021 15:40:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0VLUgKDuQzor3oNUVWgAHxhWmjgAst9NYluC6lAGvNfHNz/tN1SblzoO94bWKB0HVTDu2 X-Received: by 2002:a05:6402:309c:: with SMTP id de28mr12825592edb.96.1613346038919; Sun, 14 Feb 2021 15:40:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613346038; cv=none; d=google.com; s=arc-20160816; b=ys6/E5MZNZeLfQsUS1jLNcGpBN3H8TcaYkLnT++5QFkdmbpChnHvZQPJ7q9nj6tqGc j0IsPxhhsRoKFZJKcdUMbht1/y4ZUkC18X60b70WT7wpMtlFWr0T0pb9vWBrksG0Mu9T mOwKN3JuDg179nZenejaM4jqgJMisqPSwivYdCJG7DhOzHm6ajzayf3aTaeydmOZWXmG 5Qo2DG7JX6yLLbvGad7P613ba9sf9lH4ydbAoT6/Ask7lq0XQPKtmZb/wRj4beURFdNR CoXlxYBXNblYyYDYOqy0JcIx/n8E+Qq3OYiYp4qNKxOnrRGh2gp3Wfo0MRoU3ScCZY7Q EUiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=9QuwEg8QSXv4nlOU7b7WNYhR0s+JlKlrl2xtK/GRHzI=; b=j9Z13gt4pOFx1DTfNSRic5mg/PFmi5M9eiEPpw29BrukWsBSXomDOvJIfCfgOQMWVu 5MKwygn/eeT4uhC+DB18Kn5YqCr3UgoJkCT7WLECRD5mLUlFoyt2JZzIg+OxhU7sL35v HbfC0/Q4yh4eLL5TLXoxyw5ixEENe5UI5AvVrohpwPiBPTxS/J09lGFXXvx2iTkEeLgm S4qBrTis3Rn5ejWu9wHyqxgNMfyhNy7NM27SdeH9+nHA9DEhGulHMwaCSSg2iet3HlhR w1qoghzeeuZHqQK3GY/0+XHp8tVoOyjI7iL7VrM4EfujXMThBAS0+OO5WKGkJF4Adh/A jQ+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lt6si6068230ejb.221.2021.02.14.15.40.15; Sun, 14 Feb 2021 15:40:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230104AbhBNXK2 (ORCPT + 99 others); Sun, 14 Feb 2021 18:10:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbhBNXK1 (ORCPT ); Sun, 14 Feb 2021 18:10:27 -0500 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1F89C061756; Sun, 14 Feb 2021 15:09:46 -0800 (PST) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lBQVi-00E2wA-6b; Sun, 14 Feb 2021 23:09:02 +0000 Date: Sun, 14 Feb 2021 23:09:02 +0000 From: Al Viro To: Nicolas Boichat Cc: "Darrick J . Wong" , Ian Lance Taylor , Luis Lozano , Greg KH , Dave Chinner , Alexey Dobriyan , Alexey Gladkov , Christian Brauner , "Eric W. Biederman" , Ingo Molnar , Kees Cook , "Rafael J. Wysocki" , Steven Rostedt , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/6] Add generated flag to filesystem struct to block copy_file_range Message-ID: References: <20210212044405.4120619-1-drinkcat@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210212044405.4120619-1-drinkcat@chromium.org> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 12, 2021 at 12:43:59PM +0800, Nicolas Boichat wrote: > We hit an issue when upgrading Go compiler from 1.13 to 1.15 [1], > as we use Go's `io.Copy` to copy the content of > `/sys/kernel/debug/tracing/trace` to a temporary file. > > Under the hood, Go 1.15 uses `copy_file_range` syscall to > optimize the copy operation. However, that fails to copy any > content when the input file is from tracefs, with an apparent > size of 0 (but there is still content when you `cat` it, of > course). > > >From discussions in [2][3], it is clear that copy_file_range > cannot be properly implemented on filesystems where the content > is generated at runtime: the file size is incorrect (because it > is unknown before the content is generated), and seeking in such > files (as required by partial writes) is unlikely to work > correctly. > > With this patch, Go's `io.Copy` gracefully falls back to a normal > read/write file copy. > > I'm not 100% sure which stable tree this should go in, I'd say > at least >=5.3 since this is what introduced support for > cross-filesystem copy_file_range (and where most users are > somewhat likely to hit this issue). But let's discuss the patch > series first. No. This is *NOT* an fs-wide flag. Decision regarding the usability of copy_file_range() is on per-file basis. The real constraint is "can freely seek back and expect to find consistent data". That is what's violated for seq_file. And frankly, I would rather add a flag and have seq_open() (and other suckers, if any) clear it. With check being "has both FMODE_PREAD and this new flag".