Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6222116ybl; Wed, 15 Jan 2020 00:36:49 -0800 (PST) X-Google-Smtp-Source: APXvYqx42e7/cK1OJimMNFcX03uf4fAgShR9WZa9C5C5OoIt5mfLfoCArHHHxqYyVt6VDeruHIQM X-Received: by 2002:a9d:7e99:: with SMTP id m25mr1884140otp.212.1579077409568; Wed, 15 Jan 2020 00:36:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579077409; cv=none; d=google.com; s=arc-20160816; b=CcVawjvh+9pKq3LH3oUnWM3trBJbeQGIT2g2Uu3Stjr5kce4P6YXoFAX2V9woXeU+1 KW7XuGXMCEgcYKqUfLgYSViSU9jXmNSgzlaGwIi2JaMuwGpxkG/G25wqDoMu5bz7Ihk2 7k2zD3hAXIeeDBqK8HUHSTnYW3BxnfNP4X2QrihiICbr5a0N6UfQs0MNzWTuJfjTQutc o+4K2ZTDecWC9ZUrb9OcVwaNI7Bf6bVQ6pcf8hqTpyf4D1OWyqKW1sABy1Evzaq4iyTu NE4BVVkvvZ9a5O/tFo3PKrIHwm2nemiNu4VlTWCHLMDJmW5wIIuhlNGW4+eGoOxZcmAe ygUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=bTHfGV3TUKX5wMBR5k9P/B4XkqqDxAE+w2YKL4sVtVE=; b=iTj+wCJQq0mHvsNvWq7ZGxgdogTe18Q71krauZ8Bjlx/xIRp/vmWDNbdKnc1vcW6Dp EdQNqmkmgPdOhlP6aKmU2mkYO1Q4uny/ucNwBjP9TXzjuqeW0T8cVNpOf728DBK0jZCw WmScA9zymaEUttzj3B7lifYnZHMXNEAnOvetP5Afnj+XNruOZnpS8uRuw1H3ZzTnLSgk /5vTSdc5kanTGKuyqm5nmnxjgNrMzfShDKAP9F9B1bK8VuGUIQ9BT3DpeoE2NEkezO// ih5nMKRMHG0KJwVoemIeS+xWeqUj4+QoUgy+jSSVzuewkRWviVp684Qc2vviWO/awoJD Hocw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7si10303366otp.284.2020.01.15.00.36.33; Wed, 15 Jan 2020 00:36:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728927AbgAOIgY (ORCPT + 99 others); Wed, 15 Jan 2020 03:36:24 -0500 Received: from verein.lst.de ([213.95.11.211]:49581 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgAOIgX (ORCPT ); Wed, 15 Jan 2020 03:36:23 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id D06A568B05; Wed, 15 Jan 2020 09:36:19 +0100 (CET) Date: Wed, 15 Jan 2020 09:36:19 +0100 From: Christoph Hellwig To: David Howells Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, hch@lst.de, tytso@mit.edu, adilger.kernel@dilger.ca, darrick.wong@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Making linkat() able to overwrite the target Message-ID: <20200115083619.GA23039@lst.de> References: <3326.1579019665@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3326.1579019665@warthog.procyon.org.uk> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Jan 14, 2020 at 04:34:25PM +0000, David Howells wrote: > > when a file gets invalidated by the server - and, under some circumstances, > modified locally - I have the cache create a temporary file with vfs_tmpfile() > that I'd like to just link into place over the old one - but I can't because > vfs_link() doesn't allow you to do that. Instead I have to either unlink the > old one and then link the new one in or create it elsewhere and rename across. > > Would it be possible to make linkat() take a flag, say AT_LINK_REPLACE, that > causes the target to be replaced and not give EEXIST? Or make it so that > rename() can take a tmpfile as the source and replace the target with that. I > presume that, either way, this would require journal changes on ext4, xfs and > btrfs. This sounds like a very useful primitive, and from the low-level XFS point of view should be very easy to implement and will not require any on-disk changes. I can't really think of any good userspace interface but a new syscall, though.