From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A250FC43460 for ; Fri, 21 May 2021 12:37:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87FCB613CA for ; Fri, 21 May 2021 12:37:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233890AbhEUMjD (ORCPT ); Fri, 21 May 2021 08:39:03 -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-Google-Smtp-Source: ABdhPJyas05tLLIDBA3UJ9G3HlWZ9Viz/tUcF4iiOb4gQdzkbues8ByWakkKXBysdgZ9B4lVGBn673e1F17hVqL4zW0= 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 From mboxrd@z Thu Jan 1 00:00:00 1970 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= 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: Content-Type: text/plain; charset="UTF-8" Subject: Re: [Virtio-fs] [PATCH v4 4/5] virtiofs: Skip submounts in sget_fc() List-Id: Development discussions about virtio-fs List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: linux-kernel@vger.kernel.org, Max Reitz , virtio-fs-list , linux-fsdevel@vger.kernel.org, virtualization@lists.linux-foundation.org, Vivek Goyal 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