[Ocfs2-commits] mfasheh commits r2594 - trunk/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Sep 19 13:40:32 CDT 2005


Author: mfasheh
Signed-off-by: jlbec
Date: 2005-09-19 13:40:31 -0500 (Mon, 19 Sep 2005)
New Revision: 2594

Modified:
   trunk/fs/ocfs2/alloc.c
   trunk/fs/ocfs2/file.c
   trunk/fs/ocfs2/inode.c
   trunk/fs/ocfs2/journal.c
   trunk/fs/ocfs2/journal.h
Log:
* move the various calls of ocfs2_set_inode_lock_trans() into
  ocfs2_journal_access(). This is a better place because it's less error
  prone (as we will now never forget to do this) and is called right before    
  we dirty some metadata anyway.

* ocfs2_setattr() doesn't need to attach the lock to the handle, trivially  
  fix this.

Signed-off-by: jlbec



Modified: trunk/fs/ocfs2/alloc.c
===================================================================
--- trunk/fs/ocfs2/alloc.c	2005-09-17 05:16:28 UTC (rev 2593)
+++ trunk/fs/ocfs2/alloc.c	2005-09-19 18:40:31 UTC (rev 2594)
@@ -1864,14 +1864,6 @@
 		goto bail;
 	}
 
-	/* None of the cluster locks for a truncate are added
-	 * to the handle, so we update the last transaction
-	 * info manually. */
-	if (tc->tc_ext_alloc_inode)
-		ocfs2_set_inode_lock_trans(osb->journal,
-					   tc->tc_ext_alloc_inode);
-	ocfs2_set_inode_lock_trans(osb->journal, inode);
-
 	inode->i_ctime = inode->i_mtime = CURRENT_TIME;
 	status = ocfs2_mark_inode_dirty(handle, inode, fe_bh);
 	if (status < 0)

Modified: trunk/fs/ocfs2/file.c
===================================================================
--- trunk/fs/ocfs2/file.c	2005-09-17 05:16:28 UTC (rev 2593)
+++ trunk/fs/ocfs2/file.c	2005-09-19 18:40:31 UTC (rev 2594)
@@ -448,8 +448,6 @@
 		goto out;
 	}
 
-	ocfs2_set_inode_lock_trans(osb->journal, inode);
-
 	status = ocfs2_set_inode_size(handle, inode, fe_bh, new_i_size);
 	if (status < 0)
 		mlog_errno(status);
@@ -527,10 +525,6 @@
 			goto bail;
 		}
 
-		/* Since we got our cluster lock from caller and we
-		 * don't add it to the handle: */
-		ocfs2_set_inode_lock_trans(osb->journal, inode);
-
 		status = ocfs2_set_inode_size(handle, inode, fe_bh,
 					      new_i_size);
 		if (status < 0)
@@ -845,9 +839,6 @@
 		goto leave;
 	}
 
-	/* Since we got our cluster lock from caller and we don't add
-	 * it to the handle: */
-	ocfs2_set_inode_lock_trans(osb->journal, inode);
 restarted_transaction:
 	/* reserve a write to the file entry early on - that we if we
 	 * run out of credits in the allocation path, we can still
@@ -983,7 +974,6 @@
 int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
 {
 	int status = 0;
-	int unlock = 0;
 	u64 newsize, bytes_added;
 	struct inode *inode = dentry->d_inode;
 	struct super_block *sb = inode->i_sb;
@@ -1024,7 +1014,6 @@
 			mlog_errno(status);
 		goto bail;
 	}
-	unlock = 1;
 
 	if (S_ISREG(inode->i_mode) &&
 	    attr->ia_valid & ATTR_SIZE &&
@@ -1040,7 +1029,7 @@
 			if (status != -ENOSPC)
 				mlog_errno(status);
 			status = -ENOSPC;
-			goto bail;
+			goto bail_unlock;
 		}
 
 		/* partial extend, we continue with what we've got. */
@@ -1069,7 +1058,7 @@
 		status = ocfs2_zero_extend(inode);
 		if (status < 0) {
 			mlog_errno(status);
-			goto bail;
+			goto bail_unlock;
 		}
 	}
 
@@ -1077,17 +1066,9 @@
 	if (IS_ERR(handle)) {
 		status = PTR_ERR(handle);
 		mlog_errno(status);
-		goto bail;
+		goto bail_unlock;
 	}
 
-	/* Ok, this is the last transaction we'll do for a setattr so
-	 * just add our lock to the handle and let commit_trans deal
-	 * with it. */
-	status = ocfs2_handle_add_lock(handle, inode);
-	if (status < 0)
-		mlog_errno(status);
-	unlock = 0;
-
 	status = inode_setattr(inode, attr);
 	if (status < 0) {
 		mlog_errno(status);
@@ -1100,9 +1081,9 @@
 
 bail_commit:
 	ocfs2_commit_trans(handle);
+bail_unlock:
+	ocfs2_meta_unlock(inode, 1);
 bail:
-	if (unlock)
-		ocfs2_meta_unlock(inode, 1);
 	if (bh)
 		brelse(bh);
 

Modified: trunk/fs/ocfs2/inode.c
===================================================================
--- trunk/fs/ocfs2/inode.c	2005-09-17 05:16:28 UTC (rev 2593)
+++ trunk/fs/ocfs2/inode.c	2005-09-19 18:40:31 UTC (rev 2594)
@@ -435,8 +435,6 @@
 		goto bail;
 	}
 
-	ocfs2_set_inode_lock_trans(osb->journal, inode);
-
 	status = ocfs2_set_inode_size(handle, inode, fe_bh, 0ULL);
 	if (status < 0) {
 		mlog_errno(status);
@@ -502,14 +500,6 @@
 		goto bail_unlock;
 	}
 
-	ocfs2_set_inode_lock_trans(osb->journal, inode_alloc_inode);
-	ocfs2_set_inode_lock_trans(osb->journal, orphan_dir_inode);
-	/* Set the inode locking information, even though we're wiping
-	 * the inode - if we error before completing the wipe, we'll
-	 * want to checkpoint our progress so other nodes get an
-	 * up-to-date picture. */
-	ocfs2_set_inode_lock_trans(osb->journal, inode);
-
 	status = ocfs2_orphan_del(osb, handle, orphan_dir_inode, inode,
 				  orphan_dir_bh);
 	if (status < 0) {

Modified: trunk/fs/ocfs2/journal.c
===================================================================
--- trunk/fs/ocfs2/journal.c	2005-09-17 05:16:28 UTC (rev 2593)
+++ trunk/fs/ocfs2/journal.c	2005-09-19 18:40:31 UTC (rev 2594)
@@ -58,8 +58,7 @@
 static int ocfs2_commit_cache(ocfs2_super *osb);
 static int ocfs2_wait_on_mount(ocfs2_super *osb);
 static void ocfs2_handle_cleanup_locks(ocfs2_journal *journal,
-				      ocfs2_journal_handle *handle,
-				      int set_id);
+				       ocfs2_journal_handle *handle);
 static void ocfs2_commit_unstarted_handle(ocfs2_journal_handle *handle);
 static int ocfs2_journal_toggle_dirty(ocfs2_super *osb,
 				     int dirty);
@@ -258,7 +257,7 @@
 	ocfs2_handle_unlock_inodes(handle);
 	/* You are allowed to add journal locks before the transaction
 	 * has started. */
-	ocfs2_handle_cleanup_locks(handle->journal, handle, 0);
+	ocfs2_handle_cleanup_locks(handle->journal, handle);
 
 	kfree(handle);
 
@@ -308,7 +307,7 @@
 		handle->k_handle = NULL; /* it's been free'd in journal_stop */
 	}
 
-	ocfs2_handle_cleanup_locks(journal, handle, 1);
+	ocfs2_handle_cleanup_locks(journal, handle);
 
 	up_read(&journal->j_trans_barrier);
 
@@ -394,6 +393,14 @@
 		BUG();
 	}
 
+	/* Set the current transaction information on the inode so
+	 * that the locking code knows whether it can drop it's locks
+	 * on this inode or not. We're protected from the commit
+	 * thread updating the current transaction id until
+	 * ocfs2_commit_trans() because ocfs2_start_trans() took
+	 * j_trans_barrier for us. */
+	ocfs2_set_inode_lock_trans(OCFS2_SB(inode->i_sb)->journal, inode);
+
 	down(&OCFS2_I(inode)->ip_io_sem);
 	switch (type) {
 	case OCFS2_JOURNAL_ACCESS_CREATE:
@@ -469,8 +476,7 @@
 }
 
 static void ocfs2_handle_cleanup_locks(ocfs2_journal *journal,
-				       ocfs2_journal_handle *handle,
-				       int set_id)
+				       ocfs2_journal_handle *handle)
 {
 	struct list_head *p, *n;
 	ocfs2_journal_lock *lock;
@@ -482,8 +488,6 @@
 		handle->num_locks--;
 
 		inode = lock->jl_inode;
-		if (set_id)
-			ocfs2_set_inode_lock_trans(journal, inode);
 		ocfs2_meta_unlock(inode, 1);
 		if (atomic_read(&inode->i_count) == 1)
 			mlog(ML_ERROR,

Modified: trunk/fs/ocfs2/journal.h
===================================================================
--- trunk/fs/ocfs2/journal.h	2005-09-17 05:16:28 UTC (rev 2593)
+++ trunk/fs/ocfs2/journal.h	2005-09-19 18:40:31 UTC (rev 2594)
@@ -77,7 +77,7 @@
 	unsigned long old_id;
 	spin_lock(&trans_inc_lock);
 	old_id = j->j_trans_id++;
-	if (!j->j_trans_id)
+	if (unlikely(!j->j_trans_id))
 		j->j_trans_id = 1;
 	spin_unlock(&trans_inc_lock);
 	return old_id;



More information about the Ocfs2-commits mailing list