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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 295DCC2B9F4 for ; Fri, 18 Jun 2021 00:33:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11149610EA for ; Fri, 18 Jun 2021 00:33:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233067AbhFRAfK (ORCPT ); Thu, 17 Jun 2021 20:35:10 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:50192 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232683AbhFRAfK (ORCPT ); Thu, 17 Jun 2021 20:35:10 -0400 Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 160521FD8A; Fri, 18 Jun 2021 00:33:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623976381; h=from:from:reply-to: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=GRCQl2S+jt9CEBtKavfWh/wYRhBdJqIg1NrFwobQu2g=; b=osln04UAtncq+LZWY/FhB2mcD9TXGnCFdVN47QwWoMcHfDsi4T5VYuX8EWLdTEE9kNXnKH OkqYpuGotwzIpi3MuoLVVJL6aJEPzlT2aEdljwMkw5ZqAg0ZST0n9rLsDDGUduz2dcZ7+N efgX/8yXiCWq/JLMWKfWZcdutG91MOI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623976381; h=from:from:reply-to: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=GRCQl2S+jt9CEBtKavfWh/wYRhBdJqIg1NrFwobQu2g=; b=BH8g7DvADM3cmYAUMNwsp5f1Af2MhMaRyP/CSa1WaCADx1dQVmOMHaiyj5N1929XQJ0FFl qxugFGI8HpKX/0BQ== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 092CE118DD; Fri, 18 Jun 2021 00:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623976380; h=from:from:reply-to: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=GRCQl2S+jt9CEBtKavfWh/wYRhBdJqIg1NrFwobQu2g=; b=GpLrqZIifZhUY3VbKz92avhn8emgI8Vh7VmVBVGQyb9uSWr1fzbgLHXxm1QNJfyk52HrkE Erzg/K2wtZncwygzIKEum8bU4qIPI+zI9CTJ8259+iAk2v4L9NZbfnWvZ7/7RGdo1KpUzo 4hOrhSW1fQUAxMnZGmpaOUIu29mX3DY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623976380; h=from:from:reply-to: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=GRCQl2S+jt9CEBtKavfWh/wYRhBdJqIg1NrFwobQu2g=; b=tZ0ISTA78650y0lUbcoo569h07spjwXPs6gL7cYNmsA2tSFuoP+Pa3H2PyZ5CtWYGTF/p9 AJV9ABmXXAYSLqAg== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id vx4zK7vpy2BmZQAALh3uQQ (envelope-from ); Fri, 18 Jun 2021 00:32:59 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "Wang Yugui" Cc: linux-nfs@vger.kernel.org Subject: Re: any idea about auto export multiple btrfs snapshots? In-reply-to: <20210617122852.BE6A.409509F4@e16-tech.com> References: <20210615231318.F40F.409509F4@e16-tech.com>, <162389895501.29912.12470238090250719500@noble.neil.brown.name> Date: Fri, 18 Jun 2021 10:32:56 +1000 Message-id: <162397637680.29912.2268876490205517592@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, 17 Jun 2021, Wang Yugui wrote: > > Can we go back to the beginning. What, exactly, is the problem you are > > trying to solve? How can you demonstrate the problem? > >=20 > > NeilBrown >=20 > I nfs/exported a btrfs with 2 subvols and 2 snapshot(subvol). >=20 > # btrfs subvolume list /mnt/test > ID 256 gen 53 top level 5 path sub1 > ID 260 gen 56 top level 5 path sub2 > ID 261 gen 57 top level 5 path .snapshot/sub1-s1 > ID 262 gen 57 top level 5 path .snapshot/sub2-s1 >=20 > and then mount.nfs4 it to /nfs/test. >=20 > # /bin/find /nfs/test/ > /nfs/test/ > find: File system loop detected; '/nfs/test/sub1' is part of the same file = system loop as '/nfs/test/'. > /nfs/test/.snapshot > find: File system loop detected; '/nfs/test/.snapshot/sub1-s1' is part of t= he same file system loop as '/nfs/test/'. > find: File system loop detected; '/nfs/test/.snapshot/sub2-s1' is part of t= he same file system loop as '/nfs/test/'. > /nfs/test/dir1 > /nfs/test/dir1/a.txt > find: File system loop detected; '/nfs/test/sub2' is part of the same file = system loop as '/nfs/test/' >=20 > /bin/find report 'File system loop detected'. so I though there is > something wrong. Certainly something is wrong. The error message implies that some directory is reporting the same dev an ino as an ancestor directory. Presumably /nfs/test and /nfs/test/sub1. Can you confirm that please. e.g. run the command stat /nfs/test /nfs/test/sub1 and examine the output. As sub1 is considered a different file system, it should have a different dev number. NFS will assign a different device number only when the server reports a different fsid. The Linux NFS server will report a different fsid if d_mountpoint() is 'true' for the dentry, and follow_down() results in no change the the vfsmnt,dentry in a 'struct path'. You have already said that d_mountpoint doesn't work for btrfs, so that is part of the problem. NFSD doesn't trust d_mountpoint completely as it only reports that the dentry is a mountpoint in some namespace, not necessarily in this namespace. So you really need to fix nfsd_mountpoint. I suggest you try adding your "dirty fix" to nfsd_mountpoint() so that it reports the root of a btrfs subvol as a mountpoint, and see if that fixes the problem. It should change the problem at least. You would need to get nfsd_mountpoint() to return '1' in this case, not '2'. NeilBrown