nfsd: enable V4ROOT exports
[safe/jmp/linux-2.6] / include / linux / gfs2_ondisk.h
index 213d664..b80c88d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
- * Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
+ * Copyright (C) 2004-2006 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
@@ -10,6 +10,8 @@
 #ifndef __GFS2_ONDISK_DOT_H__
 #define __GFS2_ONDISK_DOT_H__
 
+#include <linux/types.h>
+
 #define GFS2_MAGIC             0x01161970
 #define GFS2_BASIC_BLOCK       512
 #define GFS2_BASIC_BLOCK_SHIFT 9
 #define GFS2_FORMAT_LH         800
 #define GFS2_FORMAT_LD         900
 #define GFS2_FORMAT_LB         1000
-#define GFS2_FORMAT_EA         1100
-#define GFS2_FORMAT_ED         1200
-#define GFS2_FORMAT_UT         1300
+#define GFS2_FORMAT_EA         1600
+#define GFS2_FORMAT_ED         1700
 #define GFS2_FORMAT_QC         1400
 /* These are format numbers for entities contained in files */
-#define GFS2_FORMAT_RI         1500
-#define GFS2_FORMAT_DE         1600
-#define GFS2_FORMAT_QU         1700
+#define GFS2_FORMAT_RI         1100
+#define GFS2_FORMAT_DE         1200
+#define GFS2_FORMAT_QU         1500
 /* These are part of the superblock */
 #define GFS2_FORMAT_FS         1801
 #define GFS2_FORMAT_MULTI      1900
  * An on-disk inode number
  */
 
-#define gfs2_inum_equal(ino1, ino2) \
-       (((ino1)->no_formal_ino == (ino2)->no_formal_ino) && \
-       ((ino1)->no_addr == (ino2)->no_addr))
-
 struct gfs2_inum {
        __be64 no_formal_ino;
        __be64 no_addr;
@@ -74,10 +71,9 @@ struct gfs2_inum {
 #define GFS2_METATYPE_JD       7
 #define GFS2_METATYPE_LH       8
 #define GFS2_METATYPE_LD       9
-#define GFS2_METATYPE_LB       10
-#define GFS2_METATYPE_EA       11
-#define GFS2_METATYPE_ED       12
-#define GFS2_METATYPE_UT       13
+#define GFS2_METATYPE_LB       12
+#define GFS2_METATYPE_EA       10
+#define GFS2_METATYPE_ED       11
 #define GFS2_METATYPE_QC       14
 
 struct gfs2_meta_header {
@@ -124,7 +120,11 @@ struct gfs2_sb {
 
        char sb_lockproto[GFS2_LOCKNAME_LEN];
        char sb_locktable[GFS2_LOCKNAME_LEN];
-       /* In gfs1, quota and license dinodes followed */
+
+       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 */
 };
 
 /*
@@ -155,7 +155,7 @@ struct gfs2_rindex {
 
 #define GFS2_BLKST_FREE                0
 #define GFS2_BLKST_USED                1
-#define GFS2_BLKST_INVALID     2
+#define GFS2_BLKST_UNLINKED    2
 #define GFS2_BLKST_DINODE      3
 
 #define GFS2_RGF_JOURNAL       0x00000001
@@ -169,11 +169,40 @@ struct gfs2_rgrp {
        __be32 rg_flags;
        __be32 rg_free;
        __be32 rg_dinodes;
+       __be32 __pad;
+       __be64 rg_igeneration;
 
-       __u8 rg_reserved[92]; /* Several fields from gfs1 now reserved */
+       __u8 rg_reserved[80]; /* Several fields from gfs1 now reserved */
 };
 
 /*
+ * quota linked list: user quotas and group quotas form two separate 
+ * singly linked lists. ll_next stores uids or gids of next quotas in the 
+ * linked list.
+
+Given the uid/gid, how to calculate the quota file offsets for the corresponding
+gfs2_quota structures on disk:
+
+for user quotas, given uid,
+offset = uid * sizeof(struct gfs2_quota);
+
+for group quotas, given gid,
+offset = (gid * sizeof(struct gfs2_quota)) + sizeof(struct gfs2_quota);
+
+
+  uid:0   gid:0       uid:12   gid:12      uid:17   gid:17     uid:5142 gid:5142
++-------+-------+    +-------+-------+    +-------+- - - -+    +- - - -+-------+
+| valid | valid | :: | valid | valid | :: | valid | inval | :: | inval | valid |
++-------+-------+    +-------+-------+    +-------+- - - -+    +- - - -+-------+
+next:12   next:12    next:17 next:5142    next:NULL                    next:NULL
+    |       |            |       |            |<-- user quota list         |
+     \______|___________/ \______|___________/         group quota list -->|
+            |                    |                                         |
+             \__________________/ \_______________________________________/
+
+*/
+
+/*
  * quota structure
  */
 
@@ -181,6 +210,8 @@ struct gfs2_quota {
        __be64 qu_limit;
        __be64 qu_warn;
        __be64 qu_value;
+       __be32 qu_ll_next; /* location of next quota in list */
+       __u8 qu_reserved[60];
 };
 
 /*
@@ -193,6 +224,22 @@ struct gfs2_quota {
 #define DT2IF(dt) (((dt) << 12) & S_IFMT)
 #define IF2DT(sif) (((sif) & S_IFMT) >> 12)
 
+enum {
+       gfs2fl_Jdata            = 0,
+       gfs2fl_ExHash           = 1,
+       gfs2fl_Unused           = 2,
+       gfs2fl_EaIndirect       = 3,
+       gfs2fl_Directio         = 4,
+       gfs2fl_Immutable        = 5,
+       gfs2fl_AppendOnly       = 6,
+       gfs2fl_NoAtime          = 7,
+       gfs2fl_Sync             = 8,
+       gfs2fl_System           = 9,
+       gfs2fl_TruncInProg      = 29,
+       gfs2fl_InheritDirectio  = 30,
+       gfs2fl_InheritJdata     = 31,
+};
+
 /* Dinode flags */
 #define GFS2_DIF_JDATA                 0x00000001
 #define GFS2_DIF_EXHASH                        0x00000002
@@ -230,7 +277,7 @@ struct gfs2_dinode {
         */
        __be64 di_goal_meta;    /* rgrp to alloc from next */
        __be64 di_goal_data;    /* data block goal */
-       __u32 __pad[2];
+       __be64 di_generation;   /* generation number for NFS */
 
        __be32 di_flags;        /* GFS2_DIF_... */
        __be32 di_payload_format;  /* GFS2_FORMAT_... */
@@ -246,8 +293,11 @@ struct gfs2_dinode {
        struct gfs2_inum __pad4; /* Unused even in current gfs1 */
 
        __be64 di_eattr;        /* extended attribute block number */
+       __be32 di_atime_nsec;   /* nsec portion of atime */
+       __be32 di_mtime_nsec;   /* nsec portion of mtime */
+       __be32 di_ctime_nsec;   /* nsec portion of ctime */
 
-       __u8 di_reserved[56];
+       __u8 di_reserved[44];
 };
 
 /*
@@ -260,11 +310,10 @@ struct gfs2_dinode {
 struct gfs2_dirent {
        struct gfs2_inum de_inum;
        __be32 de_hash;
-       __be32 de_rec_len;
-       __u8 de_name_len;
-       __u8 de_type;
-       __u16 __pad1;
-       __u32 __pad2;
+       __be16 de_rec_len;
+       __be16 de_name_len;
+       __be16 de_type;
+       __u8 __pad[14];
 };
 
 /*
@@ -279,11 +328,33 @@ struct gfs2_leaf {
        __be32 lf_dirent_format;        /* Format of the dirents */
        __be64 lf_next;                 /* Next leaf, if overflow */
 
-       __u8 lf_reserved[32];
+       __u8 lf_reserved[64];
 };
 
 /*
  * Extended attribute header format
+ *
+ * This works in a similar way to dirents. There is a fixed size header
+ * followed by a variable length section made up of the name and the
+ * associated data. In the case of a "stuffed" entry, the value is
+ * inline directly after the name, the ea_num_ptrs entry will be
+ * zero in that case. For non-"stuffed" entries, there will be
+ * a set of pointers (aligned to 8 byte boundary) to the block(s)
+ * containing the value.
+ *
+ * The blocks containing the values and the blocks containing the
+ * extended attribute headers themselves all start with the common
+ * metadata header. Each inode, if it has extended attributes, will
+ * have either a single block containing the extended attribute headers
+ * or a single indirect block pointing to blocks containing the
+ * extended attribure headers.
+ *
+ * The maximim size of the data part of an extended attribute is 64k
+ * so the number of blocks required depends upon block size. Since the
+ * block size also determines the number of pointers in an indirect
+ * block, its a fairly complicated calculation to work out the maximum
+ * number of blocks that an inode may have relating to extended attributes.
+ *
  */
 
 #define GFS2_EA_MAX_NAME_LEN   255
@@ -292,8 +363,9 @@ struct gfs2_leaf {
 #define GFS2_EATYPE_UNUSED     0
 #define GFS2_EATYPE_USR                1
 #define GFS2_EATYPE_SYS                2
+#define GFS2_EATYPE_SECURITY   3
 
-#define GFS2_EATYPE_LAST       2
+#define GFS2_EATYPE_LAST       3
 #define GFS2_EATYPE_VALID(x)   ((x) <= GFS2_EATYPE_LAST)
 
 #define GFS2_EAFLAG_LAST       0x01    /* last ea in block */
@@ -336,6 +408,10 @@ struct gfs2_log_header {
 /* ld_data1 is the number of revoke blocks in the descriptor.
    ld_data2 is unused. */
 
+#define GFS2_LOG_DESC_JDATA    302
+/* ld_data1 is the number of data blocks in the descriptor.
+   ld_data2 is unused. */
+
 struct gfs2_log_descriptor {
        struct gfs2_meta_header ld_header;
 
@@ -373,20 +449,6 @@ struct gfs2_statfs_change {
 };
 
 /*
- * Unlinked Tag
- * Describes an allocated inode that isn't linked into
- * the directory tree and might need to be deallocated.
- */
-
-#define GFS2_UTF_UNINIT                0x00000001
-
-struct gfs2_unlinked_tag {
-       struct gfs2_inum ut_inum;
-       __be32 ut_flags;        /* GFS2_UTF_... */
-       __u32 __pad;
-};
-
-/*
  * Quota change
  * Describes an allocation change for a particular
  * user or group.
@@ -400,55 +462,12 @@ struct gfs2_quota_change {
        __be32 qc_id;
 };
 
-/* Translation functions */
-
-extern void gfs2_inum_in(struct gfs2_inum *no, char *buf);
-extern void gfs2_inum_out(struct gfs2_inum *no, char *buf);
-extern void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf);
-extern void gfs2_meta_header_out(struct gfs2_meta_header *mh, char *buf);
-extern void gfs2_sb_in(struct gfs2_sb *sb, char *buf);
-extern void gfs2_sb_out(struct gfs2_sb *sb, char *buf);
-extern void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf);
-extern void gfs2_rindex_out(struct gfs2_rindex *ri, char *buf);
-extern void gfs2_rgrp_in(struct gfs2_rgrp *rg, char *buf);
-extern void gfs2_rgrp_out(struct gfs2_rgrp *rg, char *buf);
-extern void gfs2_quota_in(struct gfs2_quota *qu, char *buf);
-extern void gfs2_quota_out(struct gfs2_quota *qu, char *buf);
-extern void gfs2_dinode_in(struct gfs2_dinode *di, char *buf);
-extern void gfs2_dinode_out(struct gfs2_dinode *di, char *buf);
-extern void gfs2_dirent_in(struct gfs2_dirent *de, char *buf);
-extern void gfs2_dirent_out(struct gfs2_dirent *de, char *buf);
-extern void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf);
-extern void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf);
-extern void gfs2_ea_header_in(struct gfs2_ea_header *ea, char *buf);
-extern void gfs2_ea_header_out(struct gfs2_ea_header *ea, char *buf);
-extern void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf);
-extern void gfs2_inum_range_in(struct gfs2_inum_range *ir, char *buf);
-extern void gfs2_inum_range_out(struct gfs2_inum_range *ir, char *buf);
-extern void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, char *buf);
-extern void gfs2_statfs_change_out(struct gfs2_statfs_change *sc, char *buf);
-extern void gfs2_unlinked_tag_in(struct gfs2_unlinked_tag *ut, char *buf);
-extern void gfs2_unlinked_tag_out(struct gfs2_unlinked_tag *ut, char *buf);
-extern void gfs2_quota_change_in(struct gfs2_quota_change *qc, char *buf);
-extern void gfs2_quota_change_out(struct gfs2_quota_change *qc, char *buf);
-
-/* Printing functions */
-
-extern void gfs2_inum_print(struct gfs2_inum *no);
-extern void gfs2_meta_header_print(struct gfs2_meta_header *mh);
-extern void gfs2_sb_print(struct gfs2_sb *sb);
-extern void gfs2_rindex_print(struct gfs2_rindex *ri);
-extern void gfs2_rgrp_print(struct gfs2_rgrp *rg);
-extern void gfs2_quota_print(struct gfs2_quota *qu);
-extern void gfs2_dinode_print(struct gfs2_dinode *di);
-extern void gfs2_dirent_print(struct gfs2_dirent *de, char *name);
-extern void gfs2_leaf_print(struct gfs2_leaf *lf);
-extern void gfs2_ea_header_print(struct gfs2_ea_header *ea, char *name);
-extern void gfs2_log_header_print(struct gfs2_log_header *lh);
-extern void gfs2_log_descriptor_print(struct gfs2_log_descriptor *ld);
-extern void gfs2_inum_range_print(struct gfs2_inum_range *ir);
-extern void gfs2_statfs_change_print(struct gfs2_statfs_change *sc);
-extern void gfs2_unlinked_tag_print(struct gfs2_unlinked_tag *ut);
-extern void gfs2_quota_change_print(struct gfs2_quota_change *qc);
+struct gfs2_quota_lvb {
+        __be32 qb_magic;
+        __u32 __pad;
+        __be64 qb_limit;      /* Hard limit of # blocks to alloc */
+        __be64 qb_warn;       /* Warn user when alloc is above this # */
+        __be64 qb_value;       /* Current # blocks allocated */
+};
 
 #endif /* __GFS2_ONDISK_DOT_H__ */