Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1107445pxj; Fri, 21 May 2021 06:40:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQWKzY8ZORozKuN6qjFlzd9yvnczUZheeUayZmfO+NR40Y05HCd9YJ0SKgkYtf1Gyf+p38 X-Received: by 2002:a17:907:76d9:: with SMTP id kf25mr10574381ejc.340.1621604440887; Fri, 21 May 2021 06:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621604440; cv=none; d=google.com; s=arc-20160816; b=GaBQwwC3lRABRdZYP4EHdHj/Y2olDPuuOJTL89VTgbL/B44L4O5sqYkXlGjhiXfq2z V2jHkmsZXr0hFNmsqvHiU4hA1LBygyjKr+mXsJ6JV8qyGbB2E+urLCvb6Cttg9QVUZQe NNw2BiKmkXilGcYrLLWbglmgtZ9u818jYsxT9ZJ2LojEmOHW5mBktJeKAsK7nWBQZ5Il UJDUHLUPVHldNo7xat14OJ7zCJnaqIr5JiW8t/B47NPe60xv6BymoUYWI/egxSKzTsUL 5DmOO8ZrNapM+VnZsg2sglt4JKKqwjO4F1mlchsa7XFhDQKz1DCMU14HIujs7plU9ygA scmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=peFgrcGdPhwe6C5FlqMowLWB/dQkwxKBHPwPlVELpVI=; b=Z2/t6dksrZM3p3rAEoXaUJ47wiS8IdOmWdqPwS2Y0HBrp4N1Z5AzFvC+KgSYXN03eW VaMpk2F6MIOMTHKFz5R3qtH1V4GfEawj/i7rLVigdhtQ3dy88+mojiQE+KRoa8dSZHF2 J/jLDuV8Qb44ZfLcA79XHBtqTwptH8f8okkhq+fMwSQaJA4oamGPW4Fv8WsoJSqtFpAj 9XhHJDN1Wy120HGv++BBuxduAZGnes/0euQUE3+prxauaG08vlJkOD0/EtSL5/br7DUG Wy+jTN5vlUzI8LiZOyx+DbYEtd4aaA+oYF/j+WHqPmLKEqh3oz0w5DnDu6hT+ZomPFgT hERw== ARC-Authentication-Results: i=1; mx.google.com; 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 bt12si5491030ejb.669.2021.05.21.06.40.17; Fri, 21 May 2021 06:40:40 -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; 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 S235585AbhEUNiG convert rfc822-to-8bit (ORCPT + 99 others); Fri, 21 May 2021 09:38:06 -0400 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:34096 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235424AbhEUNiF (ORCPT ); Fri, 21 May 2021 09:38:05 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-AAhjg02-MbOkPEdfh6xR_Q-1; Fri, 21 May 2021 09:36:38 -0400 X-MC-Unique: AAhjg02-MbOkPEdfh6xR_Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3AA011007B14; Fri, 21 May 2021 13:36:37 +0000 (UTC) Received: from bahia.lan (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id E40696A03C; Fri, 21 May 2021 13:36:15 +0000 (UTC) Date: Fri, 21 May 2021 15:36:14 +0200 From: Greg Kurz To: Miklos Szeredi 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 Subject: Re: [PATCH v4 4/5] virtiofs: Skip submounts in sget_fc() Message-ID: <20210521153614.061b0005@bahia.lan> In-Reply-To: References: <20210520154654.1791183-1-groug@kaod.org> <20210520154654.1791183-5-groug@kaod.org> <20210521103921.153a243d@bahia.lan> <20210521120616.49d52565@bahia.lan> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 21 May 2021 14:37:25 +0200 Miklos Szeredi wrote: > 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. > Ok, I get it now. Thanks for the clarification. > > > 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(). > Cool, I was thinking about doing this exactly. :) > Thanks, > Miklos