Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7062747pxb; Wed, 17 Feb 2021 23:42:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrTIACnaUYIBwTDktCfIleUnJsBQ2j9ugPhhcjg4svbIPc9ZYP3wglrf0J+XD32+Y+Xcxy X-Received: by 2002:a05:6402:b2d:: with SMTP id bo13mr2733873edb.280.1613634143433; Wed, 17 Feb 2021 23:42:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613634143; cv=none; d=google.com; s=arc-20160816; b=ppMPiKjagwViZbDbpiBHdIpnOG60ifIfReaOOOu9gpT06HbCtpoRLrQpzeFhFWu4Bt AnGHu+PO1VcbzlYXpp4EuL7z7j1oGbC5L03Nb/25kALhH+l1BY+skOpp7ZzRKOqXeQca x4iAE/dREhzMGQ/tZbe4NIts6Y0RTnh7psPGVftCthBEcb14lbPAmrj0BzWNPjCpt2qp uZCiRY8ev5Kt5NdjaAZ2j6BTpD4oBjuTCzI7fVx9U+iWKdT9JqoWtZB2xKFcY8GYrqAX Wydn81REKSARtB75G/YBK7+RTWesQE/vtVq6BLqft4uVDA4q9vbbnpSWHnmzPUvnp62Z FPTw== 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:dkim-signature; bh=3gp1a9WmxRQvQVlMU6P3JytLr0+Eli1IQAzgvrGUb4A=; b=MJt3xvAJBmyYuqYvtgNCpAW7jJKfzanWsZIz7QQe6Te4py2zRDtiXRKSa2NDeEjh9+ 9803zeGX3P/CqRU6oVIroK2ZmakTsYo4mA7OoyqQ+7hFCykGTb8VNRB1scD4v5TPlQpu 9AMzVOq9GjGmCF+5T/8ymDYT0FWwwDBv8+p91jAc0KZzHrV9rACN5HZwt11fah9B8nnQ axzV7mcdF2m/P5zu8a9aH7tBah5EsvAgQ7msuhrJap2t9hp02fHGCvDIE/zOb+TKvTBx fTr8z5FDJpGhMB0CNyhBvyTA4N8Aln651X9ulHghf59NLVqPP4soQ4HbhwOg3B1D/A4D BbKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nuuVLco0; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b32si3180153edf.148.2021.02.17.23.41.50; Wed, 17 Feb 2021 23:42:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-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=@linuxfoundation.org header.s=korg header.b=nuuVLco0; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229577AbhBRHkw (ORCPT + 99 others); Thu, 18 Feb 2021 02:40:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:38744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231430AbhBRHjA (ORCPT ); Thu, 18 Feb 2021 02:39:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4722D64DE0; Thu, 18 Feb 2021 07:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613633693; bh=sjajRiTXns4+pD+gjYTsvSp91C0M53TJNj6vUwdi4zI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nuuVLco0VtpvNqIZUSpPN0Ndt0DVjY30kFF+9i7jVsea7VCkByEQacOwl8C/FiWbo FAQIIojb/4410HMJVvN09W/dBS/mXtuK9ged/kDsSbarIJ8WOWygRjS6MWt6G9iLLX tPfsDE0sq+g/EQLfVZFTi7Ki/t5dWuwfstyBgdTw= Date: Thu, 18 Feb 2021 08:34:49 +0100 From: "gregkh@linuxfoundation.org" To: Andreas Dilger Cc: Amir Goldstein , Steve French , Anna Schumaker , Luis Henriques , Trond Myklebust , "samba-technical@lists.samba.org" , "drinkcat@chromium.org" , "iant@google.com" , "linux-cifs@vger.kernel.org" , "darrick.wong@oracle.com" , "linux-kernel@vger.kernel.org" , "jlayton@kernel.org" , "llozano@chromium.org" , "linux-nfs@vger.kernel.org" , "miklos@szeredi.hu" , "viro@zeniv.linux.org.uk" , "dchinner@redhat.com" , "linux-fsdevel@vger.kernel.org" , "sfrench@samba.org" , "ceph-devel@vger.kernel.org" Subject: Re: [PATCH v2] vfs: prevent copy_file_range to copy across devices Message-ID: References: <87blckj75z.fsf@suse.de> <874kibkflh.fsf@suse.de> <216103D5-0575-4BFC-9802-2C21A1B12DF9@dilger.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <216103D5-0575-4BFC-9802-2C21A1B12DF9@dilger.ca> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Feb 17, 2021 at 05:50:35PM -0700, Andreas Dilger wrote: > On Feb 17, 2021, at 1:08 AM, Amir Goldstein wrote: > > > > You are missing my point. > > Never mind which server. The server does not *need* to rely on > > vfs_copy_file_range() to copy files from XFS to ext4. > > The server is very capable of implementing the fallback generic copy > > in case source/target fs do not support native {copy,remap}_file_range(). > > > > w.r.t semantics of copy_file_range() syscall vs. the fallback to userespace > > 'cp' tool (check source file size before copy or not), please note that the > > semantics of CIFS_IOC_COPYCHUNK_FILE are that of the former: > > > > rc = cifs_file_copychunk_range(xid, src_file.file, 0, dst_file, 0, > > src_inode->i_size, 0); > > > > It will copy zero bytes if advertised source file size if zero. > > > > NFS server side copy semantics are currently de-facto the same > > because both the client and the server will have to pass through this > > line in vfs_copy_file_range(): > > > > if (len == 0) > > return 0; > > > > IMO, and this opinion was voiced by several other filesystem developers, > > the shortend copy semantics are the correct semantics for copy_file_range() > > syscall as well as for vfs_copy_file_range() for internal kernel users. > > > > I guess what this means is that if the 'cp' tool ever tries an opportunistic > > copy_file_range() syscall (e.g. --cfr=auto), it may result in zero size copy. > > Having a syscall that does the "wrong thing" when called on two files > doesn't make sense. Expecting userspace to check whether source/target > files supports CFR is also not practical. This is trivial for the > kernel to determine and return -EOPNOTSUPP to the caller if the source > file (procfs/sysfs/etc) does not work with CFR properly. How does the kernel "know" that a specific file in a specific filesystem will not work with CFR "properly"? That goes back to the original patch which tried to label each and every filesystem type with a "supported/not supported" type of flag, which was going to be a mess, especially as it seems that this might be a file-specific thing, not a filesystem-specific thing. The goal of the patch _should_ be that the kernel figure it out itself, but so far no one seems to be able to explain how that can be done :( So, any hints? thanks, greg k-h