Skip to contentSkip to conversation

GFS: headers

PATCH In review David Teigland 4 participants 5 messages Sep 1, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/14 GFS: headers

Central header files that are widely used.

---

 fs/gfs2/gfs2.h              |   77 +++
 fs/gfs2/incore.h            |  691 +++++++++++++++++++++++++++
 include/linux/gfs2_ioctl.h  |   30 +
 include/linux/gfs2_ondisk.h | 1119 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1917 insertions(+)
fs/gfs2/gfs2.h +77 -0
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
+ * Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
+#ifndef __GFS2_DOT_H__
+#define __GFS2_DOT_H__
+
+#include <linux/gfs2_ondisk.h>
+
+#include "locking/harness/lm_interface.h"
+#include "lvb.h"
+#include "incore.h"
+#include "util.h"
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#define NO_CREATE 0
+#define CREATE 1
+
+#define NO_WAIT 0
+#define WAIT 1
+
+#define NO_FORCE 0
+#define FORCE 1
+
+#if (BITS_PER_LONG == 64)
+#define PRIu64 "lu"
+#define PRId64 "ld"
+#define PRIx64 "lx"
+#define PRIX64 "lX"
+#else
+#define PRIu64 "Lu"
+#define PRId64 "Ld"
+#define PRIx64 "Lx"
+#define PRIX64 "LX"
+#endif
+
+/*  Divide num by den.  Round up if there is a remainder.  */
+#define DIV_RU(num, den) (((num) + (den) - 1) / (den))
+#define MAKE_MULT8(x) (((x) + 7) & ~7)
+
+#define GFS2_FAST_NAME_SIZE 8
+
+#define get_v2sdp(sb) ((struct gfs2_sbd *)(sb)->s_fs_info)
+#define set_v2sdp(sb, sdp) (sb)->s_fs_info = (sdp)
+#define get_v2ip(inode) ((struct gfs2_inode *)(inode)->u.generic_ip)
+#define set_v2ip(inode, ip) (inode)->u.generic_ip = (ip)
+#define get_v2fp(file) ((struct gfs2_file *)(file)->private_data)
+#define set_v2fp(file, fp) (file)->private_data = (fp)
+#define get_v2bd(bh) ((struct gfs2_bufdata *)(bh)->b_private)
+#define set_v2bd(bh, bd) (bh)->b_private = (bd)
+#define get_v2db(bh) ((struct gfs2_databuf *)(bh)->b_private)
+#define set_v2db(bh, db) (bh)->b_private = (db)
+
+#define get_transaction ((struct gfs2_trans *)(current->journal_info))
+#define set_transaction(tr) (current->journal_info) = (tr)
+
+#define get_gl2ip(gl) ((struct gfs2_inode *)(gl)->gl_object)
+#define set_gl2ip(gl, ip) (gl)->gl_object = (ip)
+#define get_gl2rgd(gl) ((struct gfs2_rgrpd *)(gl)->gl_object)
+#define set_gl2rgd(gl, rgd) (gl)->gl_object = (rgd)
+#define get_gl2gl(gl) ((struct gfs2_glock *)(gl)->gl_object)
+#define set_gl2gl(gl, gl2) (gl)->gl_object = (gl2)
+
+#endif /* __GFS2_DOT_H__ */
+
fs/gfs2/incore.h +691 -0

691 lines not on this page · raw message

include/linux/gfs2_ioctl.h +30 -0
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
+ * Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
+#ifndef __GFS2_IOCTL_DOT_H__
+#define __GFS2_IOCTL_DOT_H__
+
+#define _GFS2C_(x)               (('G' << 16) | ('2' << 8) | (x))
+
+/* Ioctls implemented */
+
+#define GFS2_IOCTL_IDENTIFY      _GFS2C_(1)
+#define GFS2_IOCTL_SUPER         _GFS2C_(2)
+
+struct gfs2_ioctl {
+	unsigned int gi_argc;
+	char **gi_argv;
+
+        char __user *gi_data;
+	unsigned int gi_size;
+	uint64_t gi_offset;
+};
+
+#endif /* ___GFS2_IOCTL_DOT_H__ */
+
include/linux/gfs2_ondisk.h +1119 -0

1,119 lines not on this page · raw message

#1 lore raw

fs/gfs2/gfs2.h line 26

Quoted 8 lines
fs/gfs2/gfs2.h +7 -0
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif

eh why can't you just use the regular kernel conventions

fs/gfs2/gfs2.h line 35

Quoted 9 lines
fs/gfs2/gfs2.h +9 -0
+
+#define NO_CREATE 0
+#define CREATE 1
+
+#define NO_WAIT 0
+#define WAIT 1
+
+#define NO_FORCE 0
+#define FORCE 1

these deserve enums

Quoted 4 lines
fs/gfs2/incore.h +4 -0
+
+/* Actions */
+#define HIF_MUTEX		0
+#define HIF_PROMOTE		1

fs/gfs2/incore.h line 151

Quoted 10 lines
fs/gfs2/incore.h +10 -0
+#define HIF_DEMOTE		2
+#define HIF_GREEDY		3
+
+/* States */
+#define HIF_ALLOCED		4
+#define HIF_DEALLOC		5
+#define HIF_HOLDER		6
+#define HIF_FIRST		7
+#define HIF_RECURSE		8
+#define HIF_ABORTED		9

enum?

include/linux/gfs2_ioctl.h line 18

Quoted 6 lines
include/linux/gfs2_ioctl.h +6 -0
+#define _GFS2C_(x)               (('G' << 16) | ('2' << 8) | (x))
+
+/* Ioctls implemented */
+
+#define GFS2_IOCTL_IDENTIFY      _GFS2C_(1)
+#define GFS2_IOCTL_SUPER         _GFS2C_(2)

have you registered these in ioctl.txt?

include/linux/gfs2_ioctl.h line 27

Quoted 9 lines
include/linux/gfs2_ioctl.h +9 -0
+
+struct gfs2_ioctl {
+	unsigned int gi_argc;
+	char **gi_argv;
+
+        char __user *gi_data;
+	unsigned int gi_size;
+	uint64_t gi_offset;
+};

what is this for??

Quoted 1 line

+/* Endian functions */

ehhhh again why??
Why is this a compiletime hack?
Either you care about either-endian on disk, at which point it has to be a runtime thing, or you make the on disk layout fixed endian, at which point you really shouldn't abstract be16_to_cpu etc any further!

#2 lore raw
Quoted 7 lines · Arjan van de Ven
Quoted 1 line

+/* Endian functions */

ehhhh again why??
Why is this a compiletime hack?
Either you care about either-endian on disk, at which point it has to be a runtime thing, or you make the on disk layout fixed endian, at which point you really shouldn't abstract be16_to_cpu etc any further!

Well... I would disagree with the very end of it (e.g. having on-disk block number representation declared as __bitwise, so that it wouldn't be mixed with __be<n> + having coversion helpers consisting of static inline u32 foo_to_cpu(foo n)

{
	return be32_to_cpu((__force __be32)n);
}

etc. may be valid technics, assuming that these objects were passed around enough to deserve it.

Blanket "let's rename for the sake of renaming" is a BS, of course...

#3 lore raw
In reply to Arjan van de Ven
Quoted 7 lines · Arjan van de Ven
Quoted 1 line

+/* Endian functions */

ehhhh again why??
Why is this a compiletime hack?
Either you care about either-endian on disk, at which point it has to be a runtime thing, or you make the on disk layout fixed endian, at which point you really shouldn't abstract be16_to_cpu etc any further!

Again, on-disk is fixed little endian, so we have for example:

#define gfs2_32_to_cpu le32_to_cpu
#define cpu_to_gfs2_32 cpu_to_le32

To _test_ and _verify_ the endian-handling of the code we can #define GFS2_ENDIAN_BIG which switches the above to:

#define gfs2_32_to_cpu to be32_to_cpu
#define cpu_to_gfs2_32 to cpu_to_be32

We offered to removed this when I explained it before. It sounds like it would give you some comfort so I'll just go ahead and do it barring any pleas otherwise.

Dave

#4 lore raw
Quoted 4 lines · David Teigland

We offered to removed this when I explained it before. It sounds like it would give you some comfort so I'll just go ahead and do it barring any pleas otherwise.

Please do. Just have one test machine with an endianness different from the on-disk format.

Having the on-disk format always be big-endian would serve this purpose quite well, btw. But buying an (before-intel) apple machine also would.

Jörn

Signature · 4 lines
More computing sins are committed in the name of efficiency (without
necessarily achieving it) than for any other single reason - including
blind stupidity.
-- W. A. Wulf