Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4276549pxj; Mon, 21 Jun 2021 18:29:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLKhYbxYUTIVuVJroJuiKWFLJ62Gb6jsGq77USpf+DHnr9Ht9BzbFJ1HZh84DRA0GzbeID X-Received: by 2002:a17:906:590a:: with SMTP id h10mr1059112ejq.346.1624325368159; Mon, 21 Jun 2021 18:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624325368; cv=none; d=google.com; s=arc-20160816; b=NE+VUbgpkkBnrTSAj1eojPOPfSAY7WfOp44lPZXQcc1UvmEQ+1Enloy++VoRtIUa8A UvBHIig2VcAwcoJ+lJ/y7ZNGtqXB6sYFB20AC55lrJbvY4j3pyozXNLnS+4aQXvWWi99 xrPkKenBb3tQHoBoRT1cPZEkVa9J45+VtKPB45sXe2OUF3LsyXzmf5Qg1YyqJbksktKa D7sDSwpvIsLSYAd3J1+uI0YjEwG6foA4Dme/6qGTZ3CrY8myHdgxpvvoMNOk5o5AcvBp Vx5XT366htLm6KGOe9LnYiDrGBZOoQEzLHEbbrYutadM/s1WDdfQgbihEaszYZqmSJwb OnHw== 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=wz+J/uP8RsXnw+1vAX2T4U49+KY+xmVJYwr2cgDWqlU=; b=Kx/PuI22oS2mK032oJJFldEWt80qFuL+RpVUzYWzaGag3fczvu5MogepLq1YBeOoxV tij8hgJ3WVXVjAFzf3bJzPR1yCh9hm5+1ZpAOJHsgJHtgoOT2wVwVFOlGRv4ZvCZs8Q5 gYHHqSKryjRz3zR9YQLYEm5DJNf6Fy1iRlZiyycXB4TqrvKqvRB7YTTZufQvuC+nNEtv Of+6yo4WJ2EuRjkEL/ROav+6irGOk+1zE+R70T4Q3b4eyPWjPazhIAWLEMBjXwxwx1g/ zq72XxE8uQEvE6/ZbuAygePtW3Pjc98LitdVqiWj5/Km331iByupT6VowGGJh+j4NKur R9oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=J7YupEmn; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=J7YupEmn; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=KxxUudK9; 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 h14si18452803edr.463.2021.06.21.18.28.50; Mon, 21 Jun 2021 18:29:28 -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=J7YupEmn; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=J7YupEmn; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=KxxUudK9; 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 S230082AbhFVBay (ORCPT + 99 others); Mon, 21 Jun 2021 21:30:54 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:36280 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229663AbhFVBay (ORCPT ); Mon, 21 Jun 2021 21:30:54 -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 59EA41FD33; Tue, 22 Jun 2021 01:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1624325318; 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=wz+J/uP8RsXnw+1vAX2T4U49+KY+xmVJYwr2cgDWqlU=; b=J7YupEmnCckIVCUNj1oYEUamettmhBgqO64pky4DpLw+rFdwgbsH2sNbTv9p4fvoqrD/ey lQ+pm6IXt30n1Zpj8BXTLXLTl4PB7ufA8kBzNbaDqZ7rovXdwdbYakMKaAmRYPTxEZpDca 0oFCXkwbPtpL+h5T97oss/mM9R0PpV4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1624325318; 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=wz+J/uP8RsXnw+1vAX2T4U49+KY+xmVJYwr2cgDWqlU=; b=KxxUudK96y57umJQHsqHwWau/sJDbbnVujMjjQwBZWJYydZjPHbOaEH1lZTWLd0JBD/eU8 rBbrFNkSaa6NJRCg== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 5609D118DD; Tue, 22 Jun 2021 01:28:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1624325318; 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=wz+J/uP8RsXnw+1vAX2T4U49+KY+xmVJYwr2cgDWqlU=; b=J7YupEmnCckIVCUNj1oYEUamettmhBgqO64pky4DpLw+rFdwgbsH2sNbTv9p4fvoqrD/ey lQ+pm6IXt30n1Zpj8BXTLXLTl4PB7ufA8kBzNbaDqZ7rovXdwdbYakMKaAmRYPTxEZpDca 0oFCXkwbPtpL+h5T97oss/mM9R0PpV4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1624325318; 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=wz+J/uP8RsXnw+1vAX2T4U49+KY+xmVJYwr2cgDWqlU=; b=KxxUudK96y57umJQHsqHwWau/sJDbbnVujMjjQwBZWJYydZjPHbOaEH1lZTWLd0JBD/eU8 rBbrFNkSaa6NJRCg== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id BzXWAcU80WD7cgAALh3uQQ (envelope-from ); Tue, 22 Jun 2021 01:28:37 +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: <20210621163441.428C.409509F4@e16-tech.com> References: <162425113589.17441.4163890972298681569@noble.neil.brown.name>, <162425240757.17441.3695249639927377778@noble.neil.brown.name>, <20210621163441.428C.409509F4@e16-tech.com> Date: Tue, 22 Jun 2021 11:28:33 +1000 Message-id: <162432531379.17441.15110145423567943074@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Mon, 21 Jun 2021, Wang Yugui wrote: > Hi, >=20 > > > > It seems more fixes are needed. > > >=20 > > > I think the problem is that the submount doesn't appear in /proc/mounts. > > > "nfsd_fh()" in nfs-utils needs to be able to map from the uuid for a > > > filesystem to the mount point. To do this it walks through /proc/mounts > > > checking the uuid of each filesystem. If a filesystem isn't listed > > > there, it obviously fails. > > >=20 > > > I guess you could add code to nfs-utils to do whatever "btrfs subvol > > > list" does to make up for the fact that btrfs doesn't register in > > > /proc/mounts. > >=20 > > Another approach might be to just change svcxdr_encode_fattr3() and > > nfsd4_encode_fattr() in the 'FSIDSOJURCE_UUID' case to check if > > dentry->d_inode has a different btrfs volume id to > > exp->ex_path.dentry->d_inode. > > If it does, then mix the volume id into the fsid somehow. > >=20 > > With that, you wouldn't want the first change I suggested. >=20 > This is what I have done. and it is based on linux 5.10.44 >=20 > but it still not work, so still more jobs needed. >=20 The following is more what I had in mind. It doesn't quite work and I cannot work out why. If you 'stat' a file inside the subvol, then 'find' will not complete. If you don't, then it will. Doing that 'stat' changes the st_dev number of the main filesystem, which seems really weird. I'm probably missing something obvious. Maybe a more careful analysis of what is changing when will help. NeilBrown diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 9421dae22737..790a3357525d 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include =20 @@ -575,6 +576,7 @@ static int svc_export_parse(struct cache_detail *cd, char= *mesg, int mlen) int err; struct auth_domain *dom =3D NULL; struct svc_export exp =3D {}, *expp; + struct kstatfs statfs; int an_int; =20 if (mesg[mlen-1] !=3D '\n') @@ -604,6 +606,10 @@ static int svc_export_parse(struct cache_detail *cd, cha= r *mesg, int mlen) err =3D kern_path(buf, 0, &exp.ex_path); if (err) goto out1; + err =3D vfs_statfs(&exp.ex_path, &statfs); + if (err) + goto out3; + exp.ex_fsid64 =3D statfs.f_fsid; =20 exp.ex_client =3D dom; exp.cd =3D cd; @@ -809,6 +815,7 @@ static void export_update(struct cache_head *cnew, struct= cache_head *citem) new->ex_anon_uid =3D item->ex_anon_uid; new->ex_anon_gid =3D item->ex_anon_gid; new->ex_fsid =3D item->ex_fsid; + new->ex_fsid64 =3D item->ex_fsid64; new->ex_devid_map =3D item->ex_devid_map; item->ex_devid_map =3D NULL; new->ex_uuid =3D item->ex_uuid; diff --git a/fs/nfsd/export.h b/fs/nfsd/export.h index ee0e3aba4a6e..d3eb9a599918 100644 --- a/fs/nfsd/export.h +++ b/fs/nfsd/export.h @@ -68,6 +68,7 @@ struct svc_export { kuid_t ex_anon_uid; kgid_t ex_anon_gid; int ex_fsid; + __kernel_fsid_t ex_fsid64; unsigned char * ex_uuid; /* 16 byte fsid */ struct nfsd4_fs_locations ex_fslocs; uint32_t ex_nflavors; diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 7abeccb975b2..8144e6037eae 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2869,6 +2869,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_f= h *fhp, if (err) goto out_nfserr; if ((bmval0 & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE | + FATTR4_WORD0_FSID | FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_MAXNAME)) || (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | FATTR4_WORD1_SPACE_TOTAL))) { @@ -3024,6 +3025,12 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_= fh *fhp, case FSIDSOURCE_UUID: p =3D xdr_encode_opaque_fixed(p, exp->ex_uuid, EX_UUID_LEN); + if (statfs.f_fsid.val[0] !=3D exp->ex_fsid64.val[0] || + statfs.f_fsid.val[1] !=3D exp->ex_fsid64.val[1]) { + /* looks like a btrfs subvol */ + p[-2] ^=3D statfs.f_fsid.val[0]; + p[-1] ^=3D statfs.f_fsid.val[1]; + } break; } }