Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3223763pxb; Fri, 12 Feb 2021 12:26:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCezl9YOU5039+emAGBWdLR4tJSrfDsYUMXflfbYbFO1x3ectAKvmswL4HXOMi30ALvmi3 X-Received: by 2002:aa7:d80b:: with SMTP id v11mr5148730edq.17.1613161594236; Fri, 12 Feb 2021 12:26:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613161594; cv=none; d=google.com; s=arc-20160816; b=pCzHrbqCWuU+pq/h5qfjr/NKeGVCL9sO3rv+JYxQc9CmulEVbznRgdGCBMDJyvdl6g DxsP2MGYizcIHFAYdVVY4CoLRfeBsa+VSHq4IOq2wtPo4yUIF1ZnLPAsvqS4GofqMFqO GG7+D1ZoR5juwKApZhdw7b/MoKOBbsm0uG8mnlqdBNN7b0IuJ0qhy5m64z/EVHCe0Pzs qtf5fgx1REm5GdMuSCe4mmgSGKgZjLN13KTPfla5Da9KkiOEsLyM4ci/mHoK0Wp7SU5n K03hZj7ua9+QrYCRepO8eIVqfZJ6/dbEsD80DiGsp7vmJT/wknX1r0eD3eswQhXd+Nf8 5Xyw== 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=jt/znij/3B8fOvG2/6cCyKxwvx+Ld8xIFxr8VpQdpGs=; b=ypY5irMWArT1G3JjG6hIVhET7MTouVZERkG3/rubL8fzCTvyrijhJeNzdDXpTLpbK8 gigEOvFi5ts/R4l7oJ0vlxyvl89mzoQhY7xAxR7pGMJM7yseun8C88frZctC5/OzJkAp VCiFTrYQVrNNQ7sz0X+Cr3Vkm3OmaJehsinx+Yj58dAY5/RU6mvpQRA68/szuCGibzOR KAFVNekRUOp+WfRsZSgJio5FsjBn7XV+XNhnFUpzFTsx/T1j2jNkJRB7eUnQmP03nz1u DeP5vVkk6G9xcuTjUJPWqCDfD5+n1snDsAMBj0M4/Wnras8zHln/d3DfwTNRjr2mcFuM xKqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@golang-org.20150623.gappssmtp.com header.s=20150623 header.b=UMNFf3VN; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=golang.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e22si8506257edu.45.2021.02.12.12.26.11; Fri, 12 Feb 2021 12:26:34 -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; dkim=pass header.i=@golang-org.20150623.gappssmtp.com header.s=20150623 header.b=UMNFf3VN; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=golang.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbhBLUXk (ORCPT + 99 others); Fri, 12 Feb 2021 15:23:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbhBLUX2 (ORCPT ); Fri, 12 Feb 2021 15:23:28 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FD5BC0613D6 for ; Fri, 12 Feb 2021 12:22:47 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id w1so1153754ejf.11 for ; Fri, 12 Feb 2021 12:22:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jt/znij/3B8fOvG2/6cCyKxwvx+Ld8xIFxr8VpQdpGs=; b=UMNFf3VNvvXt7dkwZkk67PYsZgTlumZvT3waqw6JYJE4qEKa+y1zf4JNt+5R+2zqqm yN/E5gw7Vfqut29zBhqcTM4yAHaJGHxWDDouOftu/xKLEz+T35rs9UbgrWnPtytQTmv7 s6WiKQE6Wsc6N5p1TTzP844IK6c2ZtlNQPPFcQacJZzQrP+3MuEW4r3Wz0FAMyAMGR3t FmOHlkR8jEB/c/ZwfNjnDxLWmfoTi5F3fl8jml+xhf6D9dKtsa9ScwLTZ1MWQJ5LPMFK LXjF3ba1y0rX2nqh+h6xyOX4krOzF/W+vYlw1wkUTZ69oSlWMrIWbaTmnooEXSQcl0gj t6Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jt/znij/3B8fOvG2/6cCyKxwvx+Ld8xIFxr8VpQdpGs=; b=GlQGpA96BE5uICp/e+aH06XQOL6WTNC/y+HU/91FEWvLPThOsqOB0TuwxAYuv1y2qL sac4kIHkOpFjEcXiUUlK2SoreQSb2t89ithht7QIGkunZRErU4jB6lLzbkyHmzeXBqYe MkCXT8yOh5eSJ2Rj432BGDdrzUf9Q6eb7T7wNKHaUPkiNOLG/DNMoYV0HnVdbvw7dAnd TXIcIqsCb4AjHhBOraHXP1reI8TqDGaXHT/7C9aX7/bmq7fx/9N5WJXZt6NKout7bcRa spQohxO/qYW+eOrvGcd+sAKKkCPQAVhQwmozaBUoAgMxjYKVfs4WlVjWbJSWd7CG4Bw/ 4LfQ== X-Gm-Message-State: AOAM530U6wjgaIh2TFiYhFmGHaCheAIUaS8ZbSl5opkVchZkcDaiOXMa DfDJ7tQW+73vvNxfRrM+QFTmPcAJIR8EnaSnVTrNBw== X-Received: by 2002:a17:906:7687:: with SMTP id o7mr4715498ejm.209.1613161365986; Fri, 12 Feb 2021 12:22:45 -0800 (PST) MIME-Version: 1.0 References: <20210212044405.4120619-1-drinkcat@chromium.org> <20210212124354.1.I7084a6235fbcc522b674a6b1db64e4aff8170485@changeid> In-Reply-To: From: Ian Lance Taylor Date: Fri, 12 Feb 2021 12:22:33 -0800 Message-ID: Subject: Re: [PATCH 1/6] fs: Add flag to file_system_type to indicate content is generated To: Greg KH Cc: Nicolas Boichat , "Darrick J . Wong" , Alexander Viro , Luis Lozano , Dave Chinner , linux-fsdevel@vger.kernel.org, lkml Content-Type: multipart/mixed; boundary="000000000000302b1d05bb296631" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000302b1d05bb296631 Content-Type: text/plain; charset="UTF-8" On Fri, Feb 12, 2021 at 8:28 AM Greg KH wrote: > > On Fri, Feb 12, 2021 at 07:59:04AM -0800, Ian Lance Taylor wrote: > > On Fri, Feb 12, 2021 at 7:45 AM 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? > > > > I don't work on the kernel, so I can't tell you which it is. You will > > have to decide. > > As you have the userspace code, it should be easier for you to test this > on an older kernel. I don't have your userspace code... Sorry, I'm not sure what you are asking. I've attached a sample Go program. On kernel version 2.6.32 this program exits 0. On kernel version 5.7.17 it prints got "" want "./foo\x00" and exits with status 1. This program hardcodes the string "/proc/self/cmdline" for convenience, but of course the same results would happen if this were a generic copy program that somebody invoked with /proc/self/cmdline as a command line option. I could write the same program in C easily enough, by explicitly calling copy_file_range. Would it help to see a sample C program? > > From my perspective, as a kernel user rather than a kernel developer, > > a system call that silently fails for certain files and that provides > > no way to determine either 1) ahead of time that the system call will > > fail, or 2) after the call that the system call did fail, is a useless > > system call. > > Great, then don't use copy_file_range() yet as it seems like it fits > that category at the moment :) That seems like an unfortunate result, but if that is the determining opinion then I guess that is what we will have to do in the Go standard library. Ian --000000000000302b1d05bb296631 Content-Type: text/x-go; charset="US-ASCII"; name="foo7.go" Content-Disposition: attachment; filename="foo7.go" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kl2qjoq50 cGFja2FnZSBtYWluCgppbXBvcnQgKAoJImJ5dGVzIgoJImZtdCIKCSJpbyIKCSJpby9pb3V0aWwi Cgkib3MiCikKCmZ1bmMgbWFpbigpIHsKCXRtcGZpbGUsIGVyciA6PSBpb3V0aWwuVGVtcEZpbGUo IiIsICJjb3B5X2ZpbGVfcmFuZ2UiKQoJaWYgZXJyICE9IG5pbCB7CgkJZm10LkZwcmludChvcy5T dGRlcnIsIGVycikKCQlvcy5FeGl0KDEpCgl9CglzdGF0dXMgOj0gY29weSh0bXBmaWxlKQoJb3Mu UmVtb3ZlKHRtcGZpbGUuTmFtZ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