Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4658146rdh; Wed, 29 Nov 2023 07:20:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtcKUGUkcDpxIn/MMaU1bmyQArpSN+2R7C+idVnvoLegpaNNE7oHlo0lc34v3pxYIvdjMA X-Received: by 2002:a0c:f8c5:0:b0:66d:44b6:8aa8 with SMTP id h5-20020a0cf8c5000000b0066d44b68aa8mr20083558qvo.47.1701271204398; Wed, 29 Nov 2023 07:20:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701271204; cv=none; d=google.com; s=arc-20160816; b=K0F+Dm7zQjUm/+vKMutd1YVGDnZj/7ytv34VIbKXE13loKTm4wDf8kCY2NMOibczy7 wur2tO93SxeDWHoN0r4YyHi6OlFG/ydP2DUPdLn1KfFM6XRn3ACWI9yk5VrSet0VtaSu +3J1OXvOrXqw23uSYdGl1EimdYTlVTqzrZnhsVPjyj3/Q9i7LnFDSfe2T6SxdIxN5WK7 7PJDgj3il1A87AGwtfMTYZNZANgTOHWY99BTayjYRaTSRxOiH0Cwary0kZve8wy5tajR H9nqI3ryYMsemCzFI8U8sE5PGovthax0Mkt+otNK2R0LLu7Akfa6+nthaSeMhbTAwNmF T3Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:message-id:date:user-agent:references:in-reply-to:cc:to :from; bh=U6c0fq7KFsncZZz+YJTsa8Nv4i5aeZP+Zi7973oKj+E=; fh=EDa2H//DqOJAHOkNORtx2zVGTgBcbPvE6Xcv03PLZmc=; b=00eQgxch0XHW1WkQ8bpvQW4gnXcicm5Uz/AwKm8x7Nd0iORqxUt+M/h3ntK13udP3p qjx3khOdP+3PKUVY1UGTvjKPAlcHZzC1IrZRd1WaweeMkP43cfScGTxZy7rw8hwIxdgG 5E6494ZOrvbhqv8ggX9cw192aX9siVqvYhodMYi+yz3TWNk5Uj4U5kRiv6qxx8WYiWSh w8IP4Sbi1LWDB3BRFjzRxWFUY1t8LnRRzpQEnaCNGKuQHq9waZzTWqrY/YYK+bVxm0ci 43jsNZx6CGXMMyWpU4s30bCye+miyuTHiY2dNAZx39ZEtDpmY5sCJsl2hlHEnhLDWyaT hsYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r13-20020a0562140c4d00b0067a15096c40si12819520qvj.386.2023.11.29.07.20.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:20:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EFEDA1C20C90 for ; Wed, 29 Nov 2023 15:20:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F567374F9; Wed, 29 Nov 2023 15:19:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none X-Original-To: linux-ext4@vger.kernel.org Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7ECEDD; Wed, 29 Nov 2023 07:19:53 -0800 (PST) Received: from in02.mta.xmission.com ([166.70.13.52]:41778) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1r8MLv-00Cf3p-Sp; Wed, 29 Nov 2023 08:19:51 -0700 Received: from ip68-227-168-167.om.om.cox.net ([68.227.168.167]:49158 helo=email.froward.int.ebiederm.org.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1r8MLu-005gWB-Nk; Wed, 29 Nov 2023 08:19:51 -0700 From: "Eric W. Biederman" To: Al Viro Cc: linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , tytso@mit.edu, linux-f2fs-devel@lists.sourceforge.net, ebiggers@kernel.org, jaegeuk@kernel.org, linux-ext4@vger.kernel.org, Miklos Szeredi , Gabriel Krisman Bertazi In-Reply-To: <20231129045313.GA1130947@ZenIV> (Al Viro's message of "Wed, 29 Nov 2023 04:53:13 +0000") References: <20231122211901.GJ38156@ZenIV> <20231123171255.GN38156@ZenIV> <20231123182426.GO38156@ZenIV> <20231123215234.GQ38156@ZenIV> <20231125220136.GB38156@ZenIV> <20231126045219.GD38156@ZenIV> <20231126184141.GF38156@ZenIV> <20231127063842.GG38156@ZenIV> <20231129045313.GA1130947@ZenIV> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Date: Wed, 29 Nov 2023 09:19:41 -0600 Message-ID: <87v89kio36.fsf@email.froward.int.ebiederm.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1r8MLu-005gWB-Nk;;;mid=<87v89kio36.fsf@email.froward.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.168.167;;;frm=ebiederm@xmission.com;;;spf=pass X-XM-AID: U2FsdGVkX1/b6JS6EkjAv/7bqf1Ls+CX0i6iy1ZrEtE= X-SA-Exim-Connect-IP: 68.227.168.167 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Level: X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Al Viro X-Spam-Relay-Country: X-Spam-Timing: total 555 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 11 (2.0%), b_tie_ro: 10 (1.8%), parse: 1.33 (0.2%), extract_message_metadata: 18 (3.2%), get_uri_detail_list: 3.1 (0.6%), tests_pri_-2000: 12 (2.2%), tests_pri_-1000: 3.6 (0.6%), tests_pri_-950: 1.52 (0.3%), tests_pri_-900: 1.28 (0.2%), tests_pri_-90: 133 (23.9%), check_bayes: 130 (23.5%), b_tokenize: 8 (1.5%), b_tok_get_all: 69 (12.5%), b_comp_prob: 5 (0.9%), b_tok_touch_all: 44 (7.8%), b_finish: 0.86 (0.2%), tests_pri_0: 354 (63.8%), check_dkim_signature: 0.65 (0.1%), check_dkim_adsp: 2.8 (0.5%), poll_dns_idle: 0.80 (0.1%), tests_pri_10: 3.1 (0.6%), tests_pri_500: 12 (2.2%), rewrite_mail: 0.00 (0.0%) Subject: Re: fun with d_invalidate() vs. d_splice_alias() was Re: [f2fs-dev] [PATCH v6 0/9] Support negative dentries on case-insensitive ext4 and f2fs X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Al Viro writes: > On Mon, Nov 27, 2023 at 06:38:43AM +0000, Al Viro wrote: > >> > FWIW, I suspect that the right answer would be along the lines of >> > * if d_splice_alias() does move an exsiting (attached) alias in >> > place, it ought to dissolve all mountpoints in subtree being moved. >> > There might be subtleties, > > Are there ever... Starting with the "our test for loop creation > (alias is a direct ancestor, need to fail with -ELOOP) is dependent > upon rename_lock being held all along". > > Folks, what semantics do we want for dissolving mounts on splice? > The situation when it happens is when we have a subtree on e.g. NFS > and have some mounts (on client) inside that. Then somebody on > server moves the root of that subtree somewhere else and we try > to do a lookup in new place. Options: > > 1) our dentry for directory that got moved on server is moved into > new place, along with the entire subtree *and* everything mounted > on it. Very dubious semantics, especially since if we look the > old location up before looking for new one, the mounts will be > dissolved; no way around that. > > 2) lookup fails. It's already possible; e.g. if server has > /srv/nfs/1/2/3 moved to /srv/nfs/x, then /srv/nfs/1/2 moved > to /srv/nfs/x/y and client has a process with cwd in /mnt/nfs/1/2/3 > doing a lookup for "y", there's no way in hell to handle that - > the lookup will return the fhandle of /srv/nfs/x, which is the > same thing the client has for /mnt/nfs/1/2; we *can't* move that > dentry to /mnt/nfs/1/2/3/y - not without creating a detached loop. > We can also run into -ESTALE if one of the trylocks in > __d_unalias() fails. Having the same happen if there are mounts > in the subtree we are trying to splice would be unpleasant, but > not fatal. The trouble is, that won't be a transient failure - > not until somebody tries to look the old location up. > > 3) dissolve the mounts. Doable, but it's not easy; especially > since we end up having to redo the loop-prevention check after > the mounts had been dissolved. And that check may be failing > by that time, with no way to undo that dissolving... To be clear this is a change in current semantics and has a minuscule change of resulting in a regression. That should be called out in the change log. If we choose to change the semantics I would suggest that the new semantics be: If a different name for a directory already exists: * Detach the mounts unconditionally (leaving dentry descendants alone). * Attempt the current splice. - If the splice succeeds ( return the new dentry ) - If the splice fails ( fail the lookup, and d_invalidate the existing name ) Unconditionally dissolving the mounts before attempting the rename should simplify everything. In the worst case a race between d_invalidate and d_splice_alias will now become a race to see who can detach the mounts first. Eric