Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1394573pxj; Fri, 21 May 2021 13:10:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLqhuXqWdRVdq94M8vtS7KrxGnn/JREQhfD1+MYSz2ldDz2Gqz/lUl50NFNaP/2IDggfH2 X-Received: by 2002:a5d:8188:: with SMTP id u8mr553557ion.163.1621627812901; Fri, 21 May 2021 13:10:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621627812; cv=none; d=google.com; s=arc-20160816; b=xxmoQukiUHlRIX5PZpenK/wmOlCZ0m8s/7xpc5Jv13fqk0Hv0fumVoHnn3r51lWDUy uBjPO6uYXHdSve1eQA2v+h2WLSLVHFvUqat5tseOBwM9cnQ7PCxZ1XkTsvjmQnJ/FE2C Yxah0mOaISPxGa99ZYfLmULLzYYnr3cDymZC7H34LFqnTcmaTDMHSRrD04dem1P5D5eD oHvfOdiEs1EXbDYe7pu+cUs6fra0ds4+bgY+MXBeN1VPmQ7p1coQgNgO5YgEc0xxj8l0 MX284v1BMsUYgAbTgr7xonw3byOiIEeXFJwaFOkWHl5tX56PqR9ypjmWn4P3x7Njso1W uAiw== 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=mFPnGBBo9uPK7q1bx3/OHNBziL1VS1FaR/jW/45G8No=; b=UfCLwWcqp4TLwySkKtV1uD9o606fJpJcaRN5/em6jyhty35ffelsG06H70Xkl9zhQK G/zkS2Ay8rLlt9yQIBH9WYc9YcE8fglRZF4jXLxN2rLP3dkbmiyj4raHkMwT86emEboM 0MsFYbNPrTedyLW7u72+Zl1BN0Re2WCAuL/maYSN6qXA0/XKKjX6ZMP9ESekcJswEM45 0nnst5STs/IV3Vwas4IrTyfnlx7n21i17z3vqtMF5CBEpR4cCK/WTodXK+1zu+ki7bZp MCpiy7FUjpVzcPQ+SAx94CK1Bvx8ztxEiyvGSM9IX8/r+lzqox2Hojw0sArHSRc+znZd CMTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=Zk2iAnAY; 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 d70si7327303iog.4.2021.05.21.13.09.59; Fri, 21 May 2021 13:10:12 -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=Zk2iAnAY; 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 S233960AbhEUIwY (ORCPT + 99 others); Fri, 21 May 2021 04:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233909AbhEUIwX (ORCPT ); Fri, 21 May 2021 04:52:23 -0400 Received: from mail-vs1-xe2d.google.com (mail-vs1-xe2d.google.com [IPv6:2607:f8b0:4864:20::e2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE0C3C061574 for ; Fri, 21 May 2021 01:50:45 -0700 (PDT) Received: by mail-vs1-xe2d.google.com with SMTP id j12so4934899vsq.9 for ; Fri, 21 May 2021 01:50:45 -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=mFPnGBBo9uPK7q1bx3/OHNBziL1VS1FaR/jW/45G8No=; b=Zk2iAnAYEgvulBteJzqiLG+YcF0Ge6ONYvZ2Cwv9EegLGu04xZ46iosv1yP+M/Cwo1 gDqkELTiUclVGOOcOD5+zDlFcEvVuobHjKQetErpTDXYmOrE9yyPHTnsmet7bty32vgX vD4peK29KWDUju0YLfeYstIJQiIln2ZJvkO0o= 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=mFPnGBBo9uPK7q1bx3/OHNBziL1VS1FaR/jW/45G8No=; b=P2R9iqxxoVRrpr6jiQAjREEueBKg9t1U4YCvjgmJIrlofl/ywbLvaixGYoilQV6aUS eTWYRJ8oSLt4kSxkVS7tikeKEFm/CVNaC7FOxWc6Yzl1RFaiwzqKZuF7lF1saduukWaS kU8AQ4GZAQMAqYfzQjzRpnw316Cv7B8SZXgZzoNIimfS/pc40e86/wF5E1HdIiO9Gpng ei+8Xevjrvp3g63RUeRpO6lt9FvOEFtCM+uZ/A4BscRJ05bkqPa77gUK1wTh5tC2rKHE uwYw51h7f08jhwINfoN5SQtR7RDDh1OJLDiUNrDokRSJcYgVP9VXRIZkSuGvxxK5BKYm rILw== X-Gm-Message-State: AOAM533UbsY6W+daFnAdggnbAKu/1SdGl5vXfoIwKjKCYa1Bx05Ow/cf Mh7UqQQNJ/Iz/peOa8eXmgXG1I9ScCOOuBPmsihmmA== X-Received: by 2002:a05:6102:3239:: with SMTP id x25mr8079662vsf.47.1621587044884; Fri, 21 May 2021 01:50:44 -0700 (PDT) MIME-Version: 1.0 References: <20210520154654.1791183-1-groug@kaod.org> <20210520154654.1791183-5-groug@kaod.org> <20210521103921.153a243d@bahia.lan> In-Reply-To: <20210521103921.153a243d@bahia.lan> From: Miklos Szeredi Date: Fri, 21 May 2021 10:50:34 +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 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). 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 - 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... Thanks, Miklos