Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1070189pxj; Fri, 21 May 2021 05:54:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxzWLdkJGaGYxJkYzH5FbwjrI0XTsrJsBCNVUbXdXVSE4CWB2yPrsMdpGTsRD3T5X+m3lB X-Received: by 2002:a92:ddc6:: with SMTP id d6mr10170425ilr.51.1621601687733; Fri, 21 May 2021 05:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621601687; cv=none; d=google.com; s=arc-20160816; b=Pi5fGKwAkZIszrWZy6+JJucWaROyIHPEfMaORGErYcz03mHrO5S7BftS/OglsixtCM YjEb0vILc7Qkfjar+saajpk/AcXPURYnjqNCPYv01F92mS8pG9FCMZKFmYwkvKTwykpN T0lcLMU0ejB/ihlNsH1ui7sUP4n5Ohv3Vh+mWIR0nkNKnUV9TXs82IU6i5NBkyTLZl9v ruEp/ujUEucyECUgJbjMBIuDItKeWdH89SU1GWHp3Lr5r/ornqgX6/NcQmtbJzk1Jy9w oI1DHwgR1lxI8KFJZTSleYnm571PyEuOMUPGjV/zTcyE2Dpf1eDlGRk0ApHIUagzLO7R 2R1Q== 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=njboqj4vUiFzE7pfQXxgggntztlAq5fmF71S0Jmw2oQ=; b=XS3dINxSXpoEZkQcXwnvnAvqOCVEVpf/vEFmdCGjD5GNCy+m5YEkI/DHE/scp5QoFR Mk0zdtzG116Tif04RaS4YAaXVSkJ/8W5FXNaCRqSIGyA3yWlqr/yskXXpen+twBhantm GWW7OPE/YVTS5P5rZ8eQxpoUXFZ2BflgpHRG0WbLffJBEi4nq8woU6u7N2vUPb+8xjHn aDh0uhKAUemoItap5R5Cu7Elyy5HMiHNULg8AApTPXvFK0CD/8N79vCPWr+qwYs5qFa+ tyLpReeq1tRtT+Xteq5O6g4AxUjB7NIyu3F3fjIEWWYwT+T8sWlXmIvCebc8FX6rH97O c6yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=o2FmGmPx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b15si5868848jat.59.2021.05.21.05.54.34; Fri, 21 May 2021 05:54:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=o2FmGmPx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233262AbhEUMjC (ORCPT + 99 others); Fri, 21 May 2021 08:39:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbhEUMjB (ORCPT ); Fri, 21 May 2021 08:39:01 -0400 Received: from mail-vs1-xe36.google.com (mail-vs1-xe36.google.com [IPv6:2607:f8b0:4864:20::e36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACE3FC061574 for ; Fri, 21 May 2021 05:37:37 -0700 (PDT) Received: by mail-vs1-xe36.google.com with SMTP id f15so8960255vsq.12 for ; Fri, 21 May 2021 05:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=njboqj4vUiFzE7pfQXxgggntztlAq5fmF71S0Jmw2oQ=; b=o2FmGmPxL+Xvpp+r18WUv09psrrIut/NYqQB3YFjQL9E1TT7mh4pdsVVPwqQH7Y/Ab TMX+iuBpk+EWuIfSLMZvI4p3HBhgtvfuaQLE74dfPsLbnmj4GNNtFILQq4xonXECs2Xg luwBtWTPdmJTlDepwYV6YfzlXhHdnCg+CG5mI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=njboqj4vUiFzE7pfQXxgggntztlAq5fmF71S0Jmw2oQ=; b=aZfaAbLNcaKXqygfz/gQ92iEtpusrUfCxVSXkyMnyLgiUd+e2YyF9MkeaMFYi7YJxS pSGb4e6bLnbnbysh+mAgAuNcsqiVHj2Cdrulf3npEZ2lCU8KDnKNIfxbI2Y2XuSCZ2Hv zvmvsCMzZXZzqS7JzZyz/NZ7g+49M1EOL0TInKrybQF0kF9+SAQO5/x5bVITvIU9yjVi ZIyhm4yxPSUPfLDv5AcoLVBSqiy0zdlherQ07uWz9Y2NcZap48H/r+mxxOXEyuQdw6Zu yr6vTsy6p6WbrZunI6iMlB3Nzu1ekdLszmqIvav1X1RwlLMf0X5fidlbcmDgjnQ7O0ez pHmg== X-Gm-Message-State: AOAM5312pElr/SHQFWQRBAoKfF8UmskqqJeo+O9KbI95hsh5toC7xEAA NNQBwf3IFduN4P8j/xjiyMZRP46xHxH8HWAJzEQ+nA== X-Received: by 2002:a67:ebcd:: with SMTP id y13mr10057804vso.9.1621600656516; Fri, 21 May 2021 05:37:36 -0700 (PDT) MIME-Version: 1.0 References: <20210520154654.1791183-1-groug@kaod.org> <20210520154654.1791183-5-groug@kaod.org> <20210521103921.153a243d@bahia.lan> <20210521120616.49d52565@bahia.lan> In-Reply-To: <20210521120616.49d52565@bahia.lan> From: Miklos Szeredi Date: Fri, 21 May 2021 14:37:25 +0200 Message-ID: Subject: Re: [PATCH v4 4/5] virtiofs: Skip submounts in sget_fc() To: Greg Kurz Cc: virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, virtio-fs-list , Stefan Hajnoczi , Max Reitz , Vivek Goyal Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 21 May 2021 at 12:06, Greg Kurz wrote: > > On Fri, 21 May 2021 10:50:34 +0200 > Miklos Szeredi wrote: > > > On Fri, 21 May 2021 at 10:39, Greg Kurz wrote: > > > > > > On Fri, 21 May 2021 10:26:27 +0200 > > > Miklos Szeredi wrote: > > > > > > > On Thu, 20 May 2021 at 17:47, Greg Kurz wrote: > > > > > > > > > > All submounts share the same virtio-fs device instance as the root > > > > > mount. If the same virtiofs filesystem is mounted again, sget_fc() > > > > > is likely to pick up any of these submounts and reuse it instead of > > > > > the root mount. > > > > > > > > > > On the server side: > > > > > > > > > > # mkdir ${some_dir} > > > > > # mkdir ${some_dir}/mnt1 > > > > > # mount -t tmpfs none ${some_dir}/mnt1 > > > > > # touch ${some_dir}/mnt1/THIS_IS_MNT1 > > > > > # mkdir ${some_dir}/mnt2 > > > > > # mount -t tmpfs none ${some_dir}/mnt2 > > > > > # touch ${some_dir}/mnt2/THIS_IS_MNT2 > > > > > > > > > > On the client side: > > > > > > > > > > # mkdir /mnt/virtiofs1 > > > > > # mount -t virtiofs myfs /mnt/virtiofs1 > > > > > # ls /mnt/virtiofs1 > > > > > mnt1 mnt2 > > > > > # grep virtiofs /proc/mounts > > > > > myfs /mnt/virtiofs1 virtiofs rw,seclabel,relatime 0 0 > > > > > none on /mnt/mnt1 type virtiofs (rw,relatime,seclabel) > > > > > none on /mnt/mnt2 type virtiofs (rw,relatime,seclabel) > > > > > > > > > > And now remount it again: > > > > > > > > > > # mount -t virtiofs myfs /mnt/virtiofs2 > > > > > # grep virtiofs /proc/mounts > > > > > myfs /mnt/virtiofs1 virtiofs rw,seclabel,relatime 0 0 > > > > > none on /mnt/mnt1 type virtiofs (rw,relatime,seclabel) > > > > > none on /mnt/mnt2 type virtiofs (rw,relatime,seclabel) > > > > > myfs /mnt/virtiofs2 virtiofs rw,seclabel,relatime 0 0 > > > > > # ls /mnt/virtiofs2 > > > > > THIS_IS_MNT2 > > > > > > > > > > Submount mnt2 was picked-up instead of the root mount. > > > > > > > > > > > Why is this a problem? > > > > > > > > > > It seems very weird to mount the same filesystem again > > > and to end up in one of its submounts. We should have: > > > > > > # ls /mnt/virtiofs2 > > > mnt1 mnt2 > > > > Okay, sorry, I understand the problem. The solution is wrong, > > however: the position of the submount on that list is no indication > > that it's the right one (it's possible that the root sb will go away > > and only a sub-sb will remain). > > > > Ah... I had myself convinced this could not happen, i.e. you can't > unmount a parent sb with a sub-sb still mounted. No, but it's possible for sub-sb to continue existing after it's no longer a submount of original mount. > > How can this happen ? E.g. move the submount out of the way, then unmount the parent, or detach submount (umount -l) while keeping something open in there and umount the parent. > > Even just setting a flag in the root, indicating that it's the root > > isn't fully going to solve the problem. > > > > Here's issue in full: > > > > case 1: no connection for "myfs" exists > > - need to create fuse_conn, sb > > > > case 2: connection for "myfs" exists but only sb for submount > > How would we know this sb isn't a root sb ? > > > - only create sb for root, reuse fuse_conn > > > > case 3: connection for "myfs" as well as root sb exists > > - reuse sb > > > > I'll think about how to fix this properly, it's probably going to be > > rather more involved... > > > > Sure. BTW I'm wondering why we never reuse sbs for submounts ? Right, same general issue. An sb can be identified by its root nodeid, so I guess the proper fix to make the root nodeid be the key for virtio_fs_test_super(). Thanks, Miklos