[Ocfs2-tools-commits] mfasheh commits r256 - in
branches/dlm-changes: libocfs2/include mkfs.ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Sep 24 18:55:38 CDT 2004
Author: mfasheh
Date: 2004-09-24 18:55:36 -0500 (Fri, 24 Sep 2004)
New Revision: 256
Modified:
branches/dlm-changes/libocfs2/include/ocfs2_fs.h
branches/dlm-changes/mkfs.ocfs2/mkfs.c
Log:
* mkfs changes for the new disk format
Modified: branches/dlm-changes/libocfs2/include/ocfs2_fs.h
===================================================================
--- branches/dlm-changes/libocfs2/include/ocfs2_fs.h 2004-09-24 23:46:14 UTC (rev 255)
+++ branches/dlm-changes/libocfs2/include/ocfs2_fs.h 2004-09-24 23:55:36 UTC (rev 256)
@@ -56,6 +56,7 @@
#define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
#define OCFS2_INODE_SIGNATURE "INODE01"
#define OCFS2_EXTENT_BLOCK_SIGNATURE "EXBLK01"
+#define OCFS2_GROUP_DESC_SIGNATURE "GROUP01"
/* Compatibility flags */
#define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \
@@ -96,7 +97,7 @@
#define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */
#define OCFS2_JOURNAL_FL (0x00000100) /* Node journal */
#define OCFS2_DLM_FL (0x00000200) /* DLM area */
-
+#define OCFS2_SUBALLOC_FL (0x00000400) /* Suballocator File */
/* Limit of space in ocfs2_dir_entry */
#define OCFS2_MAX_FILENAME_LENGTH 255
@@ -225,6 +226,12 @@
/*10*/
} ocfs2_extent_rec;
+typedef struct _ocfs2_chain_rec {
+ __u32 c_free; /* number of free bits in this chain. */
+ __u32 c_total;
+ __u64 c_blkno; /* Physical disk offset (blocks) of 1st group */
+} ocfs2_chain_rec;
+
/*
* On disk extent list for OCFS2 (node in the tree). Note that this
* is contained inside ocfs2_dinode or ocfs2_extent_block, so the
@@ -244,17 +251,26 @@
/*10*/ ocfs2_extent_rec l_recs[0]; /* Extent records */
} ocfs2_extent_list;
+typedef struct _ocfs2_chain_list {
+ __u16 cl_cpg; /* Clusters per Block Group */
+ __u16 cl_bpc; /* Bits per cluster */
+ __u16 cl_count;
+ __u16 cl_next_free_rec;
+ __u64 cl_reserved1;
+ ocfs2_chain_rec cl_recs[0];
+} ocfs2_chain_list;
+
/*
* On disk extent block (indirect block) for OCFS2
*/
typedef struct _ocfs2_extent_block
{
/*00*/ __u8 h_signature[8]; /* Signature for verification */
- __u64 h_suballoc_blkno; /* Node suballocator offset,
- in blocks */
+ __u64 h_reserved1;
/*10*/ __s16 h_suballoc_node; /* Node suballocator this
extent_header belongs to */
- __u16 h_reserved1;
+ __u16 h_suballoc_bit; /* Bit offset in suballocater
+ block group */
__u32 h_reserved2;
__u64 h_blkno; /* Offset on disk, in blocks */
/*20*/ __u64 h_parent_blk; /* Offset on disk, in blocks,
@@ -276,9 +292,8 @@
__u16 dl_reserved1;
__u8 dl_level; /* Lock level */
__u8 dl_reserved2[3]; /* Pad to u64 */
- __u64 dl_seq_num; /* Lock transaction seqnum */
-/*10*/ __u32 dl_node_map[8]; /* Bitmap of interested nodes,
- was __u32 */
+ __u64 dl_reserved3; /* was dl_seq_num */
+/*10*/ __u32 dl_reserved4[8]; /* was dl_node_map */
/*30*/
} ocfs2_disk_lock;
@@ -339,11 +354,11 @@
typedef struct _ocfs2_dinode {
/*00*/ __u8 i_signature[8]; /* Signature for validation */
__u32 i_generation; /* Generation number */
- __u16 i_reserved1;
__s16 i_suballoc_node; /* Node suballocater this inode
belongs to */
-/*10*/ __u64 i_suballoc_blkno; /* Node suballocator offset,
- in blocks */
+ __u16 i_suballoc_bit; /* Bit offset in suballocater
+ block group */
+/*10*/ __u64 i_reserved1;
/*18*/ ocfs2_disk_lock i_disk_lock; /* Lock structure */
/*48*/ __u32 i_uid; /* Owner UID */
__u32 i_gid; /* Owning GID */
@@ -377,7 +392,8 @@
} id1; /* Inode type dependant 1 */
/*C0*/ union {
ocfs2_super_block i_super;
- ocfs2_local_alloc i_lab;
+ ocfs2_local_alloc i_lab;
+ ocfs2_chain_list i_chain;
ocfs2_extent_list i_list;
} id2;
/* Actual on-disk size is one block */
@@ -395,8 +411,24 @@
/* Actual on-disk length specified by rec_len */
};
+/*
+ * On disk allocator group structure for OCFS2
+ */
+typedef struct _ocfs2_group_desc
+{
+/*00*/ __u8 bg_signature[8]; /* Signature for validation */
+ __u16 bg_size; /* Size of included bitmap in bytes. */
+ __u16 bg_bits; /* Bits represented by this group. */
+ __u16 bg_free_bits_count; /* Free bits count */
+ __u16 bg_chain; /* What chain I am in. */
+ __u32 bg_generation;
+ __u64 bg_next_group; /* Next group in my list, in blocks */
+ __u64 bg_parent_dinode; /* dinode which owns me, in blocks */
+ __u64 bg_blkno; /* Offset on disk, in blocks */
+ __u64 bg_reserved2[2];
+ __u8 bg_bitmap[0];
+} ocfs2_group_desc;
-
#ifdef __KERNEL__
static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
{
@@ -408,6 +440,16 @@
return size / sizeof(struct _ocfs2_extent_rec);
}
+static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
+{
+ int size;
+
+ size = sb->s_blocksize -
+ offsetof(struct _ocfs2_dinode, id2.i_chain.cl_recs);
+
+ return size / sizeof(struct _ocfs2_chain_rec);
+}
+
static inline int ocfs2_extent_recs_per_eb(struct super_block *sb)
{
int size;
@@ -427,6 +469,16 @@
return size;
}
+
+static inline int ocfs2_group_bitmap_size(struct super_block *sb)
+{
+ int size;
+
+ size = sb->s_blocksize -
+ offsetof(struct _ocfs2_group_desc, bg_bitmap);
+
+ return size;
+}
#else
static inline int ocfs2_extent_recs_per_inode(int blocksize)
{
@@ -438,6 +490,16 @@
return size / sizeof(struct _ocfs2_extent_rec);
}
+static inline int ocfs2_chain_recs_per_inode(int blocksize)
+{
+ int size;
+
+ size = blocksize -
+ offsetof(struct _ocfs2_dinode, id2.i_chain.cl_recs);
+
+ return size / sizeof(struct _ocfs2_chain_rec);
+}
+
static inline int ocfs2_extent_recs_per_eb(int blocksize)
{
int size;
@@ -457,6 +519,16 @@
return size;
}
+
+static inline int ocfs2_group_bitmap_size(int blocksize)
+{
+ int size;
+
+ size = blocksize -
+ offsetof(struct _ocfs2_group_desc, bg_bitmap);
+
+ return size;
+}
#endif /* __KERNEL__ */
Modified: branches/dlm-changes/mkfs.ocfs2/mkfs.c
===================================================================
--- branches/dlm-changes/mkfs.ocfs2/mkfs.c 2004-09-24 23:46:14 UTC (rev 255)
+++ branches/dlm-changes/mkfs.ocfs2/mkfs.c 2004-09-24 23:55:36 UTC (rev 256)
@@ -108,6 +108,7 @@
SFI_BITMAP,
SFI_LOCAL_ALLOC,
SFI_DLM,
+ SFI_SUBALLOC,
SFI_OTHER
};
@@ -202,6 +203,7 @@
char *vol_label;
char *device_name;
char *uuid;
+ uint32_t vol_generation;
int fd;
@@ -250,6 +252,7 @@
static void close_device(State *s);
static int initial_nodes_for_volume(uint64_t size);
static void generate_uuid(State *s);
+static void create_generation(State *s);
static void write_autoconfig_header(State *s, SystemFileDiskRecord *rec);
static void init_record(State *s, SystemFileDiskRecord *rec, int type, int dir);
static void print_state(State *s);
@@ -266,9 +269,9 @@
{ "global_bitmap", SFI_BITMAP, 1, 0 },
{ "orphan_dir", SFI_OTHER, 1, 1 },
{ "extent_alloc:%04d", SFI_OTHER, 0, 0 },
- { "extent_alloc_bitmap:%04d", SFI_BITMAP, 0, 0 },
+ { "extent_alloc_bitmap:%04d", SFI_SUBALLOC, 0, 0 },
{ "inode_alloc:%04d", SFI_OTHER, 0, 0 },
- { "inode_alloc_bitmap:%04d", SFI_BITMAP, 0, 0 },
+ { "inode_alloc_bitmap:%04d", SFI_SUBALLOC, 0, 0 },
{ "journal:%04d", SFI_JOURNAL, 0, 0 },
{ "local_alloc:%04d", SFI_LOCAL_ALLOC, 0, 0 }
};
@@ -305,6 +308,8 @@
generate_uuid (s);
+ create_generation(s);
+
print_state (s);
init_record(s, &global_alloc_rec, SFI_OTHER, 0);
@@ -1145,7 +1150,6 @@
strcpy(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE);
di->i_suballoc_node = cpu_to_le16((__u16)-1);
- di->i_suballoc_blkno = cpu_to_le64(super_off >> s->blocksize_bits);
di->i_atime = 0;
di->i_ctime = cpu_to_le64(s->format_time);
@@ -1175,6 +1179,28 @@
free(di);
}
+static inline int
+ocfs2_clusters_per_group(int block_size, int cluster_size_bits)
+{
+ int bytes;
+
+ switch (block_size) {
+ case (4096):
+ case (2048):
+ bytes = 4 * ONE_MEGA_BYTE;
+ break;
+ case (1024):
+ bytes = 2 * ONE_MEGA_BYTE;
+ break;
+ case (512):
+ default:
+ bytes = ONE_MEGA_BYTE;
+ break;
+ }
+
+ return(bytes >> cluster_size_bits);
+}
+
static void
format_file(State *s, SystemFileDiskRecord *rec)
{
@@ -1190,9 +1216,8 @@
memset(di, 0, s->blocksize);
strcpy(di->i_signature, OCFS2_INODE_SIGNATURE);
- di->i_generation = 0;
+ di->i_generation = cpu_to_le32(s->vol_generation);
di->i_suballoc_node = cpu_to_le16(-1);
- di->i_suballoc_blkno = cpu_to_le64(rec->fe_off >> s->blocksize_bits);
di->i_blkno = cpu_to_le64(rec->fe_off >> s->blocksize_bits);
di->i_uid = 0;
di->i_gid = 0;
@@ -1215,6 +1240,17 @@
di->id1.bitmap1.i_total = cpu_to_le32(rec->bi.total_bits);
}
+ if (rec->flags & OCFS2_SUBALLOC_FL) {
+ di->id2.i_chain.cl_count =
+ cpu_to_le16(ocfs2_chain_recs_per_inode(s->blocksize));
+ di->id2.i_chain.cl_cpg =
+ cpu_to_le16(ocfs2_clusters_per_group(s->blocksize,
+ s->cluster_size_bits));
+ di->id2.i_chain.cl_bpc =
+ cpu_to_le16(s->cluster_size / s->blocksize);
+ di->id2.i_chain.cl_next_free_rec = 0;
+ goto write_out;
+ }
di->id2.i_list.l_count =
cpu_to_le16(ocfs2_extent_recs_per_inode(s->blocksize));
di->id2.i_list.l_next_free_rec = 0;
@@ -1385,6 +1421,27 @@
close(randfd);
}
+static void create_generation(State *s)
+{
+ int randfd = 0;
+ int readlen = sizeof(s->vol_generation);
+
+ if ((randfd = open("/dev/urandom", O_RDONLY)) == -1) {
+ com_err(s->progname, 0,
+ "Error opening /dev/urandom: %s", strerror(errno));
+ exit(1);
+ }
+
+ if (read(randfd, &s->vol_generation, readlen) != readlen) {
+ com_err(s->progname, 0,
+ "Error reading from /dev/urandom: %s",
+ strerror(errno));
+ exit(1);
+ }
+
+ close(randfd);
+}
+
static void
write_autoconfig_header(State *s, SystemFileDiskRecord *rec)
{
@@ -1429,6 +1486,9 @@
case SFI_DLM:
rec->flags |= OCFS2_DLM_FL;
break;
+ case SFI_SUBALLOC:
+ rec->flags |= (OCFS2_BITMAP_FL|OCFS2_SUBALLOC_FL);
+ break;
case SFI_OTHER:
break;
}
More information about the Ocfs2-tools-commits
mailing list