[Ocfs2-commits] mfasheh commits r1643 - branches/dlm-glue/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Nov 11 16:09:15 CST 2004


Author: mfasheh
Date: 2004-11-11 16:09:13 -0600 (Thu, 11 Nov 2004)
New Revision: 1643

Modified:
   branches/dlm-glue/src/inode.c
   branches/dlm-glue/src/localalloc.c
   branches/dlm-glue/src/ocfs.h
   branches/dlm-glue/src/ocfs2_fs.h
   branches/dlm-glue/src/suballoc.c
Log:
* bring the dlm-glue branch up to date with trunk revision 1642



Modified: branches/dlm-glue/src/inode.c
===================================================================
--- branches/dlm-glue/src/inode.c	2004-11-11 21:44:37 UTC (rev 1642)
+++ branches/dlm-glue/src/inode.c	2004-11-11 22:09:13 UTC (rev 1643)
@@ -378,7 +378,6 @@
 
 	OCFS_I(inode)->ip_clusters = fe->i_clusters;
 	OCFS_I(inode)->ip_inode = inode;
-	OCFS_I(inode)->u.fe_private = fe->id1.i_pad1;
 
 	if (create_ino)
 		inode->i_ino = ino_from_blkno(inode->i_sb, fe->i_blkno);
@@ -394,13 +393,6 @@
 		LOG_TRACE_ARGS("local alloc inode: i_ino=%lu\n", inode->i_ino);
 	} else if (le32_to_cpu(fe->i_flags) & OCFS2_BITMAP_FL) {
 		OCFS_I(inode)->ip_flags |= OCFS_INODE_BITMAP;
-		OCFS_I(inode)->u.ip_bitinfo.used_bits = 
-			le32_to_cpu(fe->id1.bitmap1.i_used);
-		OCFS_I(inode)->u.ip_bitinfo.total_bits = 
-			le32_to_cpu(fe->id1.bitmap1.i_total);
-		LOG_TRACE_ARGS("bitmap inode: i_ino=%lu, used=%u, total=%u\n",
-			       inode->i_ino, OCFS_I(inode)->u.ip_bitinfo.used_bits,
-			       OCFS_I(inode)->u.ip_bitinfo.total_bits);
 	} else if (le32_to_cpu(fe->i_flags) & OCFS2_SUPER_BLOCK_FL) {
 		LOG_TRACE_ARGS("superblock inode: i_ino=%lu\n", inode->i_ino);
 		// we can't actually hit this as read_inode can't handle
@@ -973,13 +965,6 @@
 	}
 
 	spin_lock(&OCFS_I(inode)->ip_lock);
-	if (le32_to_cpu(fe->i_flags) & OCFS2_BITMAP_FL) {
-		fe->id1.bitmap1.i_used = 
-			cpu_to_le32(OCFS_I(inode)->u.ip_bitinfo.used_bits);
-		fe->id1.bitmap1.i_total = 
-			cpu_to_le32(OCFS_I(inode)->u.ip_bitinfo.total_bits);
-	}
-
 	fe->i_clusters = OCFS_I(inode)->ip_clusters;
 	spin_unlock(&OCFS_I(inode)->ip_lock);
 
@@ -1020,16 +1005,6 @@
 
 	spin_lock(&oip->ip_lock);
 
-	if (le32_to_cpu(fe->i_flags) & OCFS2_BITMAP_FL) {
-		oip->u.ip_bitinfo.used_bits = 
-			le32_to_cpu(fe->id1.bitmap1.i_used);
-		oip->u.ip_bitinfo.total_bits = 
-			le32_to_cpu(fe->id1.bitmap1.i_total);
-		LOG_TRACE_ARGS("updated bitmap inode: i_ino=%lu, used=%u, total=%u\n",
-			       inode->i_ino, oip->u.ip_bitinfo.used_bits,
-			       oip->u.ip_bitinfo.total_bits);
-	}
-
 	oip->ip_clusters = fe->i_clusters;
 	inode->i_size = fe->i_size;
 	if (S_ISREG(inode->i_mode)) {

Modified: branches/dlm-glue/src/localalloc.c
===================================================================
--- branches/dlm-glue/src/localalloc.c	2004-11-11 21:44:37 UTC (rev 1642)
+++ branches/dlm-glue/src/localalloc.c	2004-11-11 22:09:13 UTC (rev 1643)
@@ -161,6 +161,13 @@
 
 	alloc = (ocfs2_dinode *) alloc_bh->b_data;
 
+	if (!(alloc->i_flags & (OCFS2_LOCAL_ALLOC_FL|OCFS2_BITMAP_FL))) {
+		LOG_ERROR_ARGS("Invalid local alloc inode, %llu\n",
+			       OCFS_I(inode)->ip_blkno);
+		status = -EINVAL;
+		goto bail;
+	}
+
 	/* do a little verification. */
 	num_used = ocfs_local_alloc_count_bits(alloc);
 
@@ -168,14 +175,14 @@
 	 * we load it so there should be no bits used from the main
 	 * bitmap. */
 	if (num_used
-	    || LOCAL_ALLOC(alloc)->la_bits_set
-	    || LOCAL_ALLOC(alloc)->la_bm_bits 
+	    || alloc->id1.bitmap1.i_used
+	    || alloc->id1.bitmap1.i_total
 	    || LOCAL_ALLOC(alloc)->la_bm_off) {
 		LOG_ERROR_ARGS("Local alloc hasn't been recovered!\n"
 			       "found = %u, set = %u, taken = %u, off = %u\n",
 			       num_used,
-			       LOCAL_ALLOC(alloc)->la_bits_set, 
-			       LOCAL_ALLOC(alloc)->la_bm_bits,
+			       alloc->id1.bitmap1.i_used,
+			       alloc->id1.bitmap1.i_total,
 			       LOCAL_ALLOC(alloc)->la_bm_off);
 		status = -EBUSY;
 		goto bail;
@@ -474,10 +481,6 @@
  * 
  * We will add ourselves to the transaction passed in, but may start
  * our own in order to shift windows.
- *
- * When we stop being lame and support multiple chunks of
- * discontiguous space, we this turns into a really simple check of
- * ->la_bits_set
  */
 int ocfs_reserve_local_alloc_bits(ocfs_super *osb,
 				  ocfs_journal_handle *passed_handle,
@@ -487,7 +490,7 @@
 	int status;
 	ocfs2_dinode *alloc;
 	struct inode *local_alloc_inode;
-	int free_bits;
+	unsigned int free_bits;
 
 	LOG_ENTRY();
 
@@ -526,11 +529,11 @@
 
 	alloc = (ocfs2_dinode *) osb->local_alloc_bh->b_data;
 
-	OCFS_ASSERT(LOCAL_ALLOC(alloc)->la_bits_set == 
+	OCFS_ASSERT(alloc->id1.bitmap1.i_used == 
 		    ocfs_local_alloc_count_bits(alloc));
 
-	free_bits = le16_to_cpu(LOCAL_ALLOC(alloc)->la_bm_bits) - 
-		le16_to_cpu(LOCAL_ALLOC(alloc)->la_bits_set);
+	free_bits = le32_to_cpu(alloc->id1.bitmap1.i_total) - 
+		le32_to_cpu(alloc->id1.bitmap1.i_used);
 	if (bits_wanted > free_bits) {
 		/* uhoh, window change time. */
 		status = 
@@ -600,7 +603,7 @@
 	while(bits_wanted--)
 		ocfs2_set_bit(start++, bitmap);
 
-	LOCAL_ALLOC(alloc)->la_bits_set += *num_bits;
+	alloc->id1.bitmap1.i_used += *num_bits;
 
 	status = ocfs_journal_dirty(handle, osb->local_alloc_bh);
 	if (status < 0) {
@@ -649,7 +652,7 @@
 
 	LOG_ENTRY_ARGS("(numbits wanted = %u)\n", numbits);
 
-	if (LOCAL_ALLOC(alloc)->la_bm_bits == 0) {
+	if (!alloc->id1.bitmap1.i_total) {
 		LOG_TRACE_STR("No bits in my window!");
 		bitoff = -1;
 		goto bail;
@@ -659,7 +662,7 @@
 
 	numfound = bitoff = startoff = 0;
 	lastzero = -1;
-	left = LOCAL_ALLOC(alloc)->la_bm_bits;
+	left = alloc->id1.bitmap1.i_total;
 	while ((bitoff = ocfs2_find_next_zero_bit(bitmap, left, startoff)) != -1) {
 		if (bitoff == left) {
 			/* LOG_TRACE_ARGS("bitoff (%d) == left", bitoff); */
@@ -707,8 +710,8 @@
 	int i;
 	LOG_ENTRY();
 
-	LOCAL_ALLOC(alloc)->la_bm_bits = 0;
-	LOCAL_ALLOC(alloc)->la_bits_set = 0;
+	alloc->id1.bitmap1.i_total = 0;
+	alloc->id1.bitmap1.i_used = 0;
 	LOCAL_ALLOC(alloc)->la_bm_off = 0;
 	for(i = 0; i < LOCAL_ALLOC(alloc)->la_size; i++)
 		LOCAL_ALLOC(alloc)->la_bitmap[i] = 0;
@@ -756,18 +759,17 @@
 	u64 blkno;
 	void *bitmap;
 
-	LOG_ENTRY_ARGS("alloc->la_bm_bits = %u, COUNT = %u, "
-		       "la_bits_set = %u\n", LOCAL_ALLOC(alloc)->la_bm_bits,
+	LOG_ENTRY_ARGS("total = %u, COUNT = %u, used = %u\n", 
+		       alloc->id1.bitmap1.i_total,
 		       ocfs_local_alloc_count_bits(alloc), 
-		       LOCAL_ALLOC(alloc)->la_bits_set);
+		       alloc->id1.bitmap1.i_used);
 
-	if (LOCAL_ALLOC(alloc)->la_bm_bits == 0) {
+	if (!alloc->id1.bitmap1.i_total) {
 		LOG_TRACE_STR("nothing to sync!");
 		goto bail;
 	}
 
-	if (LOCAL_ALLOC(alloc)->la_bits_set == 
-	    LOCAL_ALLOC(alloc)->la_bm_bits) {
+	if (alloc->id1.bitmap1.i_used == alloc->id1.bitmap1.i_total) {
 		LOG_TRACE_STR("all bits were taken!");
 		goto bail;
 	}
@@ -776,7 +778,7 @@
 						LOCAL_ALLOC(alloc)->la_bm_off);
 	bitmap = LOCAL_ALLOC(alloc)->la_bitmap;
 	start = count = bit_off = 0;
-	left = LOCAL_ALLOC(alloc)->la_bm_bits;
+	left = alloc->id1.bitmap1.i_total;
 
 	while ((bit_off = ocfs2_find_next_zero_bit(bitmap, left, start)) 
 	       != -1) {
@@ -870,7 +872,7 @@
 	LOG_ENTRY();
 
 	alloc = (ocfs2_dinode *) osb->local_alloc_bh->b_data;
-	if (LOCAL_ALLOC(alloc)->la_bm_bits != 0)
+	if (alloc->id1.bitmap1.i_total)
 		LOG_TRACE_STR("asking me to alloc a new window over a"
 			      " non-empty one");
 
@@ -892,20 +894,19 @@
 	alloc = (ocfs2_dinode *) osb->local_alloc_bh->b_data;
 
 	LOCAL_ALLOC(alloc)->la_bm_off = cluster_off;
-	LOCAL_ALLOC(alloc)->la_bm_bits = cluster_count;
+	alloc->id1.bitmap1.i_total = cpu_to_le32(cluster_count);
 	/* just in case... In the future when we find space ourselves,
 	 * we don't have to get all contiguous -- but we'll have to
 	 * set all previously used bits in bitmap and update
 	 * la_bits_set before setting the bits in the main bitmap. */
-	LOCAL_ALLOC(alloc)->la_bits_set = 0;
+	alloc->id1.bitmap1.i_used = 0;
 	memset(LOCAL_ALLOC(alloc)->la_bitmap, 0,
 	       LOCAL_ALLOC(alloc)->la_size);
 
 	LOG_TRACE_STR("New window allocated:");
 	LOG_TRACE_ARGS("window la_bm_off = %u\n",
 		       LOCAL_ALLOC(alloc)->la_bm_off);
-	LOG_TRACE_ARGS("window la_bm_bits = %u\n",
-		       LOCAL_ALLOC(alloc)->la_bm_bits);
+	LOG_TRACE_ARGS("window bits = %u\n", alloc->id1.bitmap1.i_total);
 
 bail:
 	LOG_EXIT_STATUS(status);

Modified: branches/dlm-glue/src/ocfs.h
===================================================================
--- branches/dlm-glue/src/ocfs.h	2004-11-11 21:44:37 UTC (rev 1642)
+++ branches/dlm-glue/src/ocfs.h	2004-11-11 22:09:13 UTC (rev 1643)
@@ -46,23 +46,6 @@
 #include <dlmcommon.h>
 #include <dlmmod.h>
 
-#define OCFS_BITS_IN_CHUNK(sb)  ((sb)->s_blocksize * 8)
-
-typedef struct _ocfs_alloc_bm
-{
-	__u32 validbits; /* number of valid bits */
-	__u32 allocbits; /* number of allocated bits */
-	__u32 failed;
-	__u32 ok_retries;
-	/* 'numbh' is the number of buffer heads in chunk. We keep
-	 * around enough buffer heads to cover the entire alloc'd size
-	 * of the bitmap, even though we may only ever care about the
-	 * valid size */
-	__u32 numbh;
-	struct buffer_head **chunk;
-}
-ocfs_alloc_bm;
-
 /* convenience macro */
 
 #define OCFS_ASSERT(x)             do { if (!(x)) BUG(); } while (0)
@@ -287,15 +270,6 @@
 	atomic_t          ip_clean_buffer_seq;
 	u32             ip_flags; /* see below */
 
-	/* stolen right off of ocfs2_dinode */
-	union {
-		__u64 fe_private;
-		struct _ip_bitinfo {
-			__u32 used_bits;
-			__u32 total_bits;
-		} ip_bitinfo;
-	} u;
-
 	/* protected by recovery_lock. */
 	struct inode      *ip_next_orphan;
 
@@ -623,54 +597,6 @@
 	return -EINVAL;
 }
 
-static inline int ocfs_blocks_for_bits(struct super_block *sb,
- 				       unsigned int num_bits)
-{
-	int bits_per_chunk = OCFS_BITS_IN_CHUNK(sb);
-
-	return (num_bits + (bits_per_chunk - 1)) / bits_per_chunk;
-}
-
-static inline void ocfs_bitmap_block_for_off(struct super_block *sb,
-					     unsigned int bm_off,
-					     unsigned int *block,
-					     unsigned int *block_off)
-{
-	if (block)
-		*block = bm_off / OCFS_BITS_IN_CHUNK(sb);
-
-	if (block_off)
-		*block_off = bm_off % OCFS_BITS_IN_CHUNK(sb);
-}
-
-static inline unsigned int ocfs_bitmap_off_for_block(struct super_block *sb,
-						     unsigned int block,
-						     unsigned int block_off)
-{
-	return ((block * OCFS_BITS_IN_CHUNK(sb)) + block_off);
-}
-
-static inline int ocfs_bitmap_blocks_affected(struct super_block *sb,
-					      unsigned int start_bit,
-					      unsigned int num_bits,
-					      unsigned int *start_blk)
-{
-	unsigned int start_tmp, end_tmp;
-
-	ocfs_bitmap_block_for_off(sb, start_bit, &start_tmp, NULL);
-	if (start_blk)
-		*start_blk = start_tmp;
-
-	if (!num_bits)
-		return 0;
-
-	ocfs_bitmap_block_for_off(sb, start_bit + num_bits - 1,
-				  &end_tmp, NULL);
-
-	return (end_tmp - start_tmp + 1);
-}
-
-
 typedef struct _ocfs_journal_handle ocfs_journal_handle;
 
 #endif /* !OCFS_H */

Modified: branches/dlm-glue/src/ocfs2_fs.h
===================================================================
--- branches/dlm-glue/src/ocfs2_fs.h	2004-11-11 21:44:37 UTC (rev 1642)
+++ branches/dlm-glue/src/ocfs2_fs.h	2004-11-11 22:09:13 UTC (rev 1643)
@@ -323,12 +323,9 @@
 typedef struct _ocfs2_local_alloc
 {
 /*00*/	__u32 la_bm_off;	/* Starting bit offset in main bitmap */
-	/* Do we want to use id1.bitmap1? */
-	__u16 la_bm_bits;	/* Number of bits from main bitmap */
-	__u16 la_bits_set;	/* Number of set bits */
 	__u16 la_size;		/* Size of included bitmap, in bytes */
 	__u16 la_reserved1;
-	__u32 la_reserved2;
+	__u64 la_reserved2;
 /*10*/	__u8 la_bitmap[0];
 } ocfs2_local_alloc;
 

Modified: branches/dlm-glue/src/suballoc.c
===================================================================
--- branches/dlm-glue/src/suballoc.c	2004-11-11 21:44:37 UTC (rev 1642)
+++ branches/dlm-glue/src/suballoc.c	2004-11-11 22:09:13 UTC (rev 1643)
@@ -386,8 +386,6 @@
 	OCFS_I(alloc_inode)->ip_clusters = fe->i_clusters;
 	fe->i_size = ocfs2_clusters_to_bytes(alloc_inode->i_sb,
 					     fe->i_clusters);
-	OCFS_I(alloc_inode)->u.ip_bitinfo.used_bits = fe->id1.bitmap1.i_used;
-	OCFS_I(alloc_inode)->u.ip_bitinfo.total_bits = fe->id1.bitmap1.i_total;
 	spin_unlock(&OCFS_I(alloc_inode)->ip_lock);
 	alloc_inode->i_size = fe->i_size;
 	alloc_inode->i_blocks = (alloc_inode->i_size + osb->sb->s_blocksize - 1) >> osb->sb->s_blocksize_bits;
@@ -1094,10 +1092,6 @@
 	LOG_TRACE_ARGS("Allocated %u bits from suballocator %llu\n", 
 		       *num_bits, fe->i_blkno);
 
-	spin_lock(&OCFS_I(alloc_inode)->ip_lock);
-	OCFS_I(alloc_inode)->u.ip_bitinfo.used_bits = fe->id1.bitmap1.i_used;
-	spin_unlock(&OCFS_I(alloc_inode)->ip_lock);
-
 	*bg_blkno = bg->bg_blkno;
 bail:
 	if (group_bh)
@@ -1442,9 +1436,6 @@
 		goto bail;
 	}
 
-	spin_lock(&OCFS_I(alloc_inode)->ip_lock);
-	OCFS_I(alloc_inode)->u.ip_bitinfo.used_bits = fe->id1.bitmap1.i_used;
-	spin_unlock(&OCFS_I(alloc_inode)->ip_lock);
 bail:
 	if (group_bh)
 		brelse(group_bh);



More information about the Ocfs2-commits mailing list