Skip to contentSkip to conversation

Use unified UUID/GUID definition in gfs2

RFC In review Huang Ying 3 participants 8 messages Oct 14, 2009 – Nov 3, 2009 GFS2 file system

lore
Share & tools
lore

Huang Ying

author
#0 lore raw

RFC 2/2 Use unified UUID/GUID definition in gfs2

Replace u8[16] UUID definition in gfs2.

---
 fs/gfs2/incore.h            |    3 ++-
 fs/gfs2/ops_fstype.c        |    2 +-
 fs/gfs2/sys.c               |   14 ++++----------
 include/linux/gfs2_ondisk.h |    3 ++-
 4 files changed, 9 insertions(+), 13 deletions(-)
fs/gfs2/incore.h +2 -1
@@ -15,6 +15,7 @@
 #include <linux/slow-work.h>
 #include <linux/dlm.h>
 #include <linux/buffer_head.h>
+#include <linux/uuid.h>
 
 #define DIO_WAIT	0x00000010
 #define DIO_METADATA	0x00000020
@@ -483,7 +484,7 @@ struct gfs2_sb_host {
 
 	char sb_lockproto[GFS2_LOCKNAME_LEN];
 	char sb_locktable[GFS2_LOCKNAME_LEN];
-	u8 sb_uuid[16];
+	uuid_be sb_uuid;
 };
 
 /*
fs/gfs2/sys.c +4 -10
@@ -68,20 +68,14 @@ static ssize_t fsname_show(struct gfs2_s
 	return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname);
 }
 
-static int gfs2_uuid_valid(const u8 *uuid)
+static int gfs2_uuid_valid(const uuid_be *uuid)
 {
-	int i;
-
-	for (i = 0; i < 16; i++) {
-		if (uuid[i])
-			return 1;
-	}
-	return 0;
+	return uuid_be_cmp(*uuid, NULL_UUID_BE);
 }
 
 static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf)
 {
-	const u8 *uuid = sdp->sd_sb.sb_uuid;
+	const uuid_be *uuid = &sdp->sd_sb.sb_uuid;
 	buf[0] = '\0';
 	if (!gfs2_uuid_valid(uuid))
 		return 0;
@@ -563,7 +557,7 @@ static int gfs2_uevent(struct kset *kset
 		       struct kobj_uevent_env *env)
 {
 	struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
-	const u8 *uuid = sdp->sd_sb.sb_uuid;
+	const uuid_be *uuid = &sdp->sd_sb.sb_uuid;
 
 	add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name);
 	add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
include/linux/gfs2_ondisk.h +2 -1
@@ -11,6 +11,7 @@
 #define __GFS2_ONDISK_DOT_H__
 
 #include <linux/types.h>
+#include <linux/uuid.h>
 
 #define GFS2_MAGIC		0x01161970
 #define GFS2_BASIC_BLOCK	512
@@ -124,7 +125,7 @@ struct gfs2_sb {
 	struct gfs2_inum __pad3; /* Was quota inode in gfs1 */
 	struct gfs2_inum __pad4; /* Was licence inode in gfs1 */
 #define GFS2_HAS_UUID 1
-	__u8 sb_uuid[16]; /* The UUID, maybe 0 for backwards compat */
+	uuid_be sb_uuid; /* The UUID, maybe 0 for backwards compat */
 };
 
 /*
fs/gfs2/ops_fstype.c +1 -1
@@ -233,7 +233,7 @@ static void gfs2_sb_in(struct gfs2_sb_ho
 
 	memcpy(sb->sb_lockproto, str->sb_lockproto, GFS2_LOCKNAME_LEN);
 	memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN);
-	memcpy(sb->sb_uuid, str->sb_uuid, 16);
+	sb->sb_uuid = str->sb_uuid;
 }
 
 /**
#1 lore raw
Quoted 21 lines · On Wed, 14 Oct 2009 14:30:07 +0800 Huang Ying <[email protected]> wrote:

Replace u8[16] UUID definition in gfs2.

---
 fs/gfs2/incore.h            |    3 ++-
 fs/gfs2/ops_fstype.c        |    2 +-
 fs/gfs2/sys.c               |   14 ++++----------
 include/linux/gfs2_ondisk.h |    3 ++-
 4 files changed, 9 insertions(+), 13 deletions(-)
fs/gfs2/incore.h +1 -0
@@ -15,6 +15,7 @@
 #include <linux/slow-work.h>
 #include <linux/dlm.h>
 #include <linux/buffer_head.h>
+#include <linux/uuid.h>
 
 #define DIO_WAIT	0x00000010
 #define DIO_METADATA	0x00000020

fs/gfs2/incore.h struct gfs2_sb_host { · line 489

Quoted 7 lines
fs/gfs2/incore.h +1 -1
@@ -483,7 +484,7 @@ struct gfs2_sb_host {
 
 	char sb_lockproto[GFS2_LOCKNAME_LEN];
 	char sb_locktable[GFS2_LOCKNAME_LEN];
-	u8 sb_uuid[16];
+	uuid_be sb_uuid;
 };
 

Breaks `make headers_check':

include/linux/gfs2_ondisk.h:14: included file 'linux/uuid.h' is not exported

I don't think we want to export linux/uuid.h to userspace. But fs/gfs2/incore.h _is_ shared with userspace, and needs linux/uuid.h.

Don't know what to do, so I'll drop the patches.

author
#2 lore raw
Quoted 33 lines · Andrew Morton
Quoted 21 lines · On Wed, 14 Oct 2009 14:30:07 +0800 Huang Ying <[email protected]> wrote:

Replace u8[16] UUID definition in gfs2.

---
 fs/gfs2/incore.h            |    3 ++-
 fs/gfs2/ops_fstype.c        |    2 +-
 fs/gfs2/sys.c               |   14 ++++----------
 include/linux/gfs2_ondisk.h |    3 ++-
 4 files changed, 9 insertions(+), 13 deletions(-)
fs/gfs2/incore.h +1 -0
@@ -15,6 +15,7 @@
 #include <linux/slow-work.h>
 #include <linux/dlm.h>
 #include <linux/buffer_head.h>
+#include <linux/uuid.h>
 
 #define DIO_WAIT	0x00000010
 #define DIO_METADATA	0x00000020

fs/gfs2/incore.h struct gfs2_sb_host { · line 489

Quoted 7 lines
fs/gfs2/incore.h +1 -1
@@ -483,7 +484,7 @@ struct gfs2_sb_host {
 
 	char sb_lockproto[GFS2_LOCKNAME_LEN];
 	char sb_locktable[GFS2_LOCKNAME_LEN];
-	u8 sb_uuid[16];
+	uuid_be sb_uuid;
 };
 

Breaks `make headers_check':

Quoted 4 lines

include/linux/gfs2_ondisk.h:14: included file 'linux/uuid.h' is not exported

I don't think we want to export linux/uuid.h to userspace. But fs/gfs2/incore.h _is_ shared with userspace, and needs linux/uuid.h.

When writing uuid.h, I think it should be exported to userspace. Why should we not export it to user space?

Best Regards,
Huang Ying

#3 lore raw
Quoted 34 lines · On Mon, 02 Nov 2009 08:59:43 +0800 Huang Ying <[email protected]> wrote:
Quoted 33 lines · Andrew Morton
Quoted 21 lines · On Wed, 14 Oct 2009 14:30:07 +0800 Huang Ying <[email protected]> wrote:

Replace u8[16] UUID definition in gfs2.

---
 fs/gfs2/incore.h            |    3 ++-
 fs/gfs2/ops_fstype.c        |    2 +-
 fs/gfs2/sys.c               |   14 ++++----------
 include/linux/gfs2_ondisk.h |    3 ++-
 4 files changed, 9 insertions(+), 13 deletions(-)
fs/gfs2/incore.h +1 -0
@@ -15,6 +15,7 @@
 #include <linux/slow-work.h>
 #include <linux/dlm.h>
 #include <linux/buffer_head.h>
+#include <linux/uuid.h>
 
 #define DIO_WAIT	0x00000010
 #define DIO_METADATA	0x00000020

fs/gfs2/incore.h struct gfs2_sb_host { · line 489

Quoted 7 lines
fs/gfs2/incore.h +1 -1
@@ -483,7 +484,7 @@ struct gfs2_sb_host {
 
 	char sb_lockproto[GFS2_LOCKNAME_LEN];
 	char sb_locktable[GFS2_LOCKNAME_LEN];
-	u8 sb_uuid[16];
+	uuid_be sb_uuid;
 };
 

Breaks `make headers_check':

Quoted 7 lines
Quoted 4 lines

include/linux/gfs2_ondisk.h:14: included file 'linux/uuid.h' is not exported

I don't think we want to export linux/uuid.h to userspace. But fs/gfs2/incore.h _is_ shared with userspace, and needs linux/uuid.h.

When writing uuid.h, I think it should be exported to userspace. Why should we not export it to user space?

It contains a pile of stuff which is of no use to userspace - functions definitions, function declarations, macros, additional linux includes.

If we're going to do this then we need a separate header file which contains the userspace-needed things. And we'd need to check that it's desirable to use __u8 in userspace headers.

And we'll need to wake Steven up to actually take a look at the patches!

author
#4 lore raw
Quoted 45 lines · Andrew Morton
Quoted 34 lines · On Mon, 02 Nov 2009 08:59:43 +0800 Huang Ying <[email protected]> wrote:
Quoted 33 lines · Andrew Morton
Quoted 21 lines · On Wed, 14 Oct 2009 14:30:07 +0800 Huang Ying <[email protected]> wrote:

Replace u8[16] UUID definition in gfs2.

---
 fs/gfs2/incore.h            |    3 ++-
 fs/gfs2/ops_fstype.c        |    2 +-
 fs/gfs2/sys.c               |   14 ++++----------
 include/linux/gfs2_ondisk.h |    3 ++-
 4 files changed, 9 insertions(+), 13 deletions(-)
fs/gfs2/incore.h +1 -0
@@ -15,6 +15,7 @@
 #include <linux/slow-work.h>
 #include <linux/dlm.h>
 #include <linux/buffer_head.h>
+#include <linux/uuid.h>
 
 #define DIO_WAIT	0x00000010
 #define DIO_METADATA	0x00000020

fs/gfs2/incore.h struct gfs2_sb_host { · line 489

Quoted 7 lines
fs/gfs2/incore.h +1 -1
@@ -483,7 +484,7 @@ struct gfs2_sb_host {
 
 	char sb_lockproto[GFS2_LOCKNAME_LEN];
 	char sb_locktable[GFS2_LOCKNAME_LEN];
-	u8 sb_uuid[16];
+	uuid_be sb_uuid;
 };
 

Breaks `make headers_check':

Quoted 7 lines
Quoted 4 lines

include/linux/gfs2_ondisk.h:14: included file 'linux/uuid.h' is not exported

I don't think we want to export linux/uuid.h to userspace. But fs/gfs2/incore.h _is_ shared with userspace, and needs linux/uuid.h.

When writing uuid.h, I think it should be exported to userspace. Why should we not export it to user space?

Quoted 6 lines

It contains a pile of stuff which is of no use to userspace - functions definitions, function declarations, macros, additional linux includes.

If we're going to do this then we need a separate header file which contains the userspace-needed things. And we'd need to check that it's desirable to use __u8 in userspace headers.

For stuff of no use to user space, I think it can be enclosed into

#ifdef __KERNEL__
#endif

It seems that <linux/types.h> and <linux/string.h> are both safe to be included in a file exported to user space, because there is appropriate __KERNEL__ in these files.

In include/asm-generic/int-ll64.h, it is said __xx is intended to be used to be exported to user space.

Best Regards,
Huang Ying

#5 lore raw
Quoted 4 lines · On Tue, 03 Nov 2009 08:44:48 +0800 Huang Ying <[email protected]> wrote:

For stuff of no use to user space, I think it can be enclosed into

#ifdef __KERNEL__
#endif

It can, but that's ugly. Clearly separating the inclusions into uuid-kernel.h and uuid-user-h is nicer, no?

author
#6 lore raw
Quoted 10 lines · Andrew Morton
Quoted 4 lines · On Tue, 03 Nov 2009 08:44:48 +0800 Huang Ying <[email protected]> wrote:

For stuff of no use to user space, I think it can be enclosed into

#ifdef __KERNEL__
#endif

It can, but that's ugly. Clearly separating the inclusions into uuid-kernel.h and uuid-user-h is nicer, no?

But it seems that __KERNEL__ is common used method now. There are about 370 out of 3085 files under linux/include use __KERNEL__. The data are gotten via:

# cd linux/include
# find . -type f | wc -l
# grep __KERNEL__ -lr * | wc -l

Best Regards,
Huang Ying

#7 lore raw
Quoted 6 lines · Huang Ying
Quoted 5 lines · Andrew Morton
Quoted 2 lines · On Tue, 03 Nov 2009 08:44:48 +0800 Huang Ying <[email protected]> wrote:

For stuff of no use to user space, I think it can be enclosed into

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

#ifdef __KERNEL__
#endif

It can, but that's ugly. Clearly separating the inclusions into uuid-kernel.h and uuid-user-h is nicer, no?

But it seems that __KERNEL__ is common used method now. There are about 370 out of 3085 files under linux/include use __KERNEL__.

Just because we were sloopy in the past is no excuse for repeating this.

Sam