[Ocfs2-commits] mfasheh commits r2755 - in branches/ocfs2-1.2: . fs/ocfs2 kapi-compat/include

svn-commits@oss.oracle.com svn-commits at oss.oracle.com
Mon Jan 23 13:10:55 CST 2006


Author: mfasheh
Signed-off-by: jlbec
Date: 2006-01-23 13:10:52 -0600 (Mon, 23 Jan 2006)
New Revision: 2755

Added:
   branches/ocfs2-1.2/kapi-compat/include/i_mutex.h
Modified:
   branches/ocfs2-1.2/Config.make.in
   branches/ocfs2-1.2/configure.in
   branches/ocfs2-1.2/fs/ocfs2/aio.c
   branches/ocfs2-1.2/fs/ocfs2/alloc.c
   branches/ocfs2-1.2/fs/ocfs2/dir.c
   branches/ocfs2-1.2/fs/ocfs2/file.c
   branches/ocfs2-1.2/fs/ocfs2/inode.c
   branches/ocfs2-1.2/fs/ocfs2/journal.c
   branches/ocfs2-1.2/fs/ocfs2/localalloc.c
   branches/ocfs2-1.2/fs/ocfs2/mmap.c
   branches/ocfs2-1.2/fs/ocfs2/mmap.h
Log:
* i_sem -> i_mutex conversion for forwards compatibility.

Signed-off-by: jlbec



Modified: branches/ocfs2-1.2/Config.make.in
===================================================================
--- branches/ocfs2-1.2/Config.make.in	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/Config.make.in	2006-01-23 19:10:52 UTC (rev 2755)
@@ -58,6 +58,7 @@
 HAVE_SPARSE_ENDIAN_TYPES = @HAVE_SPARSE_ENDIAN_TYPES@
 HAVE_GENERIC_READLINK = @HAVE_GENERIC_READLINK@
 NEW_FOLLOW_LINK_API = @NEW_FOLLOW_LINK_API@
+HAS_MUTEX_API = @HAS_MUTEX_API@
 
 BUILD_DEBUGFS_BACKPORT = @BUILD_DEBUGFS_BACKPORT@
 

Modified: branches/ocfs2-1.2/configure.in
===================================================================
--- branches/ocfs2-1.2/configure.in	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/configure.in	2006-01-23 19:10:52 UTC (rev 2755)
@@ -279,6 +279,11 @@
   NEW_FOLLOW_LINK_API=yes, , [void \* (\*follow_link)])
 AC_SUBST(NEW_FOLLOW_LINK_API)
 
+kref_compat_header=""
+OCFS2_CHECK_KERNEL([for mutex API], mutex.h,
+  , kref_compat_header="i_mutex.h", [mutex_lock])
+KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $kref_compat_header"
+
 # using -include has two advantages:
 #  the source doesn't need to know to include compat headers
 #  the compat header file names don't go through the search path

Modified: branches/ocfs2-1.2/fs/ocfs2/aio.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/aio.c	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/fs/ocfs2/aio.c	2006-01-23 19:10:52 UTC (rev 2755)
@@ -363,14 +363,14 @@
 
 up_io:
 	/*
-	 * never hold i_sem when we leave this function, nor when we call
+	 * never hold i_mutex when we leave this function, nor when we call
 	 * g_f_a_w().  we've done all extending and inode field updating under
-	 * the i_sem and we hold the ip_alloc_sem for reading across the ops.
+	 * the i_mutex and we hold the ip_alloc_sem for reading across the ops.
 	 * ocfs2_direct_IO calls blockdev_direct_IO with NO_LOCKING.
 	 */
-	if (okp->kp_info.wl_have_i_sem) {
-		up(&inode->i_sem);
-		okp->kp_info.wl_have_i_sem = 0;
+	if (okp->kp_info.wl_have_i_mutex) {
+		mutex_unlock(&inode->i_mutex);
+		okp->kp_info.wl_have_i_mutex = 0;
 	}
 	if (ret == 0)
 		ret = generic_file_aio_write_nolock(iocb, &local_iov, 1,

Modified: branches/ocfs2-1.2/fs/ocfs2/alloc.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/alloc.c	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/fs/ocfs2/alloc.c	2006-01-23 19:10:52 UTC (rev 2755)
@@ -964,7 +964,7 @@
 	mlog_entry("start_blk = %"MLFu64", num_clusters = %u\n", start_blk,
 		   num_clusters);
 
-	BUG_ON(!down_trylock(&tl_inode->i_sem));
+	BUG_ON(mutex_trylock(&tl_inode->i_mutex));
 
 	start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk);
 
@@ -1106,7 +1106,7 @@
 	return status;
 }
 
-/* Expects you to already be holding tl_inode->i_sem */
+/* Expects you to already be holding tl_inode->i_mutex */
 static int __ocfs2_flush_truncate_log(ocfs2_super *osb)
 {
 	int status;
@@ -1121,7 +1121,7 @@
 
 	mlog_entry_void();
 
-	BUG_ON(!down_trylock(&tl_inode->i_sem));
+	BUG_ON(mutex_trylock(&tl_inode->i_mutex));
 
 	di = (ocfs2_dinode *) tl_bh->b_data;
 	tl = &di->id2.i_dealloc;
@@ -1196,9 +1196,9 @@
 	int status;
 	struct inode *tl_inode = osb->osb_tl_inode;
 
-	down(&tl_inode->i_sem);
+	mutex_lock(&tl_inode->i_mutex);
 	status = __ocfs2_flush_truncate_log(osb);
-	up(&tl_inode->i_sem);
+	mutex_unlock(&tl_inode->i_mutex);
 
 	return status;
 }
@@ -1361,7 +1361,7 @@
 	mlog(0, "cleanup %u records from %"MLFu64"\n", num_recs,
 	     tl_copy->i_blkno);
 
-	down(&tl_inode->i_sem);
+	mutex_lock(&tl_inode->i_mutex);
 	for(i = 0; i < num_recs; i++) {
 		if (ocfs2_truncate_log_needs_flush(osb)) {
 			status = __ocfs2_flush_truncate_log(osb);
@@ -1393,7 +1393,7 @@
 	}
 
 bail_up:
-	up(&tl_inode->i_sem);
+	mutex_unlock(&tl_inode->i_mutex);
 
 	mlog_exit(status);
 	return status;
@@ -1838,7 +1838,7 @@
 
 	mlog(0, "clusters_to_del = %u in this pass\n", clusters_to_del);
 
-	down(&tl_inode->i_sem);
+	mutex_lock(&tl_inode->i_mutex);
 	tl_sem = 1;
 	/* ocfs2_truncate_log_needs_flush guarantees us at least one
 	 * record is free for use. If there isn't any, we flush to get
@@ -1873,7 +1873,7 @@
 		goto bail;
 	}
 
-	up(&tl_inode->i_sem);
+	mutex_unlock(&tl_inode->i_mutex);
 	tl_sem = 0;
 
 	ocfs2_commit_trans(handle);
@@ -1888,7 +1888,7 @@
 	ocfs2_schedule_truncate_log_flush(osb, 1);
 
 	if (tl_sem)
-		up(&tl_inode->i_sem);
+		mutex_unlock(&tl_inode->i_mutex);
 
 	if (handle)
 		ocfs2_commit_trans(handle);
@@ -1992,7 +1992,7 @@
 			goto bail;
 		}
 
-		down(&ext_alloc_inode->i_sem);
+		mutex_lock(&ext_alloc_inode->i_mutex);
 		(*tc)->tc_ext_alloc_inode = ext_alloc_inode;
 
 		status = ocfs2_meta_lock(ext_alloc_inode,
@@ -2024,7 +2024,7 @@
 		if (tc->tc_ext_alloc_locked)
 			ocfs2_meta_unlock(tc->tc_ext_alloc_inode, 1);
 
-		up(&tc->tc_ext_alloc_inode->i_sem);
+		mutex_unlock(&tc->tc_ext_alloc_inode->i_mutex);
 		iput(tc->tc_ext_alloc_inode);
 	}
 

Modified: branches/ocfs2-1.2/fs/ocfs2/dir.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/dir.c	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/fs/ocfs2/dir.c	2006-01-23 19:10:52 UTC (rev 2755)
@@ -202,7 +202,7 @@
 }
 
 /*
- * NOTE: this should always be called with parent dir i_sem taken.
+ * NOTE: this should always be called with parent dir i_mutex taken.
  */
 int ocfs2_find_files_on_disk(const char *name,
 			     int namelen,
@@ -245,7 +245,7 @@
  * Return 0 if the name does not exist
  * Return -EEXIST if the directory contains the name
  *
- * Callers should have i_sem + a cluster lock on dir
+ * Callers should have i_mutex + a cluster lock on dir
  */
 int ocfs2_check_dir_for_entry(struct inode *dir,
 			      const char *name,

Modified: branches/ocfs2-1.2/fs/ocfs2/file.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/file.c	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/fs/ocfs2/file.c	2006-01-23 19:10:52 UTC (rev 2755)
@@ -253,8 +253,8 @@
 					    info.wl_do_direct_io);
 	if (info.wl_unlock_ctxt)
 		ocfs2_unlock_buffer_inodes(&ctxt);
-	if (info.wl_have_i_sem)
-		up(&inode->i_sem);
+	if (info.wl_have_i_mutex)
+		mutex_unlock(&inode->i_mutex);
 	mlog_exit(ret);
 
 	return ret;
@@ -833,7 +833,7 @@
 	}
 
 	/* blocks peope in read/write from reading our allocation
-	 * until we're done changing it. We depend on i_sem to block
+	 * until we're done changing it. We depend on i_mutex to block
 	 * other extend/truncate calls while we're here. Ordering wrt
 	 * start_trans is important here -- always do it before! */
 	down_write(&OCFS2_I(inode)->ip_alloc_sem);

Modified: branches/ocfs2-1.2/fs/ocfs2/inode.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/inode.c	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/fs/ocfs2/inode.c	2006-01-23 19:10:52 UTC (rev 2755)
@@ -484,10 +484,10 @@
 		goto bail;
 	}
 
-	down(&inode_alloc_inode->i_sem);
+	mutex_lock(&inode_alloc_inode->i_mutex);
 	status = ocfs2_meta_lock(inode_alloc_inode, NULL, &inode_alloc_bh, 1);
 	if (status < 0) {
-		up(&inode_alloc_inode->i_sem);
+		mutex_unlock(&inode_alloc_inode->i_mutex);
 
 		mlog_errno(status);
 		goto bail;
@@ -535,7 +535,7 @@
 	ocfs2_commit_trans(handle);
 bail_unlock:
 	ocfs2_meta_unlock(inode_alloc_inode, 1);
-	up(&inode_alloc_inode->i_sem);
+	mutex_unlock(&inode_alloc_inode->i_mutex);
 	brelse(inode_alloc_bh);
 bail:
 	iput(inode_alloc_inode);
@@ -566,10 +566,10 @@
 	/* Lock the orphan dir. The lock will be held for the entire
 	 * delete_inode operation. We do this now to avoid races with
 	 * recovery completion on other nodes. */
-	down(&orphan_dir_inode->i_sem);
+	mutex_lock(&orphan_dir_inode->i_mutex);
 	status = ocfs2_meta_lock(orphan_dir_inode, NULL, &orphan_dir_bh, 1);
 	if (status < 0) {
-		up(&orphan_dir_inode->i_sem);
+		mutex_unlock(&orphan_dir_inode->i_mutex);
 
 		mlog_errno(status);
 		goto bail;
@@ -592,7 +592,7 @@
 
 bail_unlock_dir:
 	ocfs2_meta_unlock(orphan_dir_inode, 1);
-	up(&orphan_dir_inode->i_sem);
+	mutex_unlock(&orphan_dir_inode->i_mutex);
 	brelse(orphan_dir_bh);
 bail:
 	iput(orphan_dir_inode);

Modified: branches/ocfs2-1.2/fs/ocfs2/journal.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/journal.c	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/fs/ocfs2/journal.c	2006-01-23 19:10:52 UTC (rev 2755)
@@ -216,7 +216,7 @@
 	atomic_inc(&inode->i_count);
 
 	/* we're obviously changing it... */
-	down(&inode->i_sem);
+	mutex_lock(&inode->i_mutex);
 
 	/* sanity check */
 	BUG_ON(OCFS2_I(inode)->ip_handle);
@@ -241,7 +241,7 @@
 		OCFS2_I(inode)->ip_handle = NULL;
 		list_del_init(&OCFS2_I(inode)->ip_handle_list);
 
-		up(&inode->i_sem);
+		mutex_unlock(&inode->i_mutex);
 		iput(inode);
 	}
 }
@@ -1424,10 +1424,10 @@
 		goto out;
 	}
 
-	down(&orphan_dir_inode->i_sem);
+	mutex_lock(&orphan_dir_inode->i_mutex);
 	status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0);
 	if (status < 0) {
-		up(&orphan_dir_inode->i_sem);
+		mutex_unlock(&orphan_dir_inode->i_mutex);
 		mlog_errno(status);
 		goto out;
 	}
@@ -1442,7 +1442,7 @@
 		if (!bh)
 			status = -EINVAL;
 		if (status < 0) {
-			up(&orphan_dir_inode->i_sem);
+			mutex_unlock(&orphan_dir_inode->i_mutex);
 			if (bh)
 				brelse(bh);
 			mlog_errno(status);
@@ -1456,7 +1456,7 @@
 
 			if (!ocfs2_check_dir_entry(orphan_dir_inode,
 						  de, bh, local)) {
-				up(&orphan_dir_inode->i_sem);
+				mutex_unlock(&orphan_dir_inode->i_mutex);
 				status = -EINVAL;
 				mlog_errno(status);
 				brelse(bh);
@@ -1500,7 +1500,7 @@
 		}
 		brelse(bh);
 	}
-	up(&orphan_dir_inode->i_sem);
+	mutex_unlock(&orphan_dir_inode->i_mutex);
 
 	ocfs2_meta_unlock(orphan_dir_inode, 0);
 	have_disk_lock = 0;

Modified: branches/ocfs2-1.2/fs/ocfs2/localalloc.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/localalloc.c	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/fs/ocfs2/localalloc.c	2006-01-23 19:10:52 UTC (rev 2755)
@@ -334,7 +334,7 @@
 		goto bail;
 	}
 
-	down(&inode->i_sem);
+	mutex_lock(&inode->i_mutex);
 
 	status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno,
 				  &alloc_bh, 0, inode);
@@ -367,7 +367,7 @@
 		brelse(alloc_bh);
 
 	if (inode) {
-		up(&inode->i_sem);
+		mutex_unlock(&inode->i_mutex);
 		iput(inode);
 	}
 
@@ -446,7 +446,7 @@
 
 /*
  * make sure we've got at least bitswanted contiguous bits in the
- * local alloc. You lose them when you drop i_sem.
+ * local alloc. You lose them when you drop i_mutex.
  *
  * We will add ourselves to the transaction passed in, but may start
  * our own in order to shift windows.

Modified: branches/ocfs2-1.2/fs/ocfs2/mmap.c
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/mmap.c	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/fs/ocfs2/mmap.c	2006-01-23 19:10:52 UTC (rev 2755)
@@ -511,7 +511,7 @@
  * This builds up the locking state that will be used by a write.  both normal
  * file writes and AIO writes come in through here.  This function does no
  * teardown on its own.  The caller must examine the info struct to see if it
- * needs to release locks or i_sem, etc.  This function is also restartable in
+ * needs to release locks or i_mutex, etc.  This function is also restartable in
  * that it can return EIOCBRETRY if it would have blocked in the dlm.  It
  * stores its partial progress in the info struct so the caller can call back
  * in when it thinks the dlm won't block any more.  Thus, the caller must zero
@@ -565,9 +565,9 @@
 		info->wl_target_binode->ba_lock_data_level = 1;
 	}
 
-	if (!info->wl_have_i_sem) {
-		down(&inode->i_sem);
-		info->wl_have_i_sem = 1;
+	if (!info->wl_have_i_mutex) {
+		mutex_lock(&inode->i_mutex);
+		info->wl_have_i_mutex = 1;
 	}
 
 lock:

Modified: branches/ocfs2-1.2/fs/ocfs2/mmap.h
===================================================================
--- branches/ocfs2-1.2/fs/ocfs2/mmap.h	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/fs/ocfs2/mmap.h	2006-01-23 19:10:52 UTC (rev 2755)
@@ -113,7 +113,7 @@
 	u64				wl_newsize;
 	unsigned			wl_extended:1,
 					wl_do_direct_io:1,
-					wl_have_i_sem:1,
+					wl_have_i_mutex:1,
 					wl_unlock_ctxt:1,
 					wl_have_before:1,
 					wl_have_target_meta:1,

Added: branches/ocfs2-1.2/kapi-compat/include/i_mutex.h
===================================================================
--- branches/ocfs2-1.2/kapi-compat/include/i_mutex.h	2006-01-19 01:06:53 UTC (rev 2754)
+++ branches/ocfs2-1.2/kapi-compat/include/i_mutex.h	2006-01-23 19:10:52 UTC (rev 2755)
@@ -0,0 +1,10 @@
+#ifndef KAPI_IMUTEX_H
+#define KAPI_IMUTEX_H
+
+#define mutex_lock down
+#define mutex_unlock up
+#define mutex_trylock(__m) (!down_trylock(__m))
+
+#define i_mutex i_sem
+
+#endif /* KAPI_IMUTEX_H */



More information about the Ocfs2-commits mailing list