[Ocfs2-commits] mfasheh commits r1400 - trunk/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Aug 30 13:04:16 CDT 2004


Author: mfasheh
Date: 2004-08-30 13:04:15 -0500 (Mon, 30 Aug 2004)
New Revision: 1400

Modified:
   trunk/src/inode.c
   trunk/src/namei.c
   trunk/src/ocfs.h
   trunk/src/super.c
Log:
* start using i_generation. This will help us detect stale inodes in
  the future. Thanks to ext3 for most of the code :)



Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c	2004-08-30 17:40:48 UTC (rev 1399)
+++ trunk/src/inode.c	2004-08-30 18:04:15 UTC (rev 1400)
@@ -1010,6 +1010,16 @@
 		goto leave;
 	}
 
+	if (inode->i_generation != le32_to_cpu(fe->i_generation)) {
+		LOG_ERROR_ARGS("Inode %llu is stale! (%u, %u)\n",
+			       OCFS_I(inode)->ip_blkno, 
+			       inode->i_generation,
+			       le32_to_cpu(fe->i_generation));
+		SET_INODE_DELETED(inode);
+		status = -ENOENT;
+		goto leave;
+	}
+
 	if ((OCFS_I(inode)->ip_alloc_size !=
 	     (__s64)((u64)fe->i_clusters << osb->s_clustersize_bits)) ||
 	    (inode->i_size != (__s64) fe->i_size) ||

Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c	2004-08-30 17:40:48 UTC (rev 1399)
+++ trunk/src/namei.c	2004-08-30 18:04:15 UTC (rev 1400)
@@ -432,11 +432,9 @@
 	}
 #endif
 
-	/*
-	 * FIXME This needs to be
-	 * (node_num << 24) | (nodeconf->gen_counter++ & 0x00FFFFFF)
-	 */
-	inode->i_generation = 0;
+	spin_lock(&osb->s_next_gen_lock);
+	inode->i_generation = osb->s_next_generation++;
+	spin_unlock(&osb->s_next_gen_lock);
 	fe->i_generation = cpu_to_le32(inode->i_generation);
 	fe->i_blkno = fe_blkno;
 	fe->i_suballoc_blkno = fileOffset >> osb->sb->s_blocksize_bits;

Modified: trunk/src/ocfs.h
===================================================================
--- trunk/src/ocfs.h	2004-08-30 17:40:48 UTC (rev 1399)
+++ trunk/src/ocfs.h	2004-08-30 18:04:15 UTC (rev 1400)
@@ -550,7 +550,10 @@
 	u32 s_feature_compat;
 	u32 s_feature_incompat;
 	u32 s_feature_ro_compat;
-	
+
+	spinlock_t s_next_gen_lock;
+	u32 s_next_generation;
+
 	ocfs_vol_node_map *vol_node_map;
 	struct semaphore cfg_lock;
 	BARF_BARF_BARF **node_cfg_info;

Modified: trunk/src/super.c
===================================================================
--- trunk/src/super.c	2004-08-30 17:40:48 UTC (rev 1399)
+++ trunk/src/super.c	2004-08-30 18:04:15 UTC (rev 1400)
@@ -36,6 +36,7 @@
 #include <linux/utsname.h>
 #include <linux/init.h>
 #include <linux/sysctl.h>
+#include <linux/random.h>
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 #include <linux/statfs.h>
 #include <linux/moduleparam.h>
@@ -1391,6 +1392,9 @@
 		goto done_nojournal;
 	}
 
+	spin_lock_init(&osb->s_next_gen_lock);
+	get_random_bytes(&osb->s_next_generation, sizeof(u32));
+
 	/* FIXME
 	 * This should be done in ocfs_journal_init(), but unknown
 	 * ordering issues will cause the filesystem to crash.



More information about the Ocfs2-commits mailing list