From: Wang Yugui <wangyugui@e16-tech.com>
To: "NeilBrown" <neilb@suse.de>
Cc: linux-nfs@vger.kernel.org
Subject: Re: any idea about auto export multiple btrfs snapshots?
Date: Wed, 23 Jun 2021 17:34:03 +0800 [thread overview]
Message-ID: <20210623173403.08C2.409509F4@e16-tech.com> (raw)
In-Reply-To: <162442979121.28671.4357679695701460832@noble.neil.brown.name>
[-- Attachment #1: Type: text/plain, Size: 3858 bytes --]
Hi,
> On Wed, 23 Jun 2021, Wang Yugui wrote:
> > Hi,
> >
> > This patch works very well. Thanks a lot.
> > - crossmnt of btrfs subvol works as expected.
> > - nfs/umount subvol works well.
> > - pseudo mount point inode(255) is good.
> >
> > I test it in 5.10.45 with a few minor rebase.
> > ( see 0001-any-idea-about-auto-export-multiple-btrfs-snapshots.patch,
> > just fs/nfsd/nfs3xdr.c rebase)
> >
> > But when I tested it with another btrfs system without subvol but with
> > more data, 'find /nfs/test' caused a OOPS . and this OOPS will not
> > happen just without this patch.
> >
> > The data in this filesystem is created/left by xfstest(FSTYP=nfs,
> > TEST_DEV).
> >
> > #nfs4 option: default mount.nfs4, nfs-utils-2.3.3
> >
> > # access btrfs directly
> > $ find /mnt/test | wc -l
> > 6612
> >
> > # access btrfs through nfs
> > $ find /nfs/test | wc -l
> >
> > [ 466.164329] BUG: kernel NULL pointer dereference, address: 0000000000000004
> > [ 466.172123] #PF: supervisor read access in kernel mode
> > [ 466.177857] #PF: error_code(0x0000) - not-present page
> > [ 466.183601] PGD 0 P4D 0
> > [ 466.186443] Oops: 0000 [#1] SMP NOPTI
> > [ 466.190536] CPU: 27 PID: 1819 Comm: nfsd Not tainted 5.10.45-7.el7.x86_64 #1
> > [ 466.198418] Hardware name: Dell Inc. PowerEdge T620/02CD1V, BIOS 2.9.0 12/06/2019
> > [ 466.206806] RIP: 0010:fsid_source+0x7/0x50 [nfsd]
>
> in nfsd4_encode_fattr there is code:
>
> if ((bmval0 & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) && !fhp) {
> tempfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL);
> status = nfserr_jukebox;
> if (!tempfh)
> goto out;
> fh_init(tempfh, NFS4_FHSIZE);
> status = fh_compose(tempfh, exp, dentry, NULL);
> if (status)
> goto out;
> fhp = tempfh;
> }
>
> Change that to test for (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) as
> well.
>
> NeilBrown
It works well.
- if ((bmval0 & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) && !fhp) {
+ if (((bmval0 & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) ||
+ (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID))
+ && !fhp) {
tempfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL);
status = nfserr_jukebox;
if (!tempfh)
And I tested some case about statfs.f_fsid conflict between btrfs
filesystem, and it works well too.
Is it safe in theory too?
test case:
two btrfs filesystem with just 1 bit diff of UUID
# blkid /dev/sdb1 /dev/sdb2
/dev/sdb1: UUID="35327ecf-a5a7-4617-a160-1fdbfd644940" UUID_SUB="a831ebde-1e66-4592-bfde-7a86fd6478b5" BLOCK_SIZE="4096" TYPE="btrfs" PARTLABEL="primary" PARTUUID="3e30a849-88db-4fb3-92e6-b66bfbe9cb98"
/dev/sdb2: UUID="35327ecf-a5a7-4617-a160-1fdbfd644941" UUID_SUB="31e07d66-a656-48a8-b1fb-5b438565238e" BLOCK_SIZE="4096" TYPE="btrfs" PARTLABEL="primary" PARTUUID="93a2db85-065a-4ecf-89d4-6a8dcdb8ff99"
both have 3 subvols.
# btrfs subvolume list /mnt/test
ID 256 gen 13 top level 5 path sub1
ID 257 gen 13 top level 5 path sub2
ID 258 gen 13 top level 5 path sub3
# btrfs subvolume list /mnt/scratch
ID 256 gen 13 top level 5 path sub1
ID 257 gen 13 top level 5 path sub2
ID 258 gen 13 top level 5 path sub3
statfs.f_fsid.c is the source of 'statfs' command.
# statfs /mnt/test/sub1 /mnt/test/sub2 /mnt/test/sub3 /mnt/scratch/sub1 /mnt/scratch/sub2 /mnt/scratch/sub3
/mnt/test/sub1
f_fsid=0x9452611458c30e57
/mnt/test/sub2
f_fsid=0x9452611458c30e56
/mnt/test/sub3
f_fsid=0x9452611458c30e55
/mnt/scratch/sub1
f_fsid=0x9452611458c30e56
/mnt/scratch/sub2
f_fsid=0x9452611458c30e57
/mnt/scratch/sub3
f_fsid=0x9452611458c30e54
statfs.f_fsid is uniq inside a btrfs and it's subvols.
but statfs.f_fsid is NOT uniq between btrfs filesystems because just 1
bit diff of UUID.
'find /mnt/test/' and 'find /mnt/scratch/' works as expected.
Best Regards
Wang Yugui (wangyugui@e16-tech.com)
2021/06/23
[-- Attachment #2: statfs.f_fsid.c --]
[-- Type: application/octet-stream, Size: 698 bytes --]
#define __USE_LARGEFILE64
#include <stdio.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/statfs.h>
int main(int argc, char **argv)
{
struct statfs st;
char *path;
int ret=0;
if (argc < 2) {
fprintf(stderr, "Usage:%s path [path].. \n", argv[0]);
return 1;
}
for (int i = 1; i < argc; ++i) {
path = argv[i];
if (statfs(path, &st) == 0 &&
(st.f_fsid.__val[0] || st.f_fsid.__val[1])) {
fprintf(stdout, "%s\n\tf_fsid=0x%08x%08x\n", path,
st.f_fsid.__val[0], st.f_fsid.__val[1]);
} else {
fprintf(stdout, "%s\n\tstatfs error or null f_fsid.\n",path);
ret=1;
}
}
return ret;
}
next prev parent reply other threads:[~2021-06-23 9:34 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-13 3:53 any idea about auto export multiple btrfs snapshots? Wang Yugui
2021-06-14 22:50 ` NeilBrown
2021-06-15 15:13 ` Wang Yugui
2021-06-15 15:41 ` Wang Yugui
2021-06-16 5:47 ` Wang Yugui
2021-06-17 3:02 ` NeilBrown
2021-06-17 4:28 ` Wang Yugui
2021-06-18 0:32 ` NeilBrown
2021-06-18 7:26 ` Wang Yugui
2021-06-18 13:34 ` Wang Yugui
2021-06-19 6:47 ` Wang Yugui
2021-06-20 12:27 ` Wang Yugui
2021-06-21 4:52 ` NeilBrown
2021-06-21 5:13 ` NeilBrown
2021-06-21 8:34 ` Wang Yugui
2021-06-22 1:28 ` NeilBrown
2021-06-22 3:22 ` Wang Yugui
2021-06-22 7:14 ` Wang Yugui
2021-06-23 0:59 ` NeilBrown
2021-06-23 6:14 ` Wang Yugui
2021-06-23 6:29 ` NeilBrown
2021-06-23 9:34 ` Wang Yugui [this message]
2021-06-23 23:38 ` NeilBrown
2021-06-23 15:35 ` J. Bruce Fields
2021-06-23 22:04 ` NeilBrown
2021-06-23 22:25 ` J. Bruce Fields
2021-06-23 23:29 ` NeilBrown
2021-06-23 23:41 ` Frank Filz
2021-06-24 0:01 ` J. Bruce Fields
2021-06-24 21:58 ` Patrick Goetz
2021-06-24 23:27 ` NeilBrown
2021-06-21 14:35 ` Frank Filz
2021-06-21 14:55 ` Wang Yugui
2021-06-21 17:49 ` Frank Filz
2021-06-21 22:41 ` Wang Yugui
2021-06-22 17:34 ` Frank Filz
2021-06-22 22:48 ` Wang Yugui
2021-06-17 2:15 ` Wang Yugui
[not found] ` <20210310074620.GA2158@tik.uni-stuttgart.de>
[not found] ` <162632387205.13764.6196748476850020429@noble.neil.brown.name>
2021-07-15 14:09 ` [PATCH/RFC] NFSD: handle BTRFS subvolumes better Josef Bacik
2021-07-15 16:45 ` Christoph Hellwig
2021-07-15 17:11 ` Josef Bacik
2021-07-15 17:24 ` Christoph Hellwig
2021-07-15 18:01 ` Josef Bacik
2021-07-15 22:37 ` NeilBrown
2021-07-19 15:40 ` Josef Bacik
2021-07-19 20:00 ` J. Bruce Fields
2021-07-19 20:44 ` Josef Bacik
2021-07-19 23:53 ` NeilBrown
2021-07-19 15:49 ` J. Bruce Fields
2021-07-20 0:02 ` NeilBrown
2021-07-19 9:16 ` Christoph Hellwig
2021-07-19 23:54 ` NeilBrown
2021-07-20 6:23 ` Christoph Hellwig
2021-07-20 7:17 ` NeilBrown
2021-07-20 8:00 ` Christoph Hellwig
2021-07-20 23:11 ` NeilBrown
2021-07-20 22:10 ` J. Bruce Fields
2021-07-15 23:02 ` NeilBrown
2021-07-15 15:45 ` J. Bruce Fields
2021-07-15 23:08 ` NeilBrown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210623173403.08C2.409509F4@e16-tech.com \
--to=wangyugui@e16-tech.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox