From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A427C33C9E for ; Sat, 18 Jan 2020 02:20:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 05E272176D for ; Sat, 18 Jan 2020 02:20:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730614AbgARCUp (ORCPT ); Fri, 17 Jan 2020 21:20:45 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:41882 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727033AbgARCUp (ORCPT ); Fri, 17 Jan 2020 21:20:45 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1isdiy-00AaR6-N3; Sat, 18 Jan 2020 02:20:32 +0000 Date: Sat, 18 Jan 2020 02:20:32 +0000 From: Al Viro To: Omar Sandoval Cc: Trond Myklebust , "amir73il@gmail.com" , "dhowells@redhat.com" , "lsf-pc@lists.linux-foundation.org" , "hch@lst.de" , "miklos@szeredi.hu" , "linux-fsdevel@vger.kernel.org" Subject: Re: [LSF/MM/BPF TOPIC] Allowing linkat() to replace the destination Message-ID: <20200118022032.GR8904@ZenIV.linux.org.uk> References: <20200117154657.GK8904@ZenIV.linux.org.uk> <20200117163616.GA282555@vader> <20200117165904.GN8904@ZenIV.linux.org.uk> <20200117172855.GA295250@vader> <20200117181730.GO8904@ZenIV.linux.org.uk> <20200117202219.GB295250@vader> <20200117222212.GP8904@ZenIV.linux.org.uk> <20200117235444.GC295250@vader> <20200118004738.GQ8904@ZenIV.linux.org.uk> <20200118011734.GD295250@vader> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200118011734.GD295250@vader> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Fri, Jan 17, 2020 at 05:17:34PM -0800, Omar Sandoval wrote: > > No. This is completely wrong; just make it ->link_replace() and be done > > with that; no extra arguments and *always* the same conditions wrt > > positive/negative. One of the reasons why ->rename() tends to be > > ugly (and a source of quite a few bugs over years) are those "if > > target is positive/if target is negative" scattered over the instances. > > > > Make the choice conditional upon the positivity of target. > > Yup, you already convinced me that ->link_replace() is better in your > last email. FWIW, that might be not so simple ;-/ Reason: NFS-like stuff. Client sees a negative in cache; the problem is how to decide whether to tell the server "OK, I want normal link()" vs. "if it turns out that someone has created it by the time you see the request, give do a replacing link". Sure, if could treat ->link() telling you -EEXIST as "OK, repeat it with ->link_replace(), then", but that's an extra roundtrip... Hell knows... I would really like to avoid any kind of ->atomic_open() redux ;-/