Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2106405rdb; Mon, 9 Oct 2023 12:46:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhUQ75rhYZeTDzgVSZcv0L0MrNJjYpm8++9nMGQko+GFjHtBs8EcEvTQSZbkwyHM4v6pwr X-Received: by 2002:a17:902:eb45:b0:1bc:506a:58f2 with SMTP id i5-20020a170902eb4500b001bc506a58f2mr11201530pli.46.1696880761441; Mon, 09 Oct 2023 12:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696880761; cv=none; d=google.com; s=arc-20160816; b=Jc/P/Sur803dCsCHQ/xlld0TG/qW98QbUHR6RCKRvC3TwRZ8ERA69BVvT8ea+bBlH+ Y05ceW4sffZtpERRyeCNzez1ybxfPRTQ1FFZtMFAXHPWrs1Os8Ud6I+AGO42XIS4GbE+ YQNpvYetsvsYDwsJ34RqhML7YN1WlMOEWbuVqzvFuUwqw2E5mHD3UA03jNRe6oYGR7P8 Kgcbdbkbb+QRQPLexbeTAXm+woZjKQF3F+hwrXJBTS8Fk8G6iOt1PYRSjYznafKGuBBO SCeMNNPVSs22lL2EgSIQ5dDVzlY4mFP/Lc6EbL0rg5uPd3YwK1oHs9XAC6vYo5Us8XPM maeA== 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=i9IoVUFnZqWRaCM70mDq121GEnQ6kFXLINjENnMWdgE=; fh=XCEN0sQ0vpSU+R70K7SsEOZGhA6b6HFENkpvm1Rt7l8=; b=gvWz3cxcGhNELFCmmF1qNYtr2LUT7xJ32Ag4+QVusmRb9pxX/aUMuvIctYPFvx5uwB bjgJuiXYTKNXzr0ri0Wxngjx0O00N4i3pGY39wpptZYj7lWDgHWyctoDnGV5w5b98c1W WTwK1j5kMfIVeKTe1yIAYom42sON1iZhcSdOf9eshd5dn/pB5547z8NUv1tB8JwLKQU5 pxddd9QX3GucRBjGJYS6ElYJ7uANsMmb4Rk2J1Jf7RLQlsXIM6oKyMu1jtkkHsqV5Bpt CUFhbP0E8yvbRTGbypph5oq0x6rUGZY6e2t9JfRGAn/HUsKtRaBFaz9E0x6PvB+h82Nf zjzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@szeredi.hu header.s=google header.b=ee5uvAT8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=szeredi.hu Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id kf4-20020a17090305c400b001c3e9b0bae1si9849230plb.443.2023.10.09.12.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 12:46:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@szeredi.hu header.s=google header.b=ee5uvAT8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=szeredi.hu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5101880870E1; Mon, 9 Oct 2023 12:45:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378459AbjJITpa (ORCPT + 99 others); Mon, 9 Oct 2023 15:45:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234540AbjJITp1 (ORCPT ); Mon, 9 Oct 2023 15:45:27 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 242AEA6 for ; Mon, 9 Oct 2023 12:45:22 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9b1ebc80d0aso842831266b.0 for ; Mon, 09 Oct 2023 12:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; t=1696880720; x=1697485520; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=i9IoVUFnZqWRaCM70mDq121GEnQ6kFXLINjENnMWdgE=; b=ee5uvAT80fSxSRtYDeyvxEuQ7zXOl8wdW0kO70gd08D47hzkRd+3mbkEUekmJUq06D 8q777oRQSHZ6op/ZWJCsNQZHdOoWUoWw7duI1oSVMIVq6M0NdKQzZqs6MGy5XSqr2EmX BbA+2lv6IrYcf5dVP2Pc+icl6wM6wxHnu4EFI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696880720; x=1697485520; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=i9IoVUFnZqWRaCM70mDq121GEnQ6kFXLINjENnMWdgE=; b=mB6MZhJ0szYg+u/P4zMZxduXCQrw2G8phT4qN76HasTgvbMUGhH8A+naP0cwaxciT2 k6qBofaZS88byAcSYe2xsMFx4ULB5Ll4Y3smohV98Qu5z5IE0kGFQ4yNu2DGLc0YHxi9 tuyZP6gzsZTi9+EZh61RHqncIyqRQGiSXCQomjAgYZO6nT/99siJ+D037ugW7EB5aKVi AKcsB/WxYoTe3pTrr3/wGWEJV2IrIYd52cThF+rfIYsvm/9qsIPSWhvbMURN14y2CYMZ kpuKaHcV7Iy5n8HZQgfE07TcDYHn1lHq+RNZrJ5HyujlLdWM7E/zZ5NNVSNW+TI4xh8C aXJA== X-Gm-Message-State: AOJu0YwlmlZaPZ6fN2z1bBQ2qjBEUq6a8m0QpGZJtjw7QT+xeBQfDZPM xDzG//5VjJ2R2WBIYA5YdWzGkNNOujNEyi2s8Wm/oQ== X-Received: by 2002:a17:906:1db2:b0:9ba:2b14:44fb with SMTP id u18-20020a1709061db200b009ba2b1444fbmr2323048ejh.47.1696880720133; Mon, 09 Oct 2023 12:45:20 -0700 (PDT) MIME-Version: 1.0 References: <45778432fba32dce1fb1f5fd13272c89c95c3f52.1696043833.git.kjlx@templeofstupid.com> In-Reply-To: <45778432fba32dce1fb1f5fd13272c89c95c3f52.1696043833.git.kjlx@templeofstupid.com> From: Miklos Szeredi Date: Mon, 9 Oct 2023 21:45:08 +0200 Message-ID: Subject: Re: [resend PATCH v2 2/2] fuse: ensure that submounts lookup their parent To: Krister Johansen Cc: linux-fsdevel@vger.kernel.org, Miklos Szeredi , linux-kernel@vger.kernel.org, German Maglione , Greg Kurz , Max Reitz , Bernd Schubert Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 09 Oct 2023 12:45:39 -0700 (PDT) X-Spam-Level: ** On Mon, 2 Oct 2023 at 17:24, Krister Johansen wrote: > > The submount code uses the parent nodeid passed into the function in > order to create the root dentry for the new submount. This nodeid does > not get its remote reference count incremented by a lookup option. > > If the parent inode is evicted from its superblock, due to memory > pressure for example, it can result in a forget opertation being sent to > the server. Should this nodeid be forgotten while it is still in use in > a submount, users of the submount get an error from the server on any > subsequent access. In the author's case, this was an EBADF on all > subsequent operations that needed to reference the root. > > Debugging the problem revealed that the dentry shrinker triggered a forget > after killing the dentry with the last reference, despite the root > dentry in another superblock still using the nodeid. There's some context missing here. There are two dentries: a mount point in the parent mount and the root of the submount. The server indicates that the looked up inode is a submount using FUSE_ATTR_SUBMOUNT. Then AFAICS the following happens: 1) the mountpoint dentry is created with nlookup = 1. The S_AUTOMOUNT flag is set on the mountpoint inode. 2) the lookup code sees S_AUTOMOUNT and triggers the submount operation, which sets up the new super_block and the root dentry with the user supplied nodeid and with nlookup = 0 (because it wasn't actually looked up). How the automount gets torn down is another story. You say that the mount point gets evicted due to memory pressure. But it can't get evicted while the submount is attached. So the submount must first get detached, and then the mount point can be reclaimed. The question is: how does the submount gets detached. Do you have an idea? Thanks, Miklos