Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36174552rwd; Mon, 10 Jul 2023 19:34:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlEgt1Y7ZII2qsZ9EgvK2Scpu/uEvLEq7sUvINWxT2BVpKSB/IJXgYv18qphDq5piwOUqMtW X-Received: by 2002:a05:620a:294d:b0:765:45a4:4813 with SMTP id n13-20020a05620a294d00b0076545a44813mr17145991qkp.27.1689042893650; Mon, 10 Jul 2023 19:34:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1689042893; cv=pass; d=google.com; s=arc-20160816; b=sUieVIjsKRpMTEE+cOCj70TcIUQefP3sD0yB2nUSBfsXQu+2Svf50DATJmYdrwMYUG FeGHc44GeEcKvdUJnMPWkc7DAAOP/vhzcwIghAxFz8tWCJVe3aFRB4ygG1N5T0q8PSlR 7F7OiT5rq6hqZde9YIdb3jRRDhmzg9CGOlj5IeR21fNu+z82QtOAlA9niaYFuYPWqlQs vT6FSYOMJE2a7jKDvAABe2w3wqWJbdwhz4qxgH5LaJwy7/NG/lMqs16QgBOjIgCJhsKe cTGb+shGfLXTTT+hBraMCoGfgvwBgVD3zueCCyPExERS1uF62Ec42JpC0faeXI3jUMQH 8SVw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=DlxuMxmeNwWxu3Lf7j83rKB4Gg+MGbkmGgKoHzaeeao=; fh=XvGtmF0+VVaT6J0bRzCQFzpBtmTZgkYtVchCcm/o2t8=; b=kcmV/IrVcgWcV4lTAt7Hy4qrWYFBjQdO4hN6h5EmOtjK4UdeyZfrl0OfRvmFsbS+HJ aUmeVIFcZPVE0R/4qE/3o0axKspdKmP+CxKlmXGmgyjNvRuHh2eE8NQo9vLKxjgV7Of9 S667LY1tejjb7UlsgHmHdToAjiKguO94FF5Z9xNsJaEwzjrt0P08PtyhA95f2vFcsF6l JAvCi7iRtlvzgTGtmhctn/14sUzFN8HkRKlHJVhuEry3ynnT6KhjjDj8cj/52jMO7+4P EpYpzsQgpfY2wY05oFz1XVTKMoJU+ouYy7U1Co8WyZIHilWeHGR021wVqCcCYQP53Zxx b+1A== ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@templeofstupid.com header.s=dreamhost header.b=jSVsqrkn; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b18-20020a63eb52000000b0055381e05244si570733pgk.777.2023.07.10.19.34.40; Mon, 10 Jul 2023 19:34:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@templeofstupid.com header.s=dreamhost header.b=jSVsqrkn; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229917AbjGKBhn (ORCPT + 99 others); Mon, 10 Jul 2023 21:37:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjGKBhl (ORCPT ); Mon, 10 Jul 2023 21:37:41 -0400 Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E330AA4 for ; Mon, 10 Jul 2023 18:37:40 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|kjlx@templeofstupid.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 4C8EB1419E8 for ; Tue, 11 Jul 2023 01:37:40 +0000 (UTC) Received: from pdx1-sub0-mail-a234.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id B91BF1419E4 for ; Tue, 11 Jul 2023 01:37:39 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1689039459; a=rsa-sha256; cv=none; b=LVhdNPXUfTlXUrrZqCuvbke3E77Db7ie2/LmjGaqBWgWz3Qb9o2Y8SWDkPGH33gLaCdL43 uXSh2lQDrqCLGflIcXQykHIuGvzg+ulng+oSl5Np/A/MWlbcNzTknjwfBe8NPJso9b4ixy reW231Nqd5ef6j+5XCJjUptTxaayGZJUz0s547auZJcv2t/IUy9Lhha7PT4cBbn+22iBGf oZkhYIfDLR5BMqdTPrvC2h16krR1Gmkr8Im7rJfSPUdodyOlCeNEbjK+ZMegGKw6XV5GjE +DVvT+vmrgE3G9vep222ZlVd4sRt7A+vadGNNy2CLCyUi9B7u4AXp0MCZu+z+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1689039459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: dkim-signature; bh=DlxuMxmeNwWxu3Lf7j83rKB4Gg+MGbkmGgKoHzaeeao=; b=m9DQyLWHF8L7+iGmIiyozyx4i2AcMzM6ShdPEiXCISs+lSRal6nEHW9DKQ4txidVnI1mfe eT9P4VvTKmNf7tEqSYKDZxo5JZkh7b3UEKaGdf1cn4WyluV9qc6pcqn67ICeHztLxVN7C/ CJuA9dbxEW6UBbwe03DToYUVICZ5PCXwzk89DGQ0PlO292T2V/CXlburiCH+l540PO+Vgf ly7Grcsguop9ybq/UAWzG2TYhVN1HfPWTfRR75trdxStxhZVBMS1aVo0u53shIie2Kijvs 7C0mhMihK+jjTq9TeA96TExkXXBDZyqmv9i5xeL7oZN/en09d2nMjTjao8AxvA== ARC-Authentication-Results: i=1; rspamd-7d9c4d5c9b-kprkf; auth=pass smtp.auth=dreamhost smtp.mailfrom=kjlx@templeofstupid.com X-Sender-Id: dreamhost|x-authsender|kjlx@templeofstupid.com X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|kjlx@templeofstupid.com X-MailChannels-Auth-Id: dreamhost X-Cellar-Chief: 004ab418052a6e9c_1689039459972_780549425 X-MC-Loop-Signature: 1689039459972:2029713285 X-MC-Ingress-Time: 1689039459972 Received: from pdx1-sub0-mail-a234.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.126.30.12 (trex/6.9.1); Tue, 11 Jul 2023 01:37:39 +0000 Received: from kmjvbox (unknown [71.198.86.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kjlx@templeofstupid.com) by pdx1-sub0-mail-a234.dreamhost.com (Postfix) with ESMTPSA id 4R0Nm33fj2zZT for ; Mon, 10 Jul 2023 18:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=templeofstupid.com; s=dreamhost; t=1689039459; bh=DlxuMxmeNwWxu3Lf7j83rKB4Gg+MGbkmGgKoHzaeeao=; h=Date:From:To:Cc:Subject:Content-Type; b=jSVsqrknew6IDBjzlyvqVYYDLXBKTtuFqe1sJNaJCQkE4HTW0B6v41NnEWV7kmbo+ 8NM7uWE7idDKQ8c4edaMJ3TP2jJb+DG5O0pvjShZaE8EIwMygefW6A0DvXLOQA9DLJ /SbVN74YkOme2dQq5IdHDxBF96FnzZv0l/+lKed0= Received: from johansen (uid 1000) (envelope-from kjlx@templeofstupid.com) id e0085 by kmjvbox (DragonFly Mail Agent v0.12); Mon, 10 Jul 2023 18:37:03 -0700 Date: Mon, 10 Jul 2023 18:37:03 -0700 From: Krister Johansen To: Miklos Szeredi , linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, German Maglione , Greg Kurz , Max Reitz Subject: [RFC PATCH 0/2] virtiofs submounts forgotten after client memory pressure Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I recently ran into a situation where a virtiofs client began encountering EBADF after the client system had an OOM. After reproducing the issue and debugging, it appears that the problem is caused by a virtiofsd submount being forgotten once the dentry referencing that submount is killed by the shrinker. In this particular case, the submount had been bind mounted into a container's mount namespace. The reference count on the original dentry was 0, making it eligible for eviction. However, because this dentry was also the last reference the client knew it had, it sent a forget message to the server. This caused all future references to the FUSE node-id from virtiofsd perspective to become invalid. Subsequent attempts to used the node-id received an EBADF from the server. This pair of patches modifies the virtiofs submount code to perform a lookup on the nodeid that forms the root of the submount. The patch before this pulls the revalidate lookup code into a helper function that can be used both in revalidate and submount superblock fill. I'm not enamored with this approach, but was hard pressed to think of a more clever idea. In the meantime, it's been tested via: - fstests for virtiofs - fstests for fuse (against passthrough_ll) - manual testing to watch how refcounts change between client and server in response to filesytem access, umount, and eviction by the shrinker. Thanks, -K Krister Johansen (2): fuse: revalidate: move lookup into a separate function fuse: ensure that submounts lookup their root fs/fuse/dir.c | 87 +++++++++++++++++++++++++++++++++--------------- fs/fuse/fuse_i.h | 6 ++++ fs/fuse/inode.c | 32 +++++++++++++++--- 3 files changed, 94 insertions(+), 31 deletions(-) -- 2.25.1