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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Sep 27 17:59:02 CDT 2004


Author: mfasheh
Date: 2004-09-27 17:59:00 -0500 (Mon, 27 Sep 2004)
New Revision: 1498

Modified:
   branches/dlm-changes/src/inode.c
   branches/dlm-changes/src/ocfs_journal.h
Log:
* delete_inode fixes:
  -fix dlm lock / trans ordering
  -free bits from the inode suballocator
  -remove the BKL usage altogether
  -mark this trans. as always commits



Modified: branches/dlm-changes/src/inode.c
===================================================================
--- branches/dlm-changes/src/inode.c	2004-09-27 22:55:09 UTC (rev 1497)
+++ branches/dlm-changes/src/inode.c	2004-09-27 22:59:00 UTC (rev 1498)
@@ -47,6 +47,7 @@
 #include "inode.h"
 #include "lockres.h"
 #include "namei.h"
+#include "suballoc.h"
 #include "super.h"
 #include "symlink.h"
 #include "sysfile.h"
@@ -537,10 +538,12 @@
 void ocfs_delete_inode(struct inode *inode)
 {
 	struct inode *orphan_dir_inode = NULL;
+	struct inode *inode_alloc_inode = NULL;
 	ocfs_journal_handle *handle = NULL;
 	ocfs_super *osb = OCFS_SB(inode->i_sb);
 	int status = 0;
 	struct buffer_head *orphan_dir_bh = NULL;
+	struct buffer_head *inode_alloc_bh = NULL;
 	struct buffer_head *fe_bh = NULL;
 	ocfs2_dinode *fe;
 
@@ -550,18 +553,18 @@
 
 	if (OCFS_I(inode)->ip_flags & OCFS_INODE_SYSTEM_FILE) {
 		LOG_TRACE_STR("Skipping system file delete.");
-		goto clear_inode;
+		goto bail;
 	}
 
 	if (inode == osb->root_inode) {
 		LOG_TRACE_STR("Skipping root inode delete.");
-		goto clear_inode;
+		goto bail;
 	}
 
 	if (OCFS_I(inode)->ip_flags & OCFS_INODE_SKIP_DELETE) {
 		LOG_TRACE_ARGS("Skipping delete of %lu because another node "
 			       "has done this for us.\n", inode->i_ino);
-		goto clear_inode;
+		goto bail;
 	}
 
 	/* If we're coming from process_vote we can't go into our own
@@ -572,17 +575,9 @@
 	if (osb->voting_ino == inode->i_ino) {
 		LOG_TRACE_ARGS("Skipping delete of %lu because we're currently"
 			       "in process_vote\n", inode->i_ino);
-		goto clear_inode;
+		goto bail;
 	}
 
-	orphan_dir_inode = ocfs_get_system_file_inode(osb, 
-						      ORPHAN_DIR_SYSTEM_INODE, 
-						      -1);
-	if (!orphan_dir_inode) {
-		LOG_ERROR_STATUS(-EFAIL);
-		goto clear_inode;
-	}
-
 	/* acquire_lock and friends will igrab / iput this guy, so we
 	 * take an extra ref. to avoid recursive calls to
 	 * delete_inode. */
@@ -597,7 +592,7 @@
 		 * about deleting it. */
 		if (status != -EBUSY)
 			LOG_ERROR_STATUS(status);
-		goto clear_inode;
+		goto bail;
 	}
 
 	fe = (ocfs2_dinode *) fe_bh->b_data;
@@ -605,51 +600,84 @@
 		/* for lack of a better error? */
 		status = -EEXIST;
 		LOG_ERROR_STATUS(status);
-		goto clear_inode;
+		goto bail;
 	}
 
 	/* has someone already deleted us?! baaad... */
 	if (fe->i_dtime) {
 		status = -EEXIST;
 		LOG_ERROR_STATUS(status);
-		goto clear_inode;
+		goto bail;
 	}
 
 	if (fe->i_links_count) {
 		status = -EBUSY;
 		LOG_ERROR_STATUS(status);
-		goto clear_inode;
+		goto bail;
 	}
 
 	/* Oop, lets be carefull of lock / trans ordering here... */
-	handle = ocfs_start_trans(osb, NULL, OCFS_FILE_DELETE_CREDITS);
+	handle = ocfs_alloc_handle(osb);
 	if (handle == NULL) {
-		unlock_kernel();
-		LOG_ERROR_STATUS(-ENOMEM);
-		goto clear_inode;
+		status = -ENOMEM;
+		LOG_ERROR_STATUS(status);
+		goto bail;
 	}
 
-#warning "is BKL really necessary here? lets get rid of it for now."
-//	lock_kernel();
-
+	orphan_dir_inode = ocfs_get_system_file_inode(osb, 
+						      ORPHAN_DIR_SYSTEM_INODE, 
+						      -1);
+	if (!orphan_dir_inode) {
+		status = -EEXIST;
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
 	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0,
 				   &orphan_dir_bh, orphan_dir_inode);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
-		goto bail_locked;
+		goto bail;
 	}
 	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0,
 			     orphan_dir_inode);
 	ocfs_handle_add_inode(handle, orphan_dir_inode);
 
+	inode_alloc_inode = ocfs_get_system_file_inode(osb, INODE_ALLOC_BITMAP_SYSTEM_INODE, fe->i_suballoc_node);
+	if (!inode_alloc_inode) {
+		status = -EEXIST;
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0,
+				   &inode_alloc_bh, inode_alloc_inode);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0,
+			     inode_alloc_inode);
+	ocfs_handle_add_inode(handle, inode_alloc_inode);
+
+	handle = ocfs_start_trans(osb, handle, OCFS_FILE_DELETE_CREDITS);
+	if (handle == NULL) {
+		status = -ENOMEM;
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+	ocfs_handle_set_always_commits(handle, 1);
+
 	status = ocfs_orphan_del(osb, handle, orphan_dir_inode, inode, 
 				 orphan_dir_bh);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
 
 	/* set the inodes dtime */
 	status = ocfs_journal_access(handle, fe_bh, OCFS_JOURNAL_ACCESS_WRITE);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
-		goto bail_locked;
+		goto bail;
 	}
 
 	fe->i_dtime = OCFS_CURRENT_TIME;
@@ -658,40 +686,35 @@
 	status = ocfs_journal_dirty(handle, fe_bh);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
-		goto bail_locked;
+		goto bail;
 	}
 
-	/* actually delete the data and the inode */
-	status = ocfs_free_file_extents(osb, fe_bh, handle, inode);
+	status = ocfs_free_suballoc_bits(osb, handle, inode_alloc_inode,
+					 inode_alloc_bh, fe->i_suballoc_bit,
+					 fe->i_blkno, 1);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
-		goto bail_locked;
+		goto bail;
 	}
 
-#warning "need to delete inodes here!"
-#warning "when this is added, just make it a part of the current transaction."
-//	status = ocfs_handle_add_commit_bits(handle, 1,
-//					     fe->i_suballoc_blkno << osb->sb->s_blocksize_bits,
-//					     fe->i_suballoc_node,
-//					     DISK_ALLOC_INODE);
+	/* actually delete the data and the inode */
+	status = ocfs_free_file_extents(osb, fe_bh, handle, inode);
 	if (status < 0)
 		LOG_ERROR_STATUS(status);
 
-bail_locked:
-	if (handle && (status == 0))
+bail:
+	if (handle)
 		ocfs_commit_trans(handle);
-	else if (handle)
-		ocfs_abort_trans(handle);
-
-//	unlock_kernel();
-
-clear_inode:
 	if (orphan_dir_bh)
 		brelse(orphan_dir_bh);
+	if (inode_alloc_bh)
+		brelse(inode_alloc_bh);
 	if (fe_bh)
 		brelse(fe_bh);
 	if (orphan_dir_inode)
 		iput(orphan_dir_inode);
+	if (inode_alloc_inode)
+		iput(inode_alloc_inode);
 
 	/* we must clear inode. */
 	clear_inode(inode);

Modified: branches/dlm-changes/src/ocfs_journal.h
===================================================================
--- branches/dlm-changes/src/ocfs_journal.h	2004-09-27 22:55:09 UTC (rev 1497)
+++ branches/dlm-changes/src/ocfs_journal.h	2004-09-27 22:59:00 UTC (rev 1498)
@@ -467,7 +467,7 @@
 
 /* the file entry + the locknode + possibily the parent dirnode + fuzz */
 /* ok, these credits are messed up and need to be re calculated. */
-#define OCFS_FILE_DELETE_CREDITS  (1 + 1 + 1 + OCFS_JOURNAL_FUZZ_CREDITS)
+#define OCFS_FILE_DELETE_CREDITS  (2 + 1 + 1 + 1 + OCFS_JOURNAL_FUZZ_CREDITS)
 
 /* fe change, locknode change, dirnode head, times two plus a possible
  * delete, plus a possible dirnode addition in insert_file, and fuzz */



More information about the Ocfs2-commits mailing list