[Ocfs2-commits] mfasheh commits r1155 - in trunk: . src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Jun 18 21:23:27 CDT 2004


Author: mfasheh
Date: 2004-06-18 20:23:25 -0500 (Fri, 18 Jun 2004)
New Revision: 1155

Modified:
   trunk/TODO
   trunk/src/alloc.c
   trunk/src/inode.c
Log:
* we can now delete bits from the inode alloc system file.



Modified: trunk/TODO
===================================================================
--- trunk/TODO	2004-06-19 01:18:48 UTC (rev 1154)
+++ trunk/TODO	2004-06-19 01:23:25 UTC (rev 1155)
@@ -27,8 +27,6 @@
   values when the inode is passed in too (example: make acquire_lock not take
   an offset, as you get that off the inode which is passed in).
 
-* We need to be able to delete stuff from the inode alloc system file(s).
-
 * Investigate whether we need a seperate sysfile for truncate orphans (in
   the future)
 

Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c	2004-06-19 01:18:48 UTC (rev 1154)
+++ trunk/src/alloc.c	2004-06-19 01:23:25 UTC (rev 1155)
@@ -168,7 +168,7 @@
 		       "type=%d (\"%s\")\n", len, fileoff, nodenum, type, 
 		       (type == DISK_ALLOC_VOLUME) ? "DISK_ALLOC_VOLUME" : 
 		       ( (type == DISK_ALLOC_EXTENT_NODE) ? 
-			 "DISK_ALLOC_EXTENT_NODE" : "DISK_ALLOC_DIR_NODE" ));
+			 "DISK_ALLOC_EXTENT_NODE" : "DISK_ALLOC_INODE" ));
 
 	if (len == 0) {
 		printk("ocfs2: Zero length delete!\n");
@@ -176,7 +176,7 @@
 		       "type=%d (\"%s\")\n", len, fileoff, nodenum, type, 
 		       (type == DISK_ALLOC_VOLUME) ? "DISK_ALLOC_VOLUME" : 
 		       ( (type == DISK_ALLOC_EXTENT_NODE) ? 
-			 "DISK_ALLOC_EXTENT_NODE" : "DISK_ALLOC_DIR_NODE" ));
+			 "DISK_ALLOC_EXTENT_NODE" : "DISK_ALLOC_INODE" ));
 		BUG();
 	}
 
@@ -222,10 +222,12 @@
 	__u32 num_upd;
 	__u32 i;
 	__u32 node_num;
-	ocfs_free_rec **free_ext_node = NULL;
+	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;
-	struct inode **extnode_inode = 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;
@@ -245,32 +247,54 @@
 		}						\
 	} while (0)
 
-	ALLOC_BLOCK(free_ext_node,
+	ALLOC_BLOCK(inode_alloc_free,
 		    osb->max_nodes * sizeof (ocfs_free_rec *), status);
-	ALLOC_BLOCK(extnode_inode,
+	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,
+		    osb->max_nodes * sizeof (struct inode *), status);
 
 	/* init */
 	for (i = 0; i < osb->max_nodes; i++) {
-		free_ext_node[i] = NULL;
-		extnode_inode[i] = NULL;
+		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:
+			    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++;
+			    break;
+
 		    case DISK_ALLOC_EXTENT_NODE:
 			    node_num = free_log->update[i].node_num;
-			    if (free_ext_node[node_num] == NULL) {
-				    free_ext_node[node_num] =
+			    if (ext_alloc_free[node_num] == NULL) {
+				    ext_alloc_free[node_num] =
 					ocfs_malloc (sizeof (ocfs_free_rec));
-				    if (free_ext_node[node_num] == NULL) {
+				    if (ext_alloc_free[node_num] == NULL) {
 					    LOG_ERROR_STATUS (status = -ENOMEM);
 					    goto finally;
 				    }
-				    free_ext_node[node_num]->num_updates = 0;
+				    ext_alloc_free[node_num]->num_updates = 0;
 			    }
-			    tmp_log = free_ext_node[node_num];
+			    tmp_log = ext_alloc_free[node_num];
 
 			    credits++;
 			    break;
@@ -326,25 +350,50 @@
 	/* 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 (free_ext_node[i] != NULL) {
-			extnode_inode[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;
+			}
+			ocfs_handle_add_inode(handle, inode_alloc_inode[i]);
+
+			status = ocfs_acquire_lock (osb, 
+						    OCFS_DLM_EXCLUSIVE_LOCK,
+						    FLAG_FILE_CREATE,
+						    NULL,
+						    inode_alloc_inode[i]);
+			if (status < 0) {
+				iput(inode_alloc_inode[i]);
+				inode_alloc_inode[i] = NULL;
+				if (status != -EINTR)
+					LOG_ERROR_STATUS (status);
+				goto abort;
+			}
+		}
+	}
+
+	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 (!extnode_inode[i]) {
+			if (!ext_alloc_inode[i]) {
 				status = -EINVAL;
 				LOG_ERROR_STATUS (status);
 				goto abort;
 			}
-			down_write(&OCFS_I(extnode_inode[i])->ip_io_sem);
+			ocfs_handle_add_inode(handle, ext_alloc_inode[i]);
 
 			status = ocfs_acquire_lock (osb, 
 						    OCFS_DLM_EXCLUSIVE_LOCK,
 						    FLAG_FILE_CREATE,
 						    NULL,
-						    extnode_inode[i]);
+						    ext_alloc_inode[i]);
 			if (status < 0) {
-				up_write(&OCFS_I(extnode_inode[i])->ip_io_sem);
-				iput(extnode_inode[i]);
-				extnode_inode[i] = NULL;
+				iput(ext_alloc_inode[i]);
+				ext_alloc_inode[i] = NULL;
 				if (status != -EINTR)
 					LOG_ERROR_STATUS (status);
 				goto abort;
@@ -359,13 +408,12 @@
 			LOG_ERROR_STATUS (status);
 			goto abort;
 		}
-		down_write(&OCFS_I(vol_inode)->ip_io_sem);
+		ocfs_handle_add_inode(handle, vol_inode);
 
 		status = ocfs_acquire_lock(osb, OCFS_DLM_EXCLUSIVE_LOCK,
 					   FLAG_FILE_CREATE,
 					   &globalbh, vol_inode);
 		if (status < 0) {
-			up_write(&OCFS_I(vol_inode)->ip_io_sem);
 			iput(vol_inode);
 			vol_inode = NULL;
 
@@ -375,22 +423,22 @@
 		}
 	}
 
-
 	/* free vol block */
 	if (free_vol_bits != NULL)
 		ocfs_free_vol_block(osb, handle, free_vol_bits, -1, 
 				    DISK_ALLOC_VOLUME);
 
-	/* We can potentiallly loose some allocation for dirNodes or extent */
-	/* nodes but they should not be much...  */
 	for (i = 0; i < osb->max_nodes; i++) {
-		if (free_ext_node[i] != NULL)
+		if (inode_alloc_free[i] != NULL)
 			ocfs_free_vol_block(osb, handle,
-					    free_ext_node[i], i,
+					    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);
 	}
 
-	/* release all locks */
 	if (free_vol_bits) {
 		ocfs2_dinode *bm_lock;
 
@@ -420,10 +468,12 @@
 	if (handle)
 		ocfs_abort_trans(handle);
 
-	if (free_vol_bits) {
+	if (vol_inode) {
+		down_write(&OCFS_I(vol_inode)->ip_io_sem);
 		status = ocfs_release_lock(osb, OCFS_DLM_EXCLUSIVE_LOCK,
 					   FLAG_FILE_CREATE, globalbh, 
 					   vol_inode);
+		up_write(&OCFS_I(vol_inode)->ip_io_sem);
 		if (status < 0) {
 			LOG_ERROR_STATUS (status);
 			goto finally;
@@ -431,45 +481,42 @@
 	}
 
 	for (i = 0; i < osb->max_nodes; i++) {
-		if (free_ext_node[i] != NULL) {
+		if (ext_alloc_free[i] != NULL) {
+			down_write(&OCFS_I(ext_alloc_inode[i])->ip_io_sem);
 			status = ocfs_release_lock (osb,
 						    OCFS_DLM_EXCLUSIVE_LOCK,
 						    FLAG_FILE_CREATE,
-						    NULL, extnode_inode[i]);
+						    NULL, ext_alloc_inode[i]);
+			up_write(&OCFS_I(ext_alloc_inode[i])->ip_io_sem);
 			if (status < 0) {
 				LOG_ERROR_STATUS (status);
 				goto finally;
 			}
 		}
-
 	}
 
 finally:
 
-	if (extnode_inode) {
+	if (ext_alloc_inode) {
 		for (i = 0; i < osb->max_nodes; i++) {
-			if (extnode_inode[i]) {
-				up_write(&OCFS_I(extnode_inode[i])->ip_io_sem);
-				iput(extnode_inode[i]);
-			}
+			if (ext_alloc_inode[i])
+				iput(ext_alloc_inode[i]);
 		}
-		kfree(extnode_inode);
+		kfree(ext_alloc_inode);
 	}
 
-	if (vol_inode) {
-		up_write(&OCFS_I(vol_inode)->ip_io_sem);
+	if (vol_inode)
 		iput(vol_inode);
-	}
 
 	if (globalbh)
 		brelse(globalbh);
 
-	if (free_ext_node) {
+	if (ext_alloc_free) {
 		for (i = 0; i < osb->max_nodes; i++) {
-			if (free_ext_node[i])
-				kfree(free_ext_node[i]);
+			if (ext_alloc_free[i])
+				kfree(ext_alloc_free[i]);
 		}
-		kfree(free_ext_node);
+		kfree(ext_alloc_free);
 	}
 
 	if (free_vol_bits)
@@ -580,6 +627,7 @@
 
 	ocfs_initialize_bitmap(osb->sb, &AllocBitmap, fileSize * 8,
 			       allocSize * 8);
+
 	tmpbitmap = &AllocBitmap;
 	bitmapblocks = ocfs_blocks_for_bits(osb->sb,
 					    tmpbitmap->validbits);

Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c	2004-06-19 01:18:48 UTC (rev 1154)
+++ trunk/src/inode.c	2004-06-19 01:23:25 UTC (rev 1155)
@@ -760,6 +760,15 @@
 
 	/* actually delete the data and the inode */
 	status = ocfs_free_file_extents(osb, fe_bh, handle, inode);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail_locked;
+	}
+
+	status = ocfs_handle_add_commit_bits(handle, 1,
+					     fe->i_suballoc_blkno << osb->sb->s_blocksize_bits,
+					     fe->i_suballoc_node,
+					     DISK_ALLOC_INODE);
 	if (status < 0)
 		LOG_ERROR_STATUS(status);
 



More information about the Ocfs2-commits mailing list