[Ocfs2-commits] mfasheh commits r2568 - branches/readonly-operation/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Sep 14 20:11:18 CDT 2005


Author: mfasheh
Date: 2005-09-14 20:11:11 -0500 (Wed, 14 Sep 2005)
New Revision: 2568

Modified:
   branches/readonly-operation/fs/ocfs2/alloc.c
   branches/readonly-operation/fs/ocfs2/dir.c
   branches/readonly-operation/fs/ocfs2/file.c
   branches/readonly-operation/fs/ocfs2/inode.c
   branches/readonly-operation/fs/ocfs2/journal.c
   branches/readonly-operation/fs/ocfs2/localalloc.c
   branches/readonly-operation/fs/ocfs2/namei.c
   branches/readonly-operation/fs/ocfs2/suballoc.c
Log:
* Instead of adding one more error condition for callers to guess at, have
  ocfs2_start_trans() return a ERR_PTR.  



Modified: branches/readonly-operation/fs/ocfs2/alloc.c
===================================================================
--- branches/readonly-operation/fs/ocfs2/alloc.c	2005-09-15 00:59:41 UTC (rev 2567)
+++ branches/readonly-operation/fs/ocfs2/alloc.c	2005-09-15 01:11:11 UTC (rev 2568)
@@ -1110,8 +1110,9 @@
 	}
 
 	handle = ocfs2_start_trans(osb, handle, OCFS2_TRUNCATE_LOG_UPDATE);
-	if (!handle) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto bail;
 	}
@@ -1319,8 +1320,8 @@
 
 		handle = ocfs2_start_trans(osb, NULL,
 					   OCFS2_TRUNCATE_LOG_UPDATE);
-		if (!handle) {
-			status = -ENOMEM;
+		if (IS_ERR(handle)) {
+			status = (int) PTR_ERR(handle);
 			mlog_errno(status);
 			goto bail_up;
 		}
@@ -1791,8 +1792,9 @@
 	credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del,
 						fe, el);
 	handle = ocfs2_start_trans(osb, NULL, credits);
-	if (!handle) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto bail;
 	}

Modified: branches/readonly-operation/fs/ocfs2/dir.c
===================================================================
--- branches/readonly-operation/fs/ocfs2/dir.c	2005-09-15 00:59:41 UTC (rev 2567)
+++ branches/readonly-operation/fs/ocfs2/dir.c	2005-09-15 01:11:11 UTC (rev 2568)
@@ -451,8 +451,9 @@
 	}
 
 	handle = ocfs2_start_trans(osb, handle, credits);
-	if (handle == NULL) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto bail;
 	}

Modified: branches/readonly-operation/fs/ocfs2/file.c
===================================================================
--- branches/readonly-operation/fs/ocfs2/file.c	2005-09-15 00:59:41 UTC (rev 2567)
+++ branches/readonly-operation/fs/ocfs2/file.c	2005-09-15 01:11:11 UTC (rev 2568)
@@ -434,30 +434,28 @@
 				     u64 new_i_size)
 {
 	int status;
-	ocfs2_journal_handle *handle = NULL;
+	ocfs2_journal_handle *handle;
 
 	mlog_entry_void();
 
-	/* TODO: This needs to actually orphen the inode in this
+	/* TODO: This needs to actually orphan the inode in this
 	 * transaction. */
 
-	handle = ocfs2_start_trans(osb, handle, OCFS2_INODE_UPDATE_CREDITS);
-	if (handle == NULL) {
-		status = -ENOMEM;
+	handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS);
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
 		mlog_errno(status);
-		goto bail;
+		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) {
+	if (status < 0)
 		mlog_errno(status);
-		goto bail;
-	}
-bail:
-	if (handle)
-		ocfs2_commit_trans(handle);
+
+	ocfs2_commit_trans(handle);
+out:
 	mlog_exit(status);
 	return status;
 }
@@ -522,8 +520,9 @@
 		 * this truncate. */
 		handle = ocfs2_start_trans(osb, NULL,
 					  OCFS2_INODE_UPDATE_CREDITS);
-		if (handle == NULL) {
-			status = -ENOMEM;
+		if (IS_ERR(handle)) {
+			status = (int) PTR_ERR(handle);
+			handle = NULL;
 			mlog_errno(status);
 			goto bail;
 		}
@@ -839,8 +838,9 @@
 do_start_trans:
 	credits = ocfs2_calc_extend_credits(osb->sb, fe, clusters_to_add);
 	handle = ocfs2_start_trans(osb, handle, credits);
-	if (handle == NULL) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto leave;
 	}
@@ -1074,7 +1074,8 @@
 	}
 
 	handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS);
-	if (handle == NULL) {
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
 		mlog_errno(status);
 		goto bail;
 	}
@@ -1090,18 +1091,16 @@
 	status = inode_setattr(inode, attr);
 	if (status < 0) {
 		mlog_errno(status);
-		goto bail;
+		goto bail_commit;
 	}
 
 	status = ocfs2_mark_inode_dirty(handle, inode, bh);
-	if (status < 0) {
+	if (status < 0)
 		mlog_errno(status);
-		goto bail;
-	}
 
+bail_commit:
+	ocfs2_commit_trans(handle);
 bail:
-	if (handle)
-		ocfs2_commit_trans(handle);
 	if (unlock)
 		ocfs2_meta_unlock(inode, 1);
 	if (bh)

Modified: branches/readonly-operation/fs/ocfs2/inode.c
===================================================================
--- branches/readonly-operation/fs/ocfs2/inode.c	2005-09-15 00:59:41 UTC (rev 2567)
+++ branches/readonly-operation/fs/ocfs2/inode.c	2005-09-15 01:11:11 UTC (rev 2568)
@@ -428,8 +428,9 @@
 		goto bail;
 
 	handle = ocfs2_start_trans(osb, handle, OCFS2_INODE_UPDATE_CREDITS);
-	if (handle == NULL) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto bail;
 	}
@@ -495,8 +496,8 @@
 	}
 
 	handle = ocfs2_start_trans(osb, NULL, OCFS2_DELETE_INODE_CREDITS);
-	if (handle == NULL) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
 		mlog_errno(status);
 		goto bail_unlock;
 	}

Modified: branches/readonly-operation/fs/ocfs2/journal.c
===================================================================
--- branches/readonly-operation/fs/ocfs2/journal.c	2005-09-15 00:59:41 UTC (rev 2567)
+++ branches/readonly-operation/fs/ocfs2/journal.c	2005-09-15 01:11:11 UTC (rev 2568)
@@ -137,12 +137,13 @@
 }
 
 /* pass it NULL and it will allocate a new handle object for you.  If
- * you pass it a handle however, it may still return NULL, in which
+ * you pass it a handle however, it may still return error, in which
  * case it has free'd the passed handle for you. */
 ocfs2_journal_handle *ocfs2_start_trans(ocfs2_super *osb,
 					ocfs2_journal_handle *handle,
 					int max_buffs)
 {
+	int ret;
 	journal_t *journal = osb->journal->j_journal;
 
 	mlog_entry("(max_buffs = %d)\n", max_buffs);
@@ -151,7 +152,7 @@
 		BUG();
 
 	if (ocfs2_is_hard_readonly(osb)) {
-		/* Ugh. Can't we just return ERR_PTR */
+		ret = -EROFS;
 		goto done_free;
 	}
 
@@ -167,6 +168,7 @@
 	if (!handle)
 		handle = ocfs2_alloc_handle(osb);
 	if (!handle) {
+		ret = -ENOMEM;
 		mlog(ML_ERROR, "Failed to allocate memory for journal "
 		     "handle!\n");
 		goto done_free;
@@ -181,9 +183,9 @@
 	if (IS_ERR(handle->k_handle)) {
 		up_read(&osb->journal->j_trans_barrier);
 
-		mlog(ML_ERROR, "journal_start() failed!\n");
-		mlog_errno((int)PTR_ERR(handle->k_handle));
+		ret = (int)PTR_ERR(handle->k_handle);
 		handle->k_handle = NULL;
+		mlog_errno(ret);
 		goto done_free;
 	}
 
@@ -194,12 +196,11 @@
 	return handle;
 
 done_free:
-
 	if (handle)
 		ocfs2_commit_unstarted_handle(handle); /* will kfree handle */
 
-	mlog_exit(NULL);
-	return NULL;
+	mlog_exit(ret);
+	return ERR_PTR(ret);
 }
 
 void ocfs2_handle_add_inode(ocfs2_journal_handle *handle,

Modified: branches/readonly-operation/fs/ocfs2/localalloc.c
===================================================================
--- branches/readonly-operation/fs/ocfs2/localalloc.c	2005-09-15 00:59:41 UTC (rev 2567)
+++ branches/readonly-operation/fs/ocfs2/localalloc.c	2005-09-15 01:11:11 UTC (rev 2568)
@@ -245,8 +245,9 @@
 
 	/* WINDOW_MOVE_CREDITS is a bit heavy... */
 	handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS);
-	if (!handle) {
-		mlog_errno(-ENOMEM);
+	if (IS_ERR(handle)) {
+		mlog_errno(PTR_ERR(handle));
+		handle = NULL;
 		goto bail;
 	}
 
@@ -413,8 +414,9 @@
 	}
 
 	handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS);
-	if (!handle) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto bail;
 	}
@@ -895,8 +897,9 @@
 	}
 
 	handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS);
-	if (!handle) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto bail;
 	}

Modified: branches/readonly-operation/fs/ocfs2/namei.c
===================================================================
--- branches/readonly-operation/fs/ocfs2/namei.c	2005-09-15 00:59:41 UTC (rev 2567)
+++ branches/readonly-operation/fs/ocfs2/namei.c	2005-09-15 01:11:11 UTC (rev 2568)
@@ -369,8 +369,9 @@
 	}
 
 	handle = ocfs2_start_trans(osb, handle, OCFS2_MKNOD_CREDITS);
-	if (handle == NULL) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto leave;
 	}
@@ -683,8 +684,10 @@
 	}
 
 	handle = ocfs2_start_trans(osb, handle, OCFS2_LINK_CREDITS);
-	if (handle == NULL) {
-		err = -ENOMEM;
+	if (IS_ERR(handle)) {
+		err = (int) PTR_ERR(handle);
+		handle = NULL;
+		mlog_errno(err);
 		goto bail;
 	}
 
@@ -846,8 +849,9 @@
 	}
 
 	handle = ocfs2_start_trans(osb, handle, OCFS2_UNLINK_CREDITS);
-	if (handle == NULL) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto leave;
 	}
@@ -1243,8 +1247,9 @@
 	}
 
 	handle = ocfs2_start_trans(osb, handle, OCFS2_RENAME_CREDITS);
-	if (handle == NULL) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto bail;
 	}
@@ -1600,8 +1605,9 @@
 	}
 
 	handle = ocfs2_start_trans(osb, handle, credits);
-	if (handle == NULL) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto bail;
 	}

Modified: branches/readonly-operation/fs/ocfs2/suballoc.c
===================================================================
--- branches/readonly-operation/fs/ocfs2/suballoc.c	2005-09-15 00:59:41 UTC (rev 2567)
+++ branches/readonly-operation/fs/ocfs2/suballoc.c	2005-09-15 01:11:11 UTC (rev 2568)
@@ -251,8 +251,9 @@
 	credits = ocfs2_calc_group_alloc_credits(osb->sb,
 						 le16_to_cpu(cl->cl_cpg));
 	handle = ocfs2_start_trans(osb, handle, credits);
-	if (!handle) {
-		status = -ENOMEM;
+	if (IS_ERR(handle)) {
+		status = (int) PTR_ERR(handle);
+		handle = NULL;
 		mlog_errno(status);
 		goto bail;
 	}



More information about the Ocfs2-commits mailing list