Skip to contentSkip to conversation

master - libgfs2: Add support for UUID generation to gfs2_mkfs

Cluster-devel Fabio M. Di Nitto 2 participants 5 messages Oct 10, 2008 – Oct 13, 2008 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 9 lines · Steven Whitehouse
Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=85049a0824daa9abaa38f5dca377767907b53b39
Commit:        85049a0824daa9abaa38f5dca377767907b53b39
Parent:        d763f902abf33655e635fc3b8b1919fd31d4f66c
Author:        Steven Whitehouse <[email protected]>
AuthorDate:    Fri Oct 10 16:04:29 2008 +0100
Committer:     Steven Whitehouse <[email protected]>
CommitterDate: Fri Oct 10 16:12:12 2008 +0100

libgfs2: Add support for UUID generation to gfs2_mkfs

nice...

Quoted 7 lines

Uses /dev/urandom to create 16 byte UUIDs for GFS2 filesystems at mkfs time. Backwards and forwards compatible with all GFS2 filesystems.

You'll need a set of kernel headers with
the new field defined in order for this feature to be enabled. Bugzilla #242690

What kernel version is required to have UUID support? is it in .27 or will be in .28?

Quoted 10 lines
gfs2/libgfs2/structures.c +1 -1
index eb4c7bd..002edb6 100644
@@ -58,7 +58,17 @@ build_sb(struct gfs2_sbd *sdp)
 	sb.sb_root_dir = sdp->md.rooti->i_di.di_num;
 	strcpy(sb.sb_lockproto, sdp->lockproto);
 	strcpy(sb.sb_locktable, sdp->locktable);
-
+#ifdef GFS2_HAS_UUID

gfs2/libgfs2/structures.c build_sb(struct gfs2_sbd *sdp) · line 71

Quoted 10 lines
gfs2/libgfs2/structures.c +10 -0
+	{
+		int fd = open("/dev/urandom", O_RDONLY);
+		int n;
+		if (fd >= 0)
+			n = read(fd, &sb.sb_uuid, 16);
+		if (fd < 0 || n != 16)
+			memset(&sb.sb_uuid, 0, 16);
+		close(fd);
+	}
+#endif

NACK.

Please use libuuid for this operation.

Thanks
Fabio

--
I'm going to make him an offer he can't refuse.

#2 lore raw

Hi,

Quoted 18 lines · Fabio M. Di Nitto
Quoted 9 lines · Steven Whitehouse
Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=85049a0824daa9abaa38f5dca377767907b53b39
Commit:        85049a0824daa9abaa38f5dca377767907b53b39
Parent:        d763f902abf33655e635fc3b8b1919fd31d4f66c
Author:        Steven Whitehouse <[email protected]>
AuthorDate:    Fri Oct 10 16:04:29 2008 +0100
Committer:     Steven Whitehouse <[email protected]>
CommitterDate: Fri Oct 10 16:12:12 2008 +0100

libgfs2: Add support for UUID generation to gfs2_mkfs

nice...

Quoted 3 lines

Uses /dev/urandom to create 16 byte UUIDs for GFS2 filesystems at mkfs time. Backwards and forwards compatible with all GFS2 filesystems.

Quoted 7 lines
Quoted 3 lines

You'll need a set of kernel headers with
the new field defined in order for this feature to be enabled. Bugzilla #242690

What kernel version is required to have UUID support? is it in .27 or will be in .28?

It will be .28, but this is a build dep only. It doesn't make any difference what kernel you run once mkfs has been compiled.

Quoted 23 lines
Quoted 10 lines
gfs2/libgfs2/structures.c +1 -1
index eb4c7bd..002edb6 100644
@@ -58,7 +58,17 @@ build_sb(struct gfs2_sbd *sdp)
 	sb.sb_root_dir = sdp->md.rooti->i_di.di_num;
 	strcpy(sb.sb_lockproto, sdp->lockproto);
 	strcpy(sb.sb_locktable, sdp->locktable);
-
+#ifdef GFS2_HAS_UUID

gfs2/libgfs2/structures.c build_sb(struct gfs2_sbd *sdp) · line 71

Quoted 10 lines
gfs2/libgfs2/structures.c +10 -0
+	{
+		int fd = open("/dev/urandom", O_RDONLY);
+		int n;
+		if (fd >= 0)
+			n = read(fd, &sb.sb_uuid, 16);
+		if (fd < 0 || n != 16)
+			memset(&sb.sb_uuid, 0, 16);
+		close(fd);
+	}
+#endif

NACK.

Quoted 8 lines

Please use libuuid for this operation.

Thanks
Fabio

--
I'm going to make him an offer he can't refuse.

Hmm, well there are some problems with that... it will introduce another build dep, and one which we can't #ifdef around since it will be in the rpm rather than the source. Also libuuid seems somewhat over engineered. I guess we should set the format correctly though. Something like:

sb.sb_uuid[7] &= ~0xf0; /* time_hi_and_version */ sb.sb_uuid[7] |= 0x40;
sb.sb_uuid[8] &= ~0xc0; /* clock_seq_hi_and_reserved */ sb.sb_uuid[8] |= 0x40;

after the memset would do the trick. There doesn't seem much point using any of the other UUID formats since they seem to result less entropy than the random method and we have a reasonable random number generator available (which is not a PRNG despite the implication in the libuuid source).

Even with those 6 bits made constant we still have 122 bits left so the chances of clashing UUIDs is 1 in 2^122 assuming that we can rely on /dev/urandom so I don't think we are likely to have any problems here.

Steve.

#3 lore raw
Quoted 25 lines · Steven Whitehouse

Hi,

Quoted 22 lines · Fabio M. Di Nitto
Quoted 9 lines · Steven Whitehouse
Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=85049a0824daa9abaa38f5dca377767907b53b39
Commit:        85049a0824daa9abaa38f5dca377767907b53b39
Parent:        d763f902abf33655e635fc3b8b1919fd31d4f66c
Author:        Steven Whitehouse <[email protected]>
AuthorDate:    Fri Oct 10 16:04:29 2008 +0100
Committer:     Steven Whitehouse <[email protected]>
CommitterDate: Fri Oct 10 16:12:12 2008 +0100

libgfs2: Add support for UUID generation to gfs2_mkfs

nice...

Quoted 7 lines

Uses /dev/urandom to create 16 byte UUIDs for GFS2 filesystems at mkfs time. Backwards and forwards compatible with all GFS2 filesystems.

You'll need a set of kernel headers with
the new field defined in order for this feature to be enabled. Bugzilla #242690

Quoted 5 lines
Quoted 3 lines

What kernel version is required to have UUID support? is it in .27 or will be in .28?

It will be .28, but this is a build dep only. It doesn't make any difference what kernel you run once mkfs has been compiled.

Absolutely fine. I need to make sure to test when we switch to .28 headers.

Quoted 24 lines
Quoted 24 lines
Quoted 11 lines
gfs2/libgfs2/structures.c +1 -1
index eb4c7bd..002edb6 100644
@@ -58,7 +58,17 @@ build_sb(struct gfs2_sbd *sdp)
 	sb.sb_root_dir = sdp->md.rooti->i_di.di_num;
 	strcpy(sb.sb_lockproto, sdp->lockproto);
 	strcpy(sb.sb_locktable, sdp->locktable);
-
+#ifdef GFS2_HAS_UUID

gfs2/libgfs2/structures.c build_sb(struct gfs2_sbd *sdp) · line 71

Quoted 10 lines
gfs2/libgfs2/structures.c +10 -0
+	{
+		int fd = open("/dev/urandom", O_RDONLY);
+		int n;
+		if (fd >= 0)
+			n = read(fd, &sb.sb_uuid, 16);
+		if (fd < 0 || n != 16)
+			memset(&sb.sb_uuid, 0, 16);
+		close(fd);
+	}
+#endif

NACK.

Quoted 6 lines
Quoted 2 lines

Please use libuuid for this operation.

Hmm, well there are some problems with that... it will introduce another build dep, and one which we can't #ifdef around since it will be in the rpm rather than the source.

This is not an issue.

Quoted 1 line

Also libuuid seems somewhat over engineered.

Right, it is, but there are situations where /dev/urandom might not have the entropy required to spit out one single bit. I have seen it happening a few times, specially on remote servers where there is no mouse or keyboard to generate randomness and took over a few hours to generate an ssh key.

Quoted 13 lines

I guess we should set the format correctly though. Something like:

sb.sb_uuid[7] &= ~0xf0; /* time_hi_and_version */ sb.sb_uuid[7] |= 0x40;
sb.sb_uuid[8] &= ~0xc0; /* clock_seq_hi_and_reserved */ sb.sb_uuid[8] |= 0x40;

after the memset would do the trick. There doesn't seem much point using any of the other UUID formats since they seem to result less entropy than the random method and we have a reasonable random number generator available (which is not a PRNG despite the implication in the libuuid source).

Quoted 4 lines

Even with those 6 bits made constant we still have 122 bits left so the chances of clashing UUIDs is 1 in 2^122 assuming that we can rely on /dev/urandom so I don't think we are likely to have any problems here.

I would still prefer to avoid implementating our own version of a UUID generator and rely on what's already done.

Fabio

--
I'm going to make him an offer he can't refuse.

#4 lore raw

Hi,

Quoted 27 lines · Fabio M. Di Nitto
Quoted 25 lines · Steven Whitehouse

Hi,

Quoted 22 lines · Fabio M. Di Nitto
Quoted 9 lines · Steven Whitehouse
Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=85049a0824daa9abaa38f5dca377767907b53b39
Commit:        85049a0824daa9abaa38f5dca377767907b53b39
Parent:        d763f902abf33655e635fc3b8b1919fd31d4f66c
Author:        Steven Whitehouse <[email protected]>
AuthorDate:    Fri Oct 10 16:04:29 2008 +0100
Committer:     Steven Whitehouse <[email protected]>
CommitterDate: Fri Oct 10 16:12:12 2008 +0100

libgfs2: Add support for UUID generation to gfs2_mkfs

nice...

Quoted 7 lines

Uses /dev/urandom to create 16 byte UUIDs for GFS2 filesystems at mkfs time. Backwards and forwards compatible with all GFS2 filesystems.

You'll need a set of kernel headers with
the new field defined in order for this feature to be enabled. Bugzilla #242690

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

What kernel version is required to have UUID support? is it in .27 or will be in .28?

It will be .28, but this is a build dep only. It doesn't make any difference what kernel you run once mkfs has been compiled.

Absolutely fine. I need to make sure to test when we switch to .28 headers.

Ok, sounds good.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 11 lines
gfs2/libgfs2/structures.c +1 -1
index eb4c7bd..002edb6 100644
@@ -58,7 +58,17 @@ build_sb(struct gfs2_sbd *sdp)
 	sb.sb_root_dir = sdp->md.rooti->i_di.di_num;
 	strcpy(sb.sb_lockproto, sdp->lockproto);
 	strcpy(sb.sb_locktable, sdp->locktable);
-
+#ifdef GFS2_HAS_UUID

gfs2/libgfs2/structures.c build_sb(struct gfs2_sbd *sdp) · line 71

Quoted 10 lines
gfs2/libgfs2/structures.c +10 -0
+	{
+		int fd = open("/dev/urandom", O_RDONLY);
+		int n;
+		if (fd >= 0)
+			n = read(fd, &sb.sb_uuid, 16);
+		if (fd < 0 || n != 16)
+			memset(&sb.sb_uuid, 0, 16);
+		close(fd);
+	}
+#endif

NACK.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Please use libuuid for this operation.

Hmm, well there are some problems with that... it will introduce another build dep, and one which we can't #ifdef around since it will be in the rpm rather than the source.

This is not an issue.

Well I'm very cautious about adding any deps. If we have to do it, then it seems ok, but I'd rather avoid it if possible.

Quoted 8 lines
Quoted 1 line

Also libuuid seems somewhat over engineered.

Right, it is, but there are situations where /dev/urandom might not have the entropy required to spit out one single bit. I have seen it happening a few times, specially on remote servers where there is no mouse or keyboard to generate randomness and took over a few hours to generate an ssh key.

/dev/urandom should not block, neither should ssh be using it, it ought to be using /dev/random instead (which might block for the reason you mention). Bearing in mind that creating a filesystem requires disk I/O, that should help to refill the entropy pool anyway.

Quoted 18 lines
Quoted 13 lines

I guess we should set the format correctly though. Something like:

sb.sb_uuid[7] &= ~0xf0; /* time_hi_and_version */ sb.sb_uuid[7] |= 0x40;
sb.sb_uuid[8] &= ~0xc0; /* clock_seq_hi_and_reserved */ sb.sb_uuid[8] |= 0x40;

after the memset would do the trick. There doesn't seem much point using any of the other UUID formats since they seem to result less entropy than the random method and we have a reasonable random number generator available (which is not a PRNG despite the implication in the libuuid source).

Quoted 4 lines

Even with those 6 bits made constant we still have 122 bits left so the chances of clashing UUIDs is 1 in 2^122 assuming that we can rely on /dev/urandom so I don't think we are likely to have any problems here.

Quoted 7 lines

I would still prefer to avoid implementating our own version of a UUID generator and rely on what's already done.

Fabio

--
I'm going to make him an offer he can't refuse.

Hmmm, well I've put my thinking cap on over this one.... I'm not convinced yet, but watch this space....

Steve.

#5 lore raw
Quoted 8 lines · Steven Whitehouse

Hi,

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

NACK.

Please use libuuid for this operation.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Hmm, well there are some problems with that... it will introduce another build dep, and one which we can't #ifdef around since it will be in the rpm rather than the source.

This is not an issue.

Well I'm very cautious about adding any deps. If we have to do it, then it seems ok, but I'd rather avoid it if possible.

It is a fair concern.. but we are not trying to pull in libmono or .NET. Our build system already requires python and perl... this is a small one. Go for it.

Quoted 6 lines
Quoted 3 lines

--
I'm going to make him an offer he can't refuse.

Hmmm, well I've put my thinking cap on over this one.... I'm not convinced yet, but watch this space....

ahahahah

Fabio