[Ocfs2-tools-commits] smushran commits r426 - in trunk: debugfs.ocfs2 extras libocfs2 libocfs2/include tunefs.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Nov 19 15:32:53 CST 2004


Author: smushran
Date: 2004-11-19 15:32:51 -0600 (Fri, 19 Nov 2004)
New Revision: 426

Modified:
   trunk/debugfs.ocfs2/readfs.c
   trunk/extras/set_random_bits.c
   trunk/libocfs2/alloc.c
   trunk/libocfs2/checkhb.c
   trunk/libocfs2/include/ocfs2.h
   trunk/libocfs2/include/ocfs2_fs.h
   trunk/tunefs.ocfs2/tunefs.c
Log:
tune now creates inodes for system files when adding nodes

Modified: trunk/debugfs.ocfs2/readfs.c
===================================================================
--- trunk/debugfs.ocfs2/readfs.c	2004-11-19 19:50:52 UTC (rev 425)
+++ trunk/debugfs.ocfs2/readfs.c	2004-11-19 21:32:51 UTC (rev 426)
@@ -264,8 +264,8 @@
 	ocfs2_dinode *inode;
 	struct ocfs2_dir_entry *rec;
 	GArray *dirarr = NULL;
-	char *dlm = ocfs2_system_inode_names[DLM_SYSTEM_INODE];
-	char *gblbm = ocfs2_system_inode_names[GLOBAL_BITMAP_SYSTEM_INODE];
+	char *dlm = sysfile_info[DLM_SYSTEM_INODE].name;
+	char *gblbm = sysfile_info[GLOBAL_BITMAP_SYSTEM_INODE].name;
 	unsigned int i, j;
 	char *journal[256];
 	ocfs2_super_block *sb = &((gbls.superblk)->id2.i_super);
@@ -285,7 +285,7 @@
 	/* generate journal sysfile names */
 	for (i = 0; i < sb->s_max_nodes; ++i) {
 		snprintf (tmpstr, sizeof(tmpstr),
-			  ocfs2_system_inode_names[JOURNAL_SYSTEM_INODE], i);
+			  sysfile_info[JOURNAL_SYSTEM_INODE].name, i);
 		journal[i] = strdup (tmpstr);
 		gbls.journal_blkno[i] = 0;
 	}

Modified: trunk/extras/set_random_bits.c
===================================================================
--- trunk/extras/set_random_bits.c	2004-11-19 19:50:52 UTC (rev 425)
+++ trunk/extras/set_random_bits.c	2004-11-19 21:32:51 UTC (rev 426)
@@ -107,8 +107,7 @@
 	uint64_t blkno, sys_blkno;
 	int c;
 	char *filename, *buf;
-	const char *bitmap_name = 
-		ocfs2_system_inode_names[GLOBAL_BITMAP_SYSTEM_INODE];
+	const char *bitmap_name = sysfile_info[GLOBAL_BITMAP_SYSTEM_INODE].name;
 	ocfs2_filesys *fs;
 	ocfs2_dinode *di;
 	struct walk_block wb;

Modified: trunk/libocfs2/alloc.c
===================================================================
--- trunk/libocfs2/alloc.c	2004-11-19 19:50:52 UTC (rev 425)
+++ trunk/libocfs2/alloc.c	2004-11-19 21:32:51 UTC (rev 426)
@@ -101,7 +101,7 @@
 {
 	ocfs2_extent_list *fel;
 
-	di->i_generation = 0; /* FIXME */
+	di->i_generation = fs->fs_super->i_generation;
 	di->i_blkno = blkno;
 	di->i_suballoc_node = 0;
 	di->i_suballoc_bit = (uint16_t)(blkno - gd_blkno);
@@ -112,7 +112,7 @@
 		di->i_links_count = 1;
 	strcpy(di->i_signature, OCFS2_INODE_SIGNATURE);
 	di->i_flags |= OCFS2_VALID_FL;
-	di->i_atime = di->i_ctime = di->i_mtime = 0;  /* FIXME */
+	di->i_atime = di->i_ctime = di->i_mtime = time(NULL);
 	di->i_dtime = 0;
 
 	fel = &di->id2.i_list;
@@ -166,7 +166,7 @@
 }
 
 errcode_t ocfs2_new_system_inode(ocfs2_filesys *fs, uint64_t *ino,
-				 int mode)
+				 int mode, int flags)
 {
 	errcode_t ret;
 	char *buf;
@@ -190,9 +190,9 @@
 	memset(buf, 0, fs->fs_blocksize);
 	di = (ocfs2_dinode *)buf;
 	di->i_mode = mode;
+	di->i_flags = flags;
 	ocfs2_init_inode(fs, di, gd_blkno, *ino);
 	di->i_flags |= OCFS2_SYSTEM_FL;
-	di->i_generation = fs->fs_super->i_generation;
 
 	ret = ocfs2_write_inode(fs, *ino, buf);
 

Modified: trunk/libocfs2/checkhb.c
===================================================================
--- trunk/libocfs2/checkhb.c	2004-11-19 19:50:52 UTC (rev 425)
+++ trunk/libocfs2/checkhb.c	2004-11-19 21:32:51 UTC (rev 426)
@@ -352,7 +352,7 @@
 			       	int first_time)
 {
 	ocfs2_filesys *fs = fs_blk->fs;
-	char *dlm = ocfs2_system_inode_names[DLM_SYSTEM_INODE];
+	char *dlm = sysfile_info[DLM_SYSTEM_INODE].name;
 	char *buf = NULL;
 	int buflen = 0;
 	errcode_t ret = 0;

Modified: trunk/libocfs2/include/ocfs2.h
===================================================================
--- trunk/libocfs2/include/ocfs2.h	2004-11-19 19:50:52 UTC (rev 425)
+++ trunk/libocfs2/include/ocfs2.h	2004-11-19 21:32:51 UTC (rev 426)
@@ -37,6 +37,7 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <sys/stat.h>
+#include <time.h>
 
 #include <linux/types.h>
 
@@ -480,7 +481,7 @@
 				  uint32_t new_clusters);
 
 errcode_t ocfs2_new_inode(ocfs2_filesys *fs, uint64_t *ino, int mode);
-errcode_t ocfs2_new_system_inode(ocfs2_filesys *fs, uint64_t *ino, int mode);
+errcode_t ocfs2_new_system_inode(ocfs2_filesys *fs, uint64_t *ino, int mode, int flags);
 errcode_t ocfs2_delete_inode(ocfs2_filesys *fs, uint64_t ino);
 errcode_t ocfs2_new_extent_block(ocfs2_filesys *fs, uint64_t *blkno);
 errcode_t ocfs2_delete_extent_block(ocfs2_filesys *fs, uint64_t blkno);

Modified: trunk/libocfs2/include/ocfs2_fs.h
===================================================================
--- trunk/libocfs2/include/ocfs2_fs.h	2004-11-19 19:50:52 UTC (rev 425)
+++ trunk/libocfs2/include/ocfs2_fs.h	2004-11-19 21:32:51 UTC (rev 426)
@@ -111,6 +111,12 @@
 #define OCFS2_DEFAULT_JOURNAL_SIZE	(8 * ONE_MEGA_BYTE)
 #define OCFS2_MIN_JOURNAL_SIZE		(4 * ONE_MEGA_BYTE)
 
+typedef struct _ocfs2_sysfile_info {
+	char *name;
+	int flags;
+	int dir;
+} ocfs2_sysfile_info;
+
 /* System file index */
 enum {
 	BAD_BLOCK_SYSTEM_INODE = 0,
@@ -127,22 +133,22 @@
 	NUM_SYSTEM_INODES
 };
 
-static char *ocfs2_system_inode_names[NUM_SYSTEM_INODES] = {
+static ocfs2_sysfile_info sysfile_info[NUM_SYSTEM_INODES] = {
 	/* Global system inodes (single copy) */
 	/* The first two are only used from userspace mfks/tunefs */
-	[BAD_BLOCK_SYSTEM_INODE]		"bad_blocks",
-	[GLOBAL_INODE_ALLOC_SYSTEM_INODE] 	"global_inode_alloc",
+	[BAD_BLOCK_SYSTEM_INODE]		{ "bad_blocks", 0, 0 },
+	[GLOBAL_INODE_ALLOC_SYSTEM_INODE] 	{ "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, 0 },
 
 	/* These are used by the running filesystem */
-	[DLM_SYSTEM_INODE]			"dlm",
-	[GLOBAL_BITMAP_SYSTEM_INODE]		"global_bitmap",
-	[ORPHAN_DIR_SYSTEM_INODE]		"orphan_dir",
+	[DLM_SYSTEM_INODE]			{ "dlm", OCFS2_DLM_FL, 0 },
+	[GLOBAL_BITMAP_SYSTEM_INODE]		{ "global_bitmap", 0, 0 },
+	[ORPHAN_DIR_SYSTEM_INODE]		{ "orphan_dir", 0, 1 },
 
 	/* Node-specific system inodes (one copy per node) */
-	[EXTENT_ALLOC_SYSTEM_INODE]		"extent_alloc:%04d",
-	[INODE_ALLOC_SYSTEM_INODE]		"inode_alloc:%04d",
-	[JOURNAL_SYSTEM_INODE]			"journal:%04d",
-	[LOCAL_ALLOC_SYSTEM_INODE]		"local_alloc:%04d"
+	[EXTENT_ALLOC_SYSTEM_INODE]		{ "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, 0 },
+	[INODE_ALLOC_SYSTEM_INODE]		{ "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, 0 },
+	[JOURNAL_SYSTEM_INODE]			{ "journal:%04d", OCFS2_JOURNAL_FL, 0 },
+	[LOCAL_ALLOC_SYSTEM_INODE]		{ "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, 0 }
 };
 
 
@@ -542,11 +548,9 @@
          * list has a copy per node.
          */
 	if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
-		chars = snprintf(buf, len,
-				 ocfs2_system_inode_names[type]);
+		chars = snprintf(buf, len, sysfile_info[type].name);
 	else
-		chars = snprintf(buf, len,
-				 ocfs2_system_inode_names[type], node);
+		chars = snprintf(buf, len, sysfile_info[type].name, node);
 
 	return chars;
 }

Modified: trunk/tunefs.ocfs2/tunefs.c
===================================================================
--- trunk/tunefs.ocfs2/tunefs.c	2004-11-19 19:50:52 UTC (rev 425)
+++ trunk/tunefs.ocfs2/tunefs.c	2004-11-19 21:32:51 UTC (rev 426)
@@ -277,26 +277,30 @@
 	errcode_t ret = 0;
 	uint16_t old_num = OCFS2_RAW_SB(fs->fs_super)->s_max_nodes;
 	char fname[SYSTEM_FILE_NAME_MAX];
-	uint64_t inode_num;
+	uint64_t blkno;
+	int mode;
 	int i, j;
 
 	for (i = OCFS2_LAST_GLOBAL_SYSTEM_INODE + 1; i < NUM_SYSTEM_INODES; ++i) {
 		for (j = old_num; j < opts.num_nodes; ++j) {
-			sprintf(fname, ocfs2_system_inode_names[i], j);
+			sprintf(fname, sysfile_info[i].name, j);
 			printf("Adding %s...  ", fname);
-			inode_num = 1000;
-			ret =  ocfs2_new_system_inode(fs, &inode_num,
-						      0644 | S_IFREG);
+
+			/* create inode for system file */
+			mode = sysfile_info[i].dir ? 0755 | S_IFDIR : 0644 | S_IFREG;
+			ret =  ocfs2_new_system_inode(fs, &blkno, mode, sysfile_info[i].flags);
 			if (ret)
 				goto bail;
+
+			/* Add the inode to the system dir */
 			ret = ocfs2_link(fs, fs->fs_sysdir_blkno, fname,
-					 inode_num, S_IFREG);
+					 blkno, S_IFREG);
 			if (ret) {
 				if (ret == OCFS2_ET_DIR_NO_SPACE) {
 					ret = ocfs2_expand_dir(fs, fs->fs_sysdir_blkno);
 					if (!ret)
 						ret = ocfs2_link(fs, fs->fs_sysdir_blkno,
-								 fname, inode_num, S_IFREG);
+								 fname, blkno, S_IFREG);
 				}
 				if (ret)
 					goto bail;



More information about the Ocfs2-tools-commits mailing list