Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1013341pxj; Thu, 17 Jun 2021 20:10:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrvRMgH2Tp0bLF+Wa7g0G+rvTCdNgJB88YPEAHQDvdETTy040ESbqcEnr59hCMjr28za8u X-Received: by 2002:a17:907:7050:: with SMTP id ws16mr111519ejb.95.1623985836147; Thu, 17 Jun 2021 20:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623985836; cv=none; d=google.com; s=arc-20160816; b=DzF9AqSTkRxbkUfH0bFuVScVIi+tFdA6w7IxmIMaKy1OU9/RWn1jHKOee9jAwFiA+/ OyeBV51Bo1upi/x+EgH5pWPCKeqXGRCXGw3wDeGSIL/SlwAPljCVUH8zW8yfGdW02h9L f/O7b3q2vSwuMJxTDZBoGzGHGonxJMskhu0f4R56FvdWNsQ1mVbX845D2hozSZWB5jWu rCOPRTFqN8Ce+8m2cQmyeotcMbTffXNJH/41xvaIBpbSjPbA+Ve0QO7HBLJHX/ZKq376 K9aRtIKQUD8nUhDILW9Oh/e/78sG2Wj1f2UxfFotPCrHpjNHWEZZglgJy+naxjHAAN7Q 0DDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=GRCQl2S+jt9CEBtKavfWh/wYRhBdJqIg1NrFwobQu2g=; b=pSuyCcnLuirt3cEb/3oZNR+O5rmpHzUrD9FlRoFKnKY3nOGK4vZFMwOdmh8cV0+K0t nPFtAdjezfVCR3t4jMgp/1/GaRQLvVU3YjMxC2XFpo6ET1MJhxavy9CRBYK5jpJimnJO I7lKi+sjw/L9ltjPkLuk2oUQsoVMzA4QC+XGZNVJRXBXJ1CSXGgwMV995A3bDkqSaF8g SATFw5xbtiyf8dcpoTLQtIL58AUkT2zE2mOEnbl5DdpFixBtDPAAvzlDiyMsv0FmFAnj KOsPh7zS2vrRj/AP2M7jbP4yiHzGoZZpmwKEiDYWTxt+ESViXdtaymfQ7sPNKBZW/bQz L2HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=osln04UA; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=GpLrqZIi; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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 u21si7397068edy.178.2021.06.17.20.10.07; Thu, 17 Jun 2021 20:10:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@suse.de header.s=susede2_rsa header.b=osln04UA; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=GpLrqZIi; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233067AbhFRAfK (ORCPT + 99 others); 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