[Ocfs2-commits] mfasheh commits r1517 - branches/dlm-changes/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Sep 29 19:19:19 CDT 2004


Author: mfasheh
Date: 2004-09-29 19:19:18 -0500 (Wed, 29 Sep 2004)
New Revision: 1517

Modified:
   branches/dlm-changes/src/alloc.c
   branches/dlm-changes/src/ocfs.h
Log:
* Move the cluster locks in the free data / metadata path *outside* of the  
  transaction.

* The transaction now always commits

* Clean things up there a bit:
  - get rid of the inode alloc file handling as it's no longer done there
  - call ocfs_free_main_bitmap directly from ocfs_free_disk_bitmap
  - move all the main bitmap handling into ocfs_free_main_bitmap



Modified: branches/dlm-changes/src/alloc.c
===================================================================
--- branches/dlm-changes/src/alloc.c	2004-09-30 00:08:12 UTC (rev 1516)
+++ branches/dlm-changes/src/alloc.c	2004-09-30 00:19:18 UTC (rev 1517)
@@ -103,14 +103,15 @@
 				   struct inode *inode);
 
 static int ocfs_free_vol_block (ocfs_super * osb, ocfs_journal_handle *handle,
-				ocfs_free_rec * FreeLog, __u32 NodeNum, 
-				__u32 Type);
+				ocfs_free_rec * FreeLog, __u32 NodeNum);
 
 static int ocfs_free_disk_bitmap (ocfs_super * osb, ocfs_free_rec *free_log);
 
 static inline int ocfs_free_main_bitmap(ocfs_super *osb, 
 					ocfs_journal_handle *handle, 
-					ocfs_free_rec *freelog);
+					struct inode *bitmap_inode,
+					struct buffer_head *bh,
+					ocfs_free_rec *freelog); 
 
 /* The largest cluster size where we even consider using local alloc. */
 #define OCFS_LOCAL_ALLOC_MAX_CSIZE    (128 * 1024)
@@ -263,11 +264,9 @@
 	__u32 i;
 //	__u32 node_num;
 	ocfs_free_rec **ext_alloc_free = NULL;
-	ocfs_free_rec **inode_alloc_free = NULL;
 	ocfs_free_rec *free_vol_bits = NULL;
 	ocfs_free_rec *tmp_log = NULL;
 	struct inode **ext_alloc_inode = NULL;
-	struct inode **inode_alloc_inode = NULL;
 	struct inode *vol_inode = NULL;
 	__u32 tmp_indx;
 	struct buffer_head *globalbh = NULL;
@@ -288,10 +287,6 @@
 		}						\
 	} while (0)
 
-	ALLOC_BLOCK(inode_alloc_free,
-		    osb->max_nodes * sizeof (ocfs_free_rec *), status);
-	ALLOC_BLOCK(inode_alloc_inode,
-		    osb->max_nodes * sizeof (struct inode *), status);
 	ALLOC_BLOCK(ext_alloc_free,
 		    osb->max_nodes * sizeof (ocfs_free_rec *), status);
 	ALLOC_BLOCK(ext_alloc_inode,
@@ -301,31 +296,11 @@
 	for (i = 0; i < osb->max_nodes; i++) {
 		ext_alloc_free[i] = NULL;
 		ext_alloc_inode[i] = NULL;
-		inode_alloc_free[i] = NULL;
-		inode_alloc_inode[i] = NULL;
 	}
 
 	num_upd = free_log->num_updates;
 	for (i = 0; i < num_upd; i++) {
 		switch (free_log->update[i].type) {
-		    case DISK_ALLOC_INODE:
-#if 0
-			    node_num = free_log->update[i].node_num;
-			    if (inode_alloc_free[node_num] == NULL) {
-				    inode_alloc_free[node_num] =
-					ocfs_malloc (sizeof (ocfs_free_rec));
-				    if (inode_alloc_free[node_num] == NULL) {
-					    LOG_ERROR_STATUS (status = -ENOMEM);
-					    goto finally;
-				    }
-				    inode_alloc_free[node_num]->num_updates = 0;
-			    }
-			    tmp_log = inode_alloc_free[node_num];
-
-			    credits++;
-#endif
-			    break;
-
 		    case DISK_ALLOC_EXTENT_NODE:
 #if 0
 			    node_num = free_log->update[i].node_num;
@@ -365,7 +340,6 @@
 			    break;
 		}
 
-
 		if (tmp_log) {
 			ocfs_bitmap_update *fb1, *fb2;
 
@@ -383,58 +357,21 @@
 		}
 	}
 
-	/* start the transaction here to preserve ordering with the
-	 * bitmap io_sems... */
-	handle = ocfs_start_trans(osb, NULL, credits);
+	handle = ocfs_alloc_handle(osb);
 	if (!handle) {
 		status = -ENOMEM;
 		LOG_ERROR_STATUS(status);
 		goto finally;
 	}
 
-	/* Get all the locks we need. do global bitmap last to
-	 * preserve lock ordering with extend/create */
 	for (i = 0; i < osb->max_nodes; i++) {
-		if (inode_alloc_free[i] != NULL) {
-			inode_alloc_inode[i] = 
-				ocfs_get_system_file_inode(osb, INODE_ALLOC_BITMAP_SYSTEM_INODE, i);
-			if (!inode_alloc_inode[i]) {
-				status = -EINVAL;
-				LOG_ERROR_STATUS (status);
-				goto abort;
-			}
-
-			status = ocfs_acquire_lock (osb, 
-						    OCFS_LKM_EXMODE,
-						    0,
-						    &tmpbh,
-						    inode_alloc_inode[i]);
-			if (tmpbh) {
-				brelse(tmpbh);
-				tmpbh = NULL;
-			}
-			if (status < 0) {
-				iput(inode_alloc_inode[i]);
-				inode_alloc_inode[i] = NULL;
-				if (status != -EINTR)
-					LOG_ERROR_STATUS (status);
-				goto abort;
-			}
-			ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
-					     0, 
-					     inode_alloc_inode[i]);
-			ocfs_handle_add_inode(handle, inode_alloc_inode[i]);
-		}
-	}
-
-	for (i = 0; i < osb->max_nodes; i++) {
 		if (ext_alloc_free[i] != NULL) {
 			ext_alloc_inode[i] = 
 				ocfs_get_system_file_inode(osb, EXTENT_ALLOC_BITMAP_SYSTEM_INODE, i);
 			if (!ext_alloc_inode[i]) {
 				status = -EINVAL;
 				LOG_ERROR_STATUS (status);
-				goto abort;
+				goto finally;
 			}
 
 			status = ocfs_acquire_lock (osb, 
@@ -451,7 +388,7 @@
 				ext_alloc_inode[i] = NULL;
 				if (status != -EINTR)
 					LOG_ERROR_STATUS (status);
-				goto abort;
+				goto finally;
 			}
 			ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
 					     0,  
@@ -465,7 +402,7 @@
 		if (!vol_inode) {
 			status = -EINVAL;
 			LOG_ERROR_STATUS (status);
-			goto abort;
+			goto finally;
 		}
 
 		status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE,
@@ -477,67 +414,35 @@
 
 			if (status != -EINTR)
 				LOG_ERROR_STATUS (status);
-			goto abort;
+			goto finally;
 		}
 		ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
 				     0, vol_inode);
 		ocfs_handle_add_inode(handle, vol_inode);
 	}
 
-	/* free vol block */
-	if (free_vol_bits != NULL)
-		ocfs_free_vol_block(osb, handle, free_vol_bits, -1, 
-				    DISK_ALLOC_VOLUME);
+	handle = ocfs_start_trans(osb, handle, credits);
+	if (!handle) {
+		status = -ENOMEM;
+		LOG_ERROR_STATUS(status);
+		goto finally;
+	}
+	ocfs_handle_set_always_commits(handle, 1);
 
+	if (free_vol_bits)
+		ocfs_free_main_bitmap(osb, handle, vol_inode, 
+				      globalbh, free_vol_bits);
+
 	for (i = 0; i < osb->max_nodes; i++) {
-		if (inode_alloc_free[i] != NULL)
-			ocfs_free_vol_block(osb, handle,
-					    inode_alloc_free[i], i,
-					    DISK_ALLOC_INODE);
 		if (ext_alloc_free[i] != NULL)
 			ocfs_free_vol_block(osb, handle,
-					    ext_alloc_free[i], i,
-					    DISK_ALLOC_EXTENT_NODE);
+					    ext_alloc_free[i], i);
 	}
 
-	if (free_vol_bits) {
-		ocfs2_dinode *bm_lock;
-
-		status = ocfs_journal_access(handle, globalbh, 
-					     OCFS_JOURNAL_ACCESS_WRITE);
-		if (status < 0) {
-			LOG_ERROR_STATUS(status);
-			goto abort;
-		}
-
-		bm_lock = (ocfs2_dinode *) globalbh->b_data;
-		bm_lock->id1.bitmap1.i_used =
-			ocfs_count_bits(osb->sb, &osb->cluster_bitmap);
-
-		status = ocfs_journal_dirty(handle, globalbh);
-		if (status < 0) {
-			LOG_ERROR_STATUS (status);
-			goto abort;
-		}
-	}
-
-	ocfs_commit_trans(handle);
-
-	handle = NULL;
-
-abort:
+finally:
 	if (handle)
-		ocfs_abort_trans(handle);
+		ocfs_commit_trans(handle);
 
-finally:
-	if (inode_alloc_inode) {
-		for (i = 0; i < osb->max_nodes; i++) {
-			if (inode_alloc_inode[i])
-				iput(inode_alloc_inode[i]);
-		}
-		kfree(inode_alloc_inode);
-	}
-
 	if (ext_alloc_inode) {
 		for (i = 0; i < osb->max_nodes; i++) {
 			if (ext_alloc_inode[i])
@@ -560,14 +465,6 @@
 		kfree(ext_alloc_free);
 	}
 
-	if (inode_alloc_free) {
-		for (i = 0; i < osb->max_nodes; i++) {
-			if (inode_alloc_free[i])
-				kfree(inode_alloc_free[i]);
-		}
-		kfree(inode_alloc_free);
-	}
-
 	if (free_vol_bits)
 		kfree(free_vol_bits);
 
@@ -577,22 +474,18 @@
 
 static inline int ocfs_free_main_bitmap(ocfs_super *osb, 
 					ocfs_journal_handle *handle, 
+					struct inode *bitmap_inode,
+					struct buffer_head *bh,
 					ocfs_free_rec *freelog) 
 {
 	int i;
 	ocfs_alloc_bm *bitmap;
 	int status;
 	__u32 bitmapblocks; /* we only care about the valid blocks */
-	struct inode *bitmap_inode = NULL;
+	ocfs2_dinode *bm_lock;
 
 	LOG_ENTRY();
 
-	bitmap_inode = ocfs_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, -1);
-	if (!bitmap_inode) {
-		LOG_ERROR_STATUS (status = -EINVAL);
-		goto bail;
-	}
-
 	bitmap = &osb->cluster_bitmap;
 
 	bitmapblocks = ocfs_blocks_for_bits(osb->sb, bitmap->validbits);
@@ -605,15 +498,29 @@
 		goto bail;
 	}
 
-	for (i = 0; i < freelog->num_updates; i++)
+	status = ocfs_journal_access(handle, bh, 
+				     OCFS_JOURNAL_ACCESS_WRITE);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+	bm_lock = (ocfs2_dinode *) bh->b_data;
+
+	for (i = 0; i < freelog->num_updates; i++) {
 		ocfs_clear_bits(osb->sb, handle, bitmap,
 				freelog->update[i].file_off,
 				freelog->update[i].length);
+		bm_lock->id1.bitmap1.i_used -= freelog->update[i].length;
+	}
 
+	status = ocfs_journal_dirty(handle, bh);
+	if (status < 0) {
+		LOG_ERROR_STATUS (status);
+		goto bail;
+	}
+
 	status = 0;
 bail:
-	if (bitmap_inode)
-		iput(bitmap_inode);
 	LOG_EXIT_STATUS(status);
 	return(0);
 }
@@ -624,8 +531,7 @@
  */
 static int ocfs_free_vol_block(ocfs_super *osb,
 			       ocfs_journal_handle *handle,
-			       ocfs_free_rec *FreeLog, __u32 NodeNum,
-			       __u32 Type)
+			       ocfs_free_rec *FreeLog, __u32 NodeNum)
 {
 	int status = 0;
 	__u64 fileSize = 0;
@@ -641,35 +547,17 @@
 
 	LOG_ENTRY ();
 
-	LOG_TRACE_ARGS("Free Log Details (type = %d):\n", Type);
+	LOG_TRACE_ARGS("Free Log Details\n");
 	LOG_TRACE_ARGS("num_updates = %u\n", FreeLog->num_updates);
 	for(i = 0; i < FreeLog->num_updates; i++)
 		LOG_TRACE_ARGS("(upd=%u, length=%llu, file_off=%llu, type=%d, node_num=%d)\n", 
 			       i, FreeLog->update[i].length, FreeLog->update[i].file_off, 
 			       FreeLog->update[i].type, FreeLog->update[i].node_num);
 
-	switch (Type) {
-	    case DISK_ALLOC_EXTENT_NODE:
-		    file_type = EXTENT_ALLOC_BITMAP_SYSTEM_INODE;
-		    blockSize = osb->sb->s_blocksize;
-		    blockSizeBits = osb->sb->s_blocksize_bits;
-		    break;
+	file_type = EXTENT_ALLOC_BITMAP_SYSTEM_INODE;
+	blockSize = osb->sb->s_blocksize;
+	blockSizeBits = osb->sb->s_blocksize_bits;
 
-	    case DISK_ALLOC_INODE:
-		    file_type = INODE_ALLOC_BITMAP_SYSTEM_INODE;
-		    blockSize = osb->sb->s_blocksize;
-		    blockSizeBits = osb->sb->s_blocksize_bits;
-		    break;
-
-	    case DISK_ALLOC_VOLUME:
-		    status = ocfs_free_main_bitmap(osb, handle, FreeLog);
-		    if (status < 0)
-			    LOG_ERROR_STATUS (status);
-		    goto leave;
-	    default:
-		    goto leave;
-	}
-
 	if (NodeNum >= osb->max_nodes) {
 		LOG_ERROR_STATUS(status = -EINVAL);
 		goto leave;
@@ -699,9 +587,8 @@
 	}
 
 	for (i = 0; i < FreeLog->num_updates; i++) {
-		if (FreeLog->update[i].file_off == 0 && Type == 0) {
-			LOG_ERROR_ARGS ("offset=0, type=%x, blksz=%d", Type,
-					blockSize);
+		if (FreeLog->update[i].file_off == 0) {
+			LOG_ERROR_ARGS ("offset=0, blksz=%d", blockSize);
 		}
 		
 		foundBit = (__u32) (FreeLog->update[i].file_off >> blockSizeBits);

Modified: branches/dlm-changes/src/ocfs.h
===================================================================
--- branches/dlm-changes/src/ocfs.h	2004-09-30 00:08:12 UTC (rev 1516)
+++ branches/dlm-changes/src/ocfs.h	2004-09-30 00:19:18 UTC (rev 1517)
@@ -823,7 +823,6 @@
 /* these three used as 'type' in ocfs_bitmap_update */
 #define  DISK_ALLOC_EXTENT_NODE   2
 #define  DISK_ALLOC_VOLUME        3
-#define  DISK_ALLOC_INODE	  4
 
 /* a bitmap update, currently used for freeing bits */
 typedef struct ocfs_bitmap_update



More information about the Ocfs2-commits mailing list