* NFS exporting btrfs subvolumes.
@ 2010-06-02 3:41 Neil Brown
2010-06-02 3:56 ` Trond Myklebust
0 siblings, 1 reply; 3+ messages in thread
From: Neil Brown @ 2010-06-02 3:41 UTC (permalink / raw)
To: linux-btrfs, linux-nfs, jeffm
NFS needs a unique identifier for a filesystem to be able to export it.
This can be set by the admin (fsid= in /etc/exports) but that is a hassle
and it is best to set it automatically.
nfs-utils currently uses the UUID returned by libblkid if that works,
or the fsid returned by statfs64 if libblkid finds nothings and
fsid is non-zero. Otherwise it uses device major/minor.
This doesn't work well for btrfs as all subvolumes are mounted from the same
device and so report the same UUID. But the fsid provides better uniqueness
(despite being only half as many bits), at least between different
subvolumes of the same filesystem.
This wasn't a problem between Aug 2008 (nfs-utils 1.1.4) when using fsid was
added, and Jan 2009 (util-linux 2.15-rc1) when UUID support for btrfs was
added to libblkid.
But with libblkid from util-linux 2.15 or later, nfs-utils needs a different
approach to synthesising a UUID for a btrfs filesystem.
The simplest would be to explicitly ignore btrfs results from libblkid as
the following patch does. However this is rather hackish, and wastes half
of the bits in the uuid.
Can anyone suggest a better way to get a good uuid for a btrfs filesystem?
Thanks,
NeilBrown
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index caef5b2..ffc5ac7 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -176,7 +176,8 @@ static const char *get_uuid_blkdev(char *path)
blkid_tag_iterate iter;
blkid_dev dev;
const char *type;
- const char *val = NULL;
+ const char *val;
+ const char *uuid_val = NULL;
if (cache == NULL)
blkid_get_cache(&cache, NULL);
@@ -193,11 +194,16 @@ static const char *get_uuid_blkdev(char *path)
iter = blkid_tag_iterate_begin(dev);
if (!iter)
return NULL;
- while (blkid_tag_next(iter, &type, &val) == 0)
+ while (blkid_tag_next(iter, &type, &val) == 0) {
if (strcmp(type, "UUID") == 0)
+ uuid_val = val;
+ if (strcmp(type, "TYPE") == 0 &&
+ strcmp(val, "btrfs") == 0) {
+ uuid_val = NULL;
break;
+ }
blkid_tag_iterate_end(iter);
- return val;
+ return uuid_val;
}
#else
#define get_uuid_blkdev(path) (NULL)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: NFS exporting btrfs subvolumes.
2010-06-02 3:41 NFS exporting btrfs subvolumes Neil Brown
@ 2010-06-02 3:56 ` Trond Myklebust
2010-06-02 5:03 ` Neil Brown
0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2010-06-02 3:56 UTC (permalink / raw)
To: Neil Brown; +Cc: linux-btrfs, linux-nfs, jeffm
On Wed, 2010-06-02 at 13:41 +1000, Neil Brown wrote:
> NFS needs a unique identifier for a filesystem to be able to export it.
<snip>
> Can anyone suggest a better way to get a good uuid for a btrfs filesystem?
How about just adding the btrfs subvolid to the filehandle and using
that to remove the ambiguity?
Cheers
Trond
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: NFS exporting btrfs subvolumes.
2010-06-02 3:56 ` Trond Myklebust
@ 2010-06-02 5:03 ` Neil Brown
0 siblings, 0 replies; 3+ messages in thread
From: Neil Brown @ 2010-06-02 5:03 UTC (permalink / raw)
To: Trond Myklebust; +Cc: linux-btrfs, linux-nfs, jeffm
On Tue, 01 Jun 2010 23:56:20 -0400
Trond Myklebust <trond.myklebust@fys.uio.no> wrote:
> On Wed, 2010-06-02 at 13:41 +1000, Neil Brown wrote:
> > NFS needs a unique identifier for a filesystem to be able to export it.
> <snip>
> > Can anyone suggest a better way to get a good uuid for a btrfs filesystem?
>
> How about just adding the btrfs subvolid to the filehandle and using
> that to remove the ambiguity?
The filehandle has two parts - one part identifies the filesystem
(i.e. vfsmnt), the other identifies the file (the dentry).
We would need to get the btrfs subvolid into the filesystem part,
and that is set (and looked-up) by mountd in user-space.
I think you are suggesting getting the btrfs kernel module to put the
subvolid in the filehandle, but that would only go in the 'file' part
of the handle, so it would not be sufficient.
We need a user-space program - preferably without too much
filesystem-specific info - to be able to differentiate subvolumes.
Thanks,
NeilBrown
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-02 5:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-02 3:41 NFS exporting btrfs subvolumes Neil Brown
2010-06-02 3:56 ` Trond Myklebust
2010-06-02 5:03 ` Neil Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).