Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp655715pxj; Thu, 27 May 2021 08:44:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKyNKRnQaOWoSJHqJ4ZHxhSzzOLAMkDkFV8+dNONIY3FjMMVYfc8CwMj6jYa2fdQH5ZIy8 X-Received: by 2002:a17:906:2ec6:: with SMTP id s6mr4419966eji.65.1622130260158; Thu, 27 May 2021 08:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622130260; cv=none; d=google.com; s=arc-20160816; b=e/KP7W/m4mSkVJQNme9En9VNqmTYW+JEtMBu2qGlZZvGihqSJXhK3cnovo0P2LyMeU jEmmv7uxFW6MKqfmffh1y/ys7JwInDX7vCHkAqp2Ws7EVMZxVzgQ0su4M2lwRTxzDPLt 0PUo5DGkX4MwDeXjMj2CoclNJRdruHgqMX9bJE4aZ+9WLkZDRetNXXtgzm9f2OeO65VB 6OBkRW8Phzrh5haGAkv1WZoGuHLDEwYYu1oE5DEdWoamwwtCav5j10EXNPjVEaNBzoGh H3iFpQyfp4aooq8q4ZBL/c8o/eWFNZ31G7UOWwRjvN3tZrRJFX9Fjm3/QvX0wsmL0rSF sLUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=ttq7axdVYLD81r74CE3D8qHE56GrIu6ITcvhMbY6oeE=; b=wo5jY4c+1p5b6MoOBa2108gAqU6eNEyVLQRdqlNZrgi6owq6ocvPXzYX99O7UPAn3x oXpI4cXvoVfTTvBUyuplGSqm64OexvxD/bidMDm+RRaSIF5Ou7bkGbEEFuwin7HRw/ai FwZWvJsZmQxHkhuu9snXDE40RRKn7tyN2FTjWy+hKQi0YYjvcs6qjxsG0r76ki2DcFMB TDezIR6mK71MHn/BllXEVynn9mBpGCCiad2wpTOOA6Whnn4TVm6RDsmiYFY1m3NeWCGC rwcgbMnGpr4R2UPPyo2qZ68W8kpfHOG4wDX++ae5wJVuOueD1Qp9Iy8uuM21eXTNE8QZ 6Oyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="IYEwl/OH"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y22si2501752ejb.688.2021.05.27.08.43.46; Thu, 27 May 2021 08:44:20 -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=pass header.i=@redhat.com header.s=mimecast20190719 header.b="IYEwl/OH"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235913AbhE0KKZ (ORCPT + 99 others); Thu, 27 May 2021 06:10:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48406 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235950AbhE0KKY (ORCPT ); Thu, 27 May 2021 06:10:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622110131; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ttq7axdVYLD81r74CE3D8qHE56GrIu6ITcvhMbY6oeE=; b=IYEwl/OHo3BqE9YKwHAZqrE1vmWTxZSLIpToFrFMxaSAkn8+AbIYVP8+Bmbifjifky9OKW HQoEcgUWmCmPfRoj1JMhjXb/kB3SwAZS37UZxKX0Pk2s8yUsPNqjLeehmuVsINW8VUQXFP hdm3aHTC1BNWIUtd7xiPvcVGgr+gLAY= 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-118-uKPL4hILOpORFmZcbPfMoQ-1; Thu, 27 May 2021 06:08:47 -0400 X-MC-Unique: uKPL4hILOpORFmZcbPfMoQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6F2D2108BD1D; Thu, 27 May 2021 10:08:45 +0000 (UTC) Received: from dresden.str.redhat.com (ovpn-114-232.ams2.redhat.com [10.36.114.232]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9CA085F90E; Thu, 27 May 2021 10:08:43 +0000 (UTC) Subject: Re: [Virtio-fs] [PATCH 2/4] fuse: Fix infinite loop in sget_fc() To: Greg Kurz , Miklos Szeredi Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, virtio-fs@redhat.com, linux-fsdevel@vger.kernel.org, Vivek Goyal References: <20210525150230.157586-1-groug@kaod.org> <20210525150230.157586-3-groug@kaod.org> From: Max Reitz Message-ID: <58c70352-2df5-0cb9-9ca6-bb4bf2edd1c2@redhat.com> Date: Thu, 27 May 2021 12:08:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210525150230.157586-3-groug@kaod.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25.05.21 17:02, Greg Kurz wrote: > We don't set the SB_BORN flag on submounts. This is wrong as these > superblocks are then considered as partially constructed or dying > in the rest of the code and can break some assumptions. > > One such case is when you have a virtiofs filesystem with submounts > and you try to mount it again : virtio_fs_get_tree() tries to obtain > a superblock with sget_fc(). The logic in sget_fc() is to loop until > it has either found an existing matching superblock with SB_BORN set > or to create a brand new one. It is assumed that a superblock without > SB_BORN is transient and should go away. Forgetting to set SB_BORN on > submounts hence causes sget_fc() to retry forever. > > Setting SB_BORN requires special care, i.e. a write barrier for > super_cache_count() which can check SB_BORN without taking any lock. > We should call vfs_get_tree() to deal with that but this requires > to have a proper ->get_tree() implementation for submounts, which > is a bigger piece of work. Go for a simple bug fix in the meatime. > > Fixes: bf109c64040f ("fuse: implement crossmounts") > Cc: mreitz@redhat.com > Cc: stable@vger.kernel.org # v5.10+ > Signed-off-by: Greg Kurz > --- > fs/fuse/dir.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c > index 01559061cbfb..3b0482738741 100644 > --- a/fs/fuse/dir.c > +++ b/fs/fuse/dir.c > @@ -346,6 +346,16 @@ static struct vfsmount *fuse_dentry_automount(struct path *path) > goto out_put_sb; > } > > + /* > + * FIXME: setting SB_BORN requires a write barrier for > + * super_cache_count(). We should actually come > + * up with a proper ->get_tree() implementation > + * for submounts and call vfs_get_tree() to take > + * care of the write barrier. > + */ > + smp_wmb(); > + sb->s_flags |= SB_BORN; > + I’m not sure whether we should have the order be exactly the same as in vfs_get_tree(), i.e. whether this should be put after fsc->root has been set. Or maybe even after fm has been added to fc->mounts, because that too was part of the fuse_get_tree_submount() function of your “fuse: Call vfs_get_tree() for submounts” patch. From a quick look at SB_BORN users, it doesn’t seem to make a difference to me, though, so: Reviewed-by: Max Reitz > sb->s_flags |= SB_ACTIVE; > fsc->root = dget(sb->s_root); > /* We are done configuring the superblock, so unlock it */ >