Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3317927pxb; Fri, 12 Feb 2021 15:29:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJya/gJNqfDZqoIjNcNpwI1xqpYRAjPJPFOFd0kflzhJznM6s6/bJ2ZLl630R0e+EKvR+75i X-Received: by 2002:a17:906:4712:: with SMTP id y18mr5270829ejq.529.1613172580695; Fri, 12 Feb 2021 15:29:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613172580; cv=none; d=google.com; s=arc-20160816; b=p31eN6RuuW26f7cgZvFX0TFMqAXGzC+Oq8GvzVRxRyrrHUVciB2w5HIcSaALqbz7ei E9MWQCX2B6v59SH7V/hLrOhhOrR1jTmCPUp8DLuhC+CnO0DWmc17k5ZS1GcFiZvz/l3j u1wyELo55eXme9VaUFafeVkmyGKcZnzmRPr0RKOkLNmqCZPQl59y2o5M6wOhd0wV09H7 LKEo66KGunXJVGQgcnn1gzcTS+NF/aVEnLda6e6heM5RWv/7LCcNeTeDKyZM/T6/sKc+ 3hHxEhtJ4zy+JbKSnnifOvOUxj6QCToaAZ/DroYM0wysn875y/sdK06zUDvv9q6RIBJt I2Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=NFYNrKLWF3+JVAFowLwpkdxmMDFjezgLPjpePn8oLOc=; b=R+NDv/nUebTnd805CyjjGetou8tLUHphUXFT5SwN4doAtzx4gsRqh8nUtz3CsQ3VRc QEettujih884V8UZY6K8786dukweZAjHmwlmMwzbaDQmQ9cXQnCFwGqLqf57LUN82tLn ZMAwBRwCOcBcM/hoCgiUj5WWas2IbrjNYiuZS5qckBcdnFS4QmPqiAarkiBIBJH0DeXy wNxsGjv7DENpo8vtAgLcZAQHN7CV+ySOi9bx0FqVPyg3Rwz+zBb97KdQ0El+exqNOu6H V+rPSk3/ugmNolrWgHqkpqvaX6hs8BVGzKoPrqG7LYq5LYwbt+5K6hIHvvArBRrLx/oI WmnA== 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 j16si7490941edv.27.2021.02.12.15.29.17; Fri, 12 Feb 2021 15:29:40 -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 S230270AbhBLX2L (ORCPT + 99 others); Fri, 12 Feb 2021 18:28:11 -0500 Received: from mail106.syd.optusnet.com.au ([211.29.132.42]:53368 "EHLO mail106.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhBLX2K (ORCPT ); Fri, 12 Feb 2021 18:28:10 -0500 Received: from dread.disaster.area (pa49-181-52-82.pa.nsw.optusnet.com.au [49.181.52.82]) by mail106.syd.optusnet.com.au (Postfix) with ESMTPS id B9452781CB0; Sat, 13 Feb 2021 10:27:27 +1100 (AEDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1lAhqQ-001tJx-V0; Sat, 13 Feb 2021 10:27:26 +1100 Date: Sat, 13 Feb 2021 10:27:26 +1100 From: Dave Chinner To: Ian Lance Taylor Cc: Greg KH , Nicolas Boichat , "Darrick J . Wong" , Alexander Viro , Luis Lozano , linux-fsdevel@vger.kernel.org, lkml Subject: Re: [PATCH 1/6] fs: Add flag to file_system_type to indicate content is generated Message-ID: <20210212232726.GW4626@dread.disaster.area> References: <20210212044405.4120619-1-drinkcat@chromium.org> <20210212124354.1.I7084a6235fbcc522b674a6b1db64e4aff8170485@changeid> <20210212230346.GU4626@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=F8MpiZpN c=1 sm=1 tr=0 cx=a_idp_d a=7pwokN52O8ERr2y46pWGmQ==:117 a=7pwokN52O8ERr2y46pWGmQ==:17 a=kj9zAlcOel0A:10 a=qa6Q16uM49sA:10 a=7-415B0cAAAA:8 a=ag1SF4gXAAAA:8 a=8-rjP3H8IrN6C3UD4SsA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 a=Yupwre4RP9_Eg_Bd0iYG:22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 12, 2021 at 03:07:39PM -0800, Ian Lance Taylor wrote: > On Fri, Feb 12, 2021 at 3:03 PM Dave Chinner wrote: > > > > On Fri, Feb 12, 2021 at 04:45:41PM +0100, Greg KH wrote: > > > On Fri, Feb 12, 2021 at 07:33:57AM -0800, Ian Lance Taylor wrote: > > > > On Fri, Feb 12, 2021 at 12:38 AM Greg KH wrote: > > > > > > > > > > Why are people trying to use copy_file_range on simple /proc and /sys > > > > > files in the first place? They can not seek (well most can not), so > > > > > that feels like a "oh look, a new syscall, let's use it everywhere!" > > > > > problem that userspace should not do. > > > > > > > > This may have been covered elsewhere, but it's not that people are > > > > saying "let's use copy_file_range on files in /proc." It's that the > > > > Go language standard library provides an interface to operating system > > > > files. When Go code uses the standard library function io.Copy to > > > > copy the contents of one open file to another open file, then on Linux > > > > kernels 5.3 and greater the Go standard library will use the > > > > copy_file_range system call. That seems to be exactly what > > > > copy_file_range is intended for. Unfortunately it appears that when > > > > people writing Go code open a file in /proc and use io.Copy the > > > > contents to another open file, copy_file_range does nothing and > > > > reports success. There isn't anything on the copy_file_range man page > > > > explaining this limitation, and there isn't any documented way to know > > > > that the Go standard library should not use copy_file_range on certain > > > > files. > > > > > > But, is this a bug in the kernel in that the syscall being made is not > > > working properly, or a bug in that Go decided to do this for all types > > > of files not knowing that some types of files can not handle this? > > > > > > If the kernel has always worked this way, I would say that Go is doing > > > the wrong thing here. If the kernel used to work properly, and then > > > changed, then it's a regression on the kernel side. > > > > > > So which is it? > > > > Both Al Viro and myself have said "copy file range is not a generic > > method for copying data between two file descriptors". It is a > > targetted solution for *regular files only* on filesystems that store > > persistent data and can accelerate the data copy in some way (e.g. > > clone, server side offload, hardware offlead, etc). It is not > > intended as a copy mechanism for copying data from one random file > > descriptor to another. > > > > The use of it as a general file copy mechanism in the Go system > > library is incorrect and wrong. It is a userspace bug. Userspace > > has done the wrong thing, userspace needs to be fixed. > > OK, we'll take it out. > > I'll just make one last plea that I think that copy_file_range could > be much more useful if there were some way that a program could know > whether it would work or not. If you can't tell from userspace that a file has data in it other than by calling read() on it, then you can't use cfr on it. Cheers, Dave. -- Dave Chinner david@fromorbit.com