[Ocfs2-commits] mfasheh commits r1592 - branches/dlm-glue/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Oct 25 20:03:27 CDT 2004


Author: mfasheh
Date: 2004-10-25 20:03:25 -0500 (Mon, 25 Oct 2004)
New Revision: 1592

Modified:
   branches/dlm-glue/src/alloc.c
   branches/dlm-glue/src/aops.c
   branches/dlm-glue/src/dcache.c
   branches/dlm-glue/src/dir.c
   branches/dlm-glue/src/file.c
   branches/dlm-glue/src/inode.c
   branches/dlm-glue/src/inode.h
   branches/dlm-glue/src/journal.c
   branches/dlm-glue/src/localalloc.c
   branches/dlm-glue/src/namei.c
   branches/dlm-glue/src/ocfs.h
   branches/dlm-glue/src/ocfs_journal.h
   branches/dlm-glue/src/suballoc.c
   branches/dlm-glue/src/super.c
Log:
* start adding my changes. Previously, this was up to date with svn
  revision 1590



Modified: branches/dlm-glue/src/alloc.c
===================================================================
--- branches/dlm-glue/src/alloc.c	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/alloc.c	2004-10-26 01:03:25 UTC (rev 1592)
@@ -1183,15 +1183,12 @@
 	}
 
 	ocfs_handle_add_inode(handle, bitmap_inode);
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 
-				   0, &bh, bitmap_inode);
+	status = ocfs2_meta_lock(bitmap_inode, handle, &bh, 1);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STATUS (status);
 		goto bail;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
-			     0, bitmap_inode);
 
 	fe = (ocfs2_dinode *) bh->b_data;
 	free_bits = le32_to_cpu(fe->id1.bitmap1.i_total) - 
@@ -1528,12 +1525,16 @@
 
 	down_write(&OCFS_I(inode)->ip_alloc_sem);
 
+	target_i_clusters = ocfs2_clusters_for_bytes(osb->sb,
+						     inode->i_size);
+
+	/* the extent map gets truncated in ocfs_do_truncate */
+	ocfs2_lvb_set_trunc_clusters(inode, target_i_clusters);
+
 	last_eb_bh = tc->tc_last_eb_bh;
 	tc->tc_last_eb_bh = NULL;
 	handle = tc->tc_handle;
 
-	target_i_clusters = ocfs2_clusters_for_bytes(osb->sb,
-						     inode->i_size);
 	fe = (ocfs2_dinode *) fe_bh->b_data;
 
 	if (fe->id2.i_list.l_tree_depth) {
@@ -1704,15 +1705,15 @@
 		}
 
 		ocfs_handle_add_inode(handle, ext_alloc_inode);
-		status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0, 
-					   &ext_alloc_bh, ext_alloc_inode);
+		status = ocfs2_meta_lock(ext_alloc_inode,
+					handle,
+					&ext_alloc_bh,
+					1);
 		if (status < 0) {
 			if (status != -EINTR)
 				LOG_ERROR_STATUS (status);
 			goto bail;
 		}
-		ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
-				     0, ext_alloc_inode);
 	}
 
 	data_alloc_inode = ocfs_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, -1);
@@ -1723,15 +1724,12 @@
 	}
 
 	ocfs_handle_add_inode(handle, data_alloc_inode);
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 
-				   0, &data_alloc_bh, data_alloc_inode);
+	status = ocfs2_meta_lock(data_alloc_inode, handle, &data_alloc_bh, 1);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STATUS (status);
 		goto bail;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
-			     0, data_alloc_inode);
 
 	(*tc)->tc_bitmap_inode    = data_alloc_inode;
 	(*tc)->tc_bitmap_bh       = data_alloc_bh;

Modified: branches/dlm-glue/src/aops.c
===================================================================
--- branches/dlm-glue/src/aops.c	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/aops.c	2004-10-26 01:03:25 UTC (rev 1592)
@@ -130,7 +130,6 @@
 	int err = -EIO;
 	u64 vbo = 0;
 	u64 p_blkno;
-	int open_direct;
 
 	LOG_ENTRY_ARGS("(0x%p, %llu, 0x%p, %d)\n", inode,
 			(unsigned long long)iblock, bh_result, create);
@@ -140,8 +139,6 @@
 		       inode, inode->i_ino);
 	}
 
-	open_direct = OCFS_I(inode)->ip_open_flags & OCFS_OIN_OPEN_FOR_DIRECTIO;
-
 	if (S_ISLNK(inode->i_mode)) {
 		/* this always does I/O for some reason. */
 		err = ocfs_symlink_get_block (inode, iblock, bh_result, 
@@ -162,13 +159,8 @@
 	}
 	spin_unlock(&OCFS_I(inode)->ip_lock);
 
-	if (!open_direct)
-		down_read(&OCFS_I(inode)->ip_node_extend_sem);
-
 	err = ocfs2_extent_map_get_blocks(inode, iblock, 1, &p_blkno,
 					   NULL);
-	if (!open_direct)
-		up_read(&OCFS_I(inode)->ip_node_extend_sem);
 
 	if (err) {
 		LOG_ERROR_ARGS("Error %d from get_blocks(0x%p, %llu, 1, %llu, NULL)\n",
@@ -517,16 +509,6 @@
 	}
 
 	blocksize_bits = inode->i_sb->s_blocksize_bits;
-	/* make sure we're up to date... */
-	if (atomic_read(&OCFS_I(inode)->ip_needs_verification)) {
-		LOG_TRACE_STR ("ocfs_direct_IO_get_blocks: verify oin.");
-		status = ocfs_verify_update_inode (osb, inode);
-		if (status < 0) {
-			LOG_TRACE_STR ("ocfs_verify_update_inode failed");
-			ret = -EIO;
-			goto bail;
-		}
-	}
 
 	/* This function won't even be called if the request isn't all
 	 * nicely aligned and of the right size, so there's no need

Modified: branches/dlm-glue/src/dcache.c
===================================================================
--- branches/dlm-glue/src/dcache.c	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/dcache.c	2004-10-26 01:03:25 UTC (rev 1592)
@@ -102,9 +102,6 @@
 
 	ret = 1;
 
-	/* TODO: Is this really necessary? */
-	atomic_set(&OCFS_I(inode)->ip_needs_verification, 1);
-
 bail:
 	LOG_EXIT_INT (ret);
 

Modified: branches/dlm-glue/src/dir.c
===================================================================
--- branches/dlm-glue/src/dir.c	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/dir.c	2004-10-26 01:03:25 UTC (rev 1592)
@@ -94,7 +94,7 @@
 	stored = 0;
 	bh = NULL;
 
-	error = ocfs_acquire_lock_ro(osb, inode);
+	error = ocfs2_meta_lock(inode, NULL, NULL, 0);
 	if (error < 0) {
 		if (error != -EINTR)
 			LOG_ERROR_STATUS (error);
@@ -202,7 +202,7 @@
 	stored = 0;
 bail:
 	if (have_disk_lock) {
-		error = ocfs_release_lock_ro (osb, inode);
+		error = ocfs2_meta_unlock(inode, 0);
 		if (error < 0)
 			LOG_ERROR_STATUS (error);
 	}
@@ -232,7 +232,7 @@
 
 	if (take_lock) {
 		/* Get a lock on the directory... */
-		status = ocfs_acquire_lock_ro (osb, inode);
+		status = ocfs2_meta_lock(inode, NULL, NULL, 0);
 		if (status < 0) {
 			/* Volume should be disabled in this case */
 			if (status != -EINTR)
@@ -255,7 +255,7 @@
 
 	if (take_lock && lock_acq)
 	{
-		tmpstat = ocfs_release_lock_ro (osb, inode);
+		tmpstat = ocfs2_meta_unlock(inode, 0);
 		if (tmpstat < 0) {
 			LOG_ERROR_STATUS (tmpstat);
 			/* Volume should be disabled in this case */

Modified: branches/dlm-glue/src/file.c
===================================================================
--- branches/dlm-glue/src/file.c	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/file.c	2004-10-26 01:03:25 UTC (rev 1592)
@@ -87,46 +87,28 @@
 	return sync_mapping_buffers(inode->i_mapping);
 }
 
-static inline int ocfs_wait_on_first_open(ocfs_super *osb, 
-					   struct inode *inode) 
+/* Checks an open request against our currently open mode */
+static inline int ocfs2_valid_open(int mode, int open_direct)
 {
-	int status = 0;
-	sigset_t tmpsig;
+	int ret = 1;
 
-	ocfs_block_sigs(&tmpsig, SHUTDOWN_SIGS);
-again:
-	if (signal_pending(current)) {
-		status = -EINTR;
-		goto bail;
+	if (mode & O_DIRECT) {
+		if (!open_direct)
+			ret = 0;
+	} else {
+		if (open_direct && !(mode & O_RDONLY))
+			ret = 0;
 	}
-
-	spin_lock(&OCFS_I(inode)->ip_lock);
-	if (!(OCFS_I(inode)->ip_open_flags & OCFS_IN_FIRST_OPEN))
-		goto bail;
-	spin_unlock(&OCFS_I(inode)->ip_lock);
-
-	interruptible_sleep_on(&osb->open_event);
-	goto again;
-
-bail:
-	spin_unlock(&OCFS_I(inode)->ip_lock);
-	ocfs_unblock_sigs(tmpsig);
-
-	return(status);
+	return ret;
 }
 
-static inline void ocfs_notify_openers(ocfs_super *osb) 
-{
-	wake_up(&osb->open_event);
-}
-
 /*
  * ocfs_file_open()
  *
  */
 static int ocfs_file_open(struct inode *inode, struct file *file)
 {
-	int ret =0, err = 0, status = 0, first_open = 0;
+	int status;
 	int mode = file->f_flags;
 	ocfs_super *osb = OCFS_SB(inode->i_sb);
 	ocfs_inode_private *oip = OCFS_I(inode);
@@ -135,116 +117,31 @@
 			file->f_dentry->d_name.len, 
 			file->f_dentry->d_name.name);
 
+	status = -EACCESS;
 	if (osb->osb_flags & OCFS_OSB_FLAGS_SHUTDOWN) {
 		LOG_ERROR_STR ("Volume has been shutdown");
-		status = -EACCES;
 		goto leave;
 	}
 
-	if (atomic_read(&oip->ip_needs_verification)) {
-		down(&inode->i_sem);
-		status = ocfs_verify_update_inode (osb, inode);
-		up(&inode->i_sem);
-		if (status < 0) {
-			LOG_ERROR_STATUS (status);
-			goto leave;
-		}
-	}
-
 	spin_lock(&oip->ip_lock);
-	if (!oip->ip_open_cnt++) {
-		first_open = 1;
-		oip->ip_open_flags |= OCFS_IN_FIRST_OPEN;
+	if (oip->ip_open_cnt &&
+	    !ocfs2_valid_open(mode, 
+			      oip->ip_open_flags & OCFS_INODE_OPEN_DIRECT)) {
+		spin_unlock(&oip->ip_lock);
+		goto leave;
 	}
-	spin_unlock(&oip->ip_lock);
 
-	if (!first_open)
-		status = ocfs_wait_on_first_open(osb, inode);
+	if (mode & O_DIRECT)
+		oip->ip_open_flags |= OCFS_INODE_OPEN_DIRECT;
+	else
+		oip->ip_open_flags &= ~OCFS_INODE_OPEN_DIRECT;
 
-	if (status < 0) {
-		if (status != -EINTR)
-			LOG_ERROR_STATUS(status);
-		spin_lock(&oip->ip_lock);
-		oip->ip_open_cnt--;
-		goto leave_unlock;
-	}
-
-	/* TODO: if we're not opening for write then lets send an additional
-	 * flag over to tell the other node it's not necessary to do the
-	 * truncate_inode_pages (he just has to sync). */
-
-	status = 0;
-	if (!(mode & O_DIRECT) 
-	    && (first_open || (mode & (O_WRONLY|O_RDWR))))
-		status = ocfs_notify_on_open(osb, inode);
-
-	spin_lock(&oip->ip_lock);
-	if (first_open) {
-		oip->ip_open_flags &= ~OCFS_IN_FIRST_OPEN;
-		ocfs_notify_openers(osb);
-	}
-
-	if (status < 0) {
-		oip->ip_open_cnt--;
-		if (status != -EINTR)
-			LOG_ERROR_STATUS(status);
-		goto leave_unlock;
-	}
-
-	if (oip->ip_open_cnt > 1) {
-		/*  We're not the only person who has it open right
-		 *  now so lets check whether the requested
-		 *  access/share access conflicts with the existing
-		 *  open operations. */
-
-		LOG_TRACE_ARGS ("oin->ip_open_cnt > 0! : %u\n", 
-				oip->ip_open_cnt);
-		if (!(mode & O_DIRECT)) {
-			if ((oip->ip_open_flags & OCFS_OIN_OPEN_FOR_DIRECTIO) && !(mode & O_RDONLY)) {
-				oip->ip_open_cnt--;
-				status = -EACCES;
-				LOG_TRACE_STR("file is already open O_DIRECT, "
-						"cannot open non O_DIRECT");
-				goto leave_unlock;
-			}
-		} else if (mode & O_DIRECT) {
-			if (!(oip->ip_open_flags & OCFS_OIN_OPEN_FOR_DIRECTIO)) {
-				oip->ip_open_cnt--;
-				status = -EACCES;
-				LOG_TRACE_STR("file is already open non "  \
-					      "O_DIRECT, cannot open "     \
-					      "O_DIRECT");
-				goto leave_unlock;
-			}
-		}
-		status = 0;
-	} else {
-		if (mode & O_DIRECT)
-			OCFS_SET_FLAG(oip->ip_open_flags, OCFS_OIN_OPEN_FOR_DIRECTIO);
-		else
-			OCFS_CLEAR_FLAG(oip->ip_open_flags, OCFS_OIN_OPEN_FOR_DIRECTIO);
-	}
-
-leave_unlock:
+	oip->ip_open_cnt++;
 	spin_unlock(&oip->ip_lock);
-
+	status = 0;
 leave:
-	if (status < 0) {
-		if (status != -ENOENT && status != -ENOMEM &&
-			status != -EACCES && status != -EINTR) {
-			LOG_ERROR_STATUS (status);
-			ret = -EACCES;
-		} else
-			ret = status;
-	} else {
-		ret = 0;
-	}
-
-	LOG_TRACE_ARGS
-	    ("exiting file_open: file=%p dentry=%p inode=%p kiovec=%d\n",
-	     file, file->f_dentry, file->f_dentry->d_inode, err);
-	LOG_EXIT_INT (ret);
-	return ret;
+	LOG_EXIT_STATUS(status);
+	return status;
 }				/* ocfs_file_open */
 
 static int ocfs_file_release(struct inode *inode, struct file *file)
@@ -258,7 +155,7 @@
 
 	spin_lock(&oip->ip_lock);
 	if (!--oip->ip_open_cnt)
-		oip->ip_open_flags &= ~OCFS_OIN_OPEN_FOR_DIRECTIO;
+		oip->ip_open_flags &= ~OCFS_INODE_OPEN_DIRECT;
 	spin_unlock(&oip->ip_lock);
 
 	LOG_EXIT_INT(0);
@@ -328,14 +225,12 @@
 		goto leave;
 	}
 
-	status = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE, 0, &bh, inode);
+	status = ocfs2_meta_lock(inode, handle, &bh, 1);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STATUS (status);
 		goto leave;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, FLAG_FILE_UPDATE_OIN, 
-			     inode);
 
 	/* Start a transaction - need a minimal amount of block credits (1) */
 	handle = ocfs_start_trans(osb, handle, OCFS_INODE_UPDATE_CREDITS);
@@ -497,15 +392,12 @@
 		} else
 			do_direct_io = 1;
 	}
-	if (atomic_read(&OCFS_I(inode)->ip_needs_verification)) {
-		LOG_TRACE_STR ("OIN_NEEDS_VERIFICATION");
-		status = ocfs_verify_update_inode (osb, inode);
-		if (status < 0) {
-			LOG_TRACE_STR ("ocfs_verify_update_inode failed");
-			LOG_TRACE_STR ("TODO: disable volume");
-			ret = -EIO;
-			goto bail;
-		}
+
+	status = ocfs2_meta_lock(inode, NULL, NULL, 0);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		ret = status;
+		goto bail;
 	}
 
 	newsize = count + *ppos;
@@ -524,6 +416,10 @@
 		     ocfs2_clusters_to_bytes(inode->i_sb,
 					     OCFS_I(inode)->ip_clusters),
 		     newsize);
+		status = ocfs2_meta_unlock(inode, 0);
+		if (status < 0)
+			LOG_ERROR_STATUS(status);
+
 		status = ocfs_extend_file(osb, inode, newsize);
 		if (status < 0) {
 			if (status != -EINTR && status != -ENOSPC) {
@@ -536,8 +432,27 @@
 				ret = status;
 			goto bail;
 		}
+		status = ocfs2_meta_lock(inode, NULL, NULL, 0);
+		if (status < 0) {
+			LOG_ERROR_STATUS(status);
+			ret = status;
+			goto bail;
+		}
 	}
 
+	if (!do_direct_io) {
+		status = ocfs2_data_lock(inode, 1);
+		if (status < 0) {
+			LOG_ERROR_STATUS(status);
+			ret = status;
+
+			status = ocfs2_meta_unlock(inode, 0);
+			if (status < 0)
+				LOG_ERROR_STATUS(status);
+			goto bail;
+		}
+	}
+
 	down_read(&OCFS_I(inode)->ip_alloc_sem);
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 	/* 
@@ -565,6 +480,11 @@
 		ret = generic_file_write_nolock (filp, buf, count, ppos);
 #endif
 	up_read(&OCFS_I(inode)->ip_alloc_sem);
+	if (!do_direct_io) {
+		status = ocfs2_data_unlock(inode, 1);
+		if (status < 0)
+			LOG_ERROR_STATUS(status);
+	}
 	if (writingAtEOF) {
 		LOG_TRACE_STR
 		    ("Generic_file_write ok, asking for OIN update now");
@@ -586,7 +506,9 @@
 				LOG_ERROR_ARGS("Unable to pre-zero extension of inode (%d)", status);
 		}
 	}
-
+	status = ocfs2_meta_unlock(inode, 0);
+	if (status < 0)
+		LOG_ERROR_STATUS(status);
 bail:
 	if (have_i_sem)
 		up(&inode->i_sem);
@@ -644,14 +566,22 @@
 		} else
 			do_direct_io = 1;
 	}
-	if (atomic_read(&OCFS_I(inode)->ip_needs_verification)) {
-		down(&inode->i_sem);
-		status = ocfs_verify_update_inode (osb, inode);
-		up(&inode->i_sem);
+
+	/* yay, PR (shared) locks all 'round :) */
+	status = ocfs2_meta_lock(inode, NULL, NULL, 0);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		/* is this ret code correct? */
+		ret = status;
+		goto bail;
+	}
+
+	if (!do_direct_io) {
+		status = ocfs2_data_lock(inode, 0);
 		if (status < 0) {
-			LOG_TRACE_STR ("ocfs_verify_update_inode failed");
-			LOG_TRACE_STR ("TODO: disable volume");
-			ret = -EIO;
+			LOG_ERROR_STATUS(status);
+			/* is this ret code correct? */
+			ret = status;
 			goto bail;
 		}
 	}
@@ -684,6 +614,19 @@
 	if (ret == -EINVAL)
 		LOG_ERROR_STR ("Generic_file_read returned -EINVAL");
 
+	if (!do_direct_io) {
+		status = ocfs2_data_unlock(inode, 0);
+		if (status < 0) {
+			LOG_ERROR_STATUS(status);
+			/* is this ret code correct? */
+			ret = status;
+			goto bail;
+		}
+	}
+
+	status = ocfs2_meta_unlock(inode, 0);
+	if (status < 0)
+		LOG_ERROR_STATUS(status);
 bail:
 	LOG_EXIT_INT (ret);
 
@@ -803,16 +746,12 @@
 		goto bail;
 	}
 
-	status = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE, 
-				    FLAG_FILE_TRUNCATE|FLAG_FILE_UPDATE_OIN,
-				    &fe_bh, inode);
+	status = ocfs2_meta_lock(inode, handle, &fe_bh, 1);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STATUS (status);
 		goto bail;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
-			     FLAG_FILE_TRUNCATE|FLAG_FILE_UPDATE_OIN, inode);
 
 	fe = (ocfs2_dinode *) fe_bh->b_data;
 	OCFS_ASSERT(IS_VALID_FILE_ENTRY(fe));
@@ -854,6 +793,18 @@
 		goto bail;
 	}
 
+	/* This forces other nodes to sync and drop their pages */
+	status = ocfs2_data_lock(inode, 1);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+	status = ocfs2_data_unlock(inode, 1);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+
 	/* alright, we're going to need to do a full blown alloc size
 	 * change. Orphan the inode so that recovery can complete the
 	 * truncate if necessary. This does the task of marking
@@ -1084,17 +1035,12 @@
 		goto leave;
 	}
 
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, FLAG_FILE_EXTEND, 
-				    &bh, inode);
+	status = ocfs2_meta_lock(inode, handle, &bh, 1);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STATUS (status);
 		goto leave;
 	}
-	ocfs_handle_add_lock(handle, 
-			     OCFS_LKM_EXMODE,
-			     FLAG_FILE_EXTEND|FLAG_FILE_UPDATE_OIN,
-			     inode);
 
 	fe = (ocfs2_dinode *) bh->b_data;
 	OCFS_ASSERT(IS_VALID_FILE_ENTRY(fe));
@@ -1366,8 +1312,7 @@
 		spin_lock(&OCFS_I(inode)->ip_lock);
 		inode->i_size = newsize;
 		inode->i_blocks = (newsize + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
-		if (OCFS_I(inode)->ip_open_flags &
-		    OCFS_OIN_OPEN_FOR_DIRECTIO) {
+		if (OCFS_I(inode)->ip_open_flags & OCFS_INODE_OPEN_DIRECT) {
 			/* This is a total broken hack for O_DIRECT crack */
 			OCFS_I(inode)->ip_mmu_private = inode->i_size;
 		}

Modified: branches/dlm-glue/src/inode.c
===================================================================
--- branches/dlm-glue/src/inode.c	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/inode.c	2004-10-26 01:03:25 UTC (rev 1592)
@@ -307,7 +307,6 @@
 
 	i->ip_flags = 0;
 	atomic_set(&i->ip_clean_buffer_seq, 0);
-	init_rwsem(&(i->ip_node_extend_sem));
 	i->ip_open_cnt = 0;
 	spin_lock_init(&i->ip_lock);
 	ocfs2_extent_map_init(inode);
@@ -318,7 +317,6 @@
 
 	init_rwsem(&i->ip_alloc_sem);
 	init_MUTEX(&(i->ip_io_sem));
-	atomic_set(&i->ip_needs_verification, 0);
 	INIT_LIST_HEAD(&i->ip_pending_locks);
 	INIT_LIST_HEAD(&i->ip_j_inode);
 
@@ -397,8 +395,10 @@
 	inode->i_nlink = fe->i_links_count;
 
 	if (le32_to_cpu(fe->i_flags) & OCFS2_LOCAL_ALLOC_FL) {
+		OCFS_I(inode)->ip_flags |= OCFS_INODE_BITMAP;
 		LOG_TRACE_ARGS("local alloc inode: i_ino=%lu\n", inode->i_ino);
 	} else if (le32_to_cpu(fe->i_flags) & OCFS2_BITMAP_FL) {
+		OCFS_I(inode)->ip_flags |= OCFS_INODE_BITMAP;
 		OCFS_I(inode)->u.ip_bitinfo.used_bits = 
 			le32_to_cpu(fe->id1.bitmap1.i_used);
 		OCFS_I(inode)->u.ip_bitinfo.total_bits = 
@@ -439,7 +439,9 @@
 		    break;
 	}
 
-	status = 0;
+	status = ocfs2_lock_res_init(inode, &OCFS_I(inode)->ip_lockres);
+	if (status < 0)
+		LOG_ERROR_STATUS(status);
 bail:
 	LOG_EXIT_STATUS (status);
 	return status;
@@ -624,7 +626,8 @@
 	 * have to skip deleting this guy. That's OK though because
 	 * the node who's doing the actual deleting should handle it
 	 * anyway. */
-	if (osb->voting_ino == inode->i_ino) {
+
+	if (current == osb->vote_task) {
 		LOG_TRACE_ARGS("Skipping delete of %lu because we're currently"
 			       "in process_vote\n", inode->i_ino);
 		goto bail;
@@ -685,14 +688,11 @@
 		goto bail;
 	}
 	ocfs_handle_add_inode(handle, orphan_dir_inode);
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0,
-				   &orphan_dir_bh, orphan_dir_inode);
+	status = ocfs2_meta_lock(orphan_dir_inode, handle, &orphan_dir_bh, 1);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto bail;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0,
-			     orphan_dir_inode);
 
 	/* we do this while holding the orphan dir lock because we
 	 * don't want recovery being run from another node to vote for
@@ -711,14 +711,11 @@
 		goto bail;
 	}
 	ocfs_handle_add_inode(handle, inode_alloc_inode);
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0,
-				   &inode_alloc_bh, inode_alloc_inode);
+	status = ocfs2_meta_lock(inode_alloc_inode, handle, &inode_alloc_bh, 1);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto bail;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0,
-			     inode_alloc_inode);
 
 	handle = ocfs_start_trans(osb, handle, OCFS_DELETE_INODE_CREDITS);
 	if (handle == NULL) {
@@ -819,10 +816,15 @@
 
 	ocfs2_extent_map_drop(inode, 0);
 
+	status = ocfs2_drop_inode_locks(inode);
+	if (status < 0)
+		LOG_ERROR_STATUS(status);
+
 	down(&recovery_list_sem);
 	list_del(&OCFS_I(inode)->ip_recovery_list);
 	up(&recovery_list_sem);
 
+	ocfs2_lock_res_free(&OCFS_I(inode)->ip_lockres);
 	/* clean out the inode private ... why?! */
 	memset(inode->u.generic_ip, 0, sizeof(ocfs_inode_private));
 
@@ -904,7 +906,6 @@
 	struct inode *inode = dentry->d_inode;
 	int status = 0;
 	ocfs_super *osb;
-	ocfs_lock_res *lockres;
 
 	LOG_SET_CONTEXT(REVALIDATE);
 
@@ -928,28 +929,16 @@
 	}
 	spin_unlock(&OCFS_I(inode)->ip_lock);
 
-	if (ocfs_node_map_is_only(osb, &osb->publ_map, osb->node_num)) {
-		LOG_TRACE_STR ("Only node alive.");
+	status = ocfs_meta_lock(inode, NULL, NULL, 0);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
 		goto bail;
 	}
 
-	lockres = GET_INODE_LOCKRES(inode);
-	/* if I hold cache lock, no revalidate needed */
-	ocfs_acquire_lockres_read(inode);
-	if (ocfs_is_local_cache_lock(osb, inode)) {
-		ocfs_release_lockres_read(inode);
-		LOG_TRACE_STR("local cache lock\n");
-		goto bail;
-	}
-	ocfs_release_lockres_read(inode);
+	status = ocfs_meta_unlock(inode, 0);
+	if (status < 0)
+		LOG_ERROR_STATUS(status);
 
-	atomic_set(&OCFS_I(inode)->ip_needs_verification, 1);
-	status = ocfs_verify_update_inode(osb, inode);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		status = -ENOENT;
-	}
-
 bail:
 	LOG_EXIT_STATUS(status);
 
@@ -1023,166 +1012,40 @@
  * Updates a struct inode from a disk inode.
  * does no i/o, only takes ip_lock. 
  */
-int ocfs_refresh_inode(struct inode *inode, 
-		       ocfs2_dinode *fe)
+void ocfs_refresh_inode(struct inode *inode, 
+			ocfs2_dinode *fe)
 {
-	int status = 0;
-	int drop_map = 0;
+	ocfs_inode_private *oip = OCFS_I(inode);
 	ocfs_super *osb = OCFS2_SB(inode->i_sb);
 
-	spin_lock(&OCFS_I(inode)->ip_lock);
+	spin_lock(&oip->ip_lock);
 
-	if (INODE_DELETED(inode)) {
-		LOG_TRACE_ARGS("Inode %llu was marked as deleted!", 
-			       OCFS_I(inode)->ip_blkno);
-		status = -ENOENT;
-		goto bail;
+	if (le32_to_cpu(fe->i_flags) & OCFS2_BITMAP_FL) {
+		oip->u.ip_bitinfo.used_bits = 
+			le32_to_cpu(fe->id1.bitmap1.i_used);
+		oip->u.ip_bitinfo.total_bits = 
+			le32_to_cpu(fe->id1.bitmap1.i_total);
+		LOG_TRACE_ARGS("updated bitmap inode: i_ino=%lu, used=%u, total=%u\n",
+			       inode->i_ino, oip->u.ip_bitinfo.used_bits,
+			       oip->u.ip_bitinfo.total_bits);
 	}
 
-	/* Add checks as needed */
-	if ((fe->i_dtime) || (!(fe->i_flags & OCFS2_VALID_FL))) {
-		if (fe->i_dtime)
-			LOG_ERROR_ARGS("Inode %lu has dtime = %llu\n", 
-				       inode->i_ino, fe->i_dtime);
-		else
-			LOG_TRACE_STR ("File Entry is invalid");
-
-		status = -ENOENT;
-		goto bail;
+	oip->ip_clusters = fe->i_clusters;
+	inode->i_size = fe->i_size;
+	if (S_ISREG(inode->i_mode)) {
+		oip->ip_mmu_private = inode->i_size;
 	}
+	inode->i_nlink = fe->i_links_count;
+	inode->i_blocks = (inode->i_size + osb->sb->s_blocksize - 1) >> osb->sb->s_blocksize_bits;
+	inode->i_uid = fe->i_uid;
+	inode->i_gid = fe->i_gid;
+	inode->i_mode = fe->i_mode;
+	inode->i_blksize = (__u32) osb->s_clustersize;
+	OCFS_SET_INODE_TIME(inode, i_ctime, fe->i_ctime);
+	OCFS_SET_INODE_TIME(inode, i_atime, fe->i_atime);
+	OCFS_SET_INODE_TIME(inode, i_mtime, fe->i_mtime);
 
-	if (inode->i_generation != le32_to_cpu(fe->i_generation)) {
-		LOG_ERROR_ARGS("Inode %llu is stale! (%u, %u)\n",
-			       OCFS_I(inode)->ip_blkno, 
-			       inode->i_generation,
-			       le32_to_cpu(fe->i_generation));
-		SET_INODE_DELETED(inode);
-		status = -ENOENT;
-		goto bail;
-	}
-
-	if ((OCFS_I(inode)->ip_clusters != fe->i_clusters) ||
-	    (inode->i_size != fe->i_size) ||
-	    inode->i_uid != fe->i_uid ||
-	    inode->i_gid != fe->i_gid || 
-	    inode->i_mode != fe->i_mode ||
-	    inode->i_nlink != fe->i_links_count){
-
-		if (OCFS_I(inode)->ip_clusters > fe->i_clusters) {
-			LOG_TRACE_ARGS("destroying extent maps for %llu, "
-				       "ip_clusters = %u, i_clusters = %u\n", 
-				       OCFS_I(inode)->ip_blkno, 
-				       OCFS_I(inode)->ip_clusters, 
-				       fe->i_clusters);
-			drop_map = 1; /* Because we have the lock here */
-		}
-
-		if (le32_to_cpu(fe->i_flags) & OCFS2_BITMAP_FL) {
-			OCFS_I(inode)->u.ip_bitinfo.used_bits = 
-				le32_to_cpu(fe->id1.bitmap1.i_used);
-			OCFS_I(inode)->u.ip_bitinfo.total_bits = 
-				le32_to_cpu(fe->id1.bitmap1.i_total);
-			LOG_TRACE_ARGS("updated bitmap inode: i_ino=%lu, used=%u, total=%u\n",
-			       inode->i_ino, OCFS_I(inode)->u.ip_bitinfo.used_bits,
-			       OCFS_I(inode)->u.ip_bitinfo.total_bits);
-		}
-
-		LOG_TRACE_STR("Allocsize, filesize or seq no did not match");
-		OCFS_I(inode)->ip_clusters = fe->i_clusters;
-		inode->i_size = fe->i_size;
-		if (S_ISREG(inode->i_mode)) {
-			OCFS_I(inode)->ip_mmu_private = inode->i_size;
-		}
-		LOG_TRACE_ARGS("verifyupdate: setting nlink from %d to %d for %llu\n", 
-			       inode->i_nlink, fe->i_links_count,
-			       OCFS_I(inode)->ip_blkno);
-		inode->i_nlink = fe->i_links_count;
-		inode->i_blocks = (inode->i_size + osb->sb->s_blocksize - 1) >> osb->sb->s_blocksize_bits;
-		inode->i_uid = fe->i_uid;
-		inode->i_gid = fe->i_gid;
-		inode->i_mode = fe->i_mode;
-		inode->i_blksize = (__u32) osb->s_clustersize;
-		OCFS_SET_INODE_TIME(inode, i_ctime, fe->i_ctime);
-		OCFS_SET_INODE_TIME(inode, i_atime, fe->i_atime);
-		OCFS_SET_INODE_TIME(inode, i_mtime, fe->i_mtime);
-
-		if (S_ISCHR(fe->i_mode) ||
-	       	    S_ISBLK(fe->i_mode) ||
-	      	    S_ISFIFO(fe->i_mode) ||
-	     	    S_ISSOCK(fe->i_mode)) {
-			inode->i_rdev = 0;
-			init_special_inode(inode, inode->i_mode,
-					   huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev)));
-		}
-	}
-
-	atomic_set(&OCFS_I(inode)->ip_needs_verification, 0);
-bail:
-
-	spin_unlock(&OCFS_I(inode)->ip_lock);
-
-	if (drop_map)
-		ocfs2_extent_map_trunc(inode, fe->i_clusters);
-
-	return(status);
+	spin_unlock(&oip->ip_lock);
 }				/* ocfs_refresh_inode */
 
-/*
- * ocfs_verify_update_inode()
- */ 
-int ocfs_verify_update_inode (ocfs_super * osb, struct inode * inode)
-{
-	int status = 0;
-	struct buffer_head *fe_bh = NULL;
-	ocfs2_dinode *fe;
 
-	/* We are setting the oin Updated flag in the end. */
-	LOG_ENTRY ();
-
-	OCFS_ASSERT (inode);
-
-	if (OCFS_I(inode)->ip_blkno == 0) {
-		LOG_ERROR_ARGS("inode 0x%lu has zero blkno\n", inode->i_ino);
-		status = -EINVAL;
-		goto leave;
-	}
-
-	spin_lock(&OCFS_I(inode)->ip_lock);
-	if (INODE_DELETED(inode)) {
-		spin_unlock(&OCFS_I(inode)->ip_lock);
-		LOG_TRACE_ARGS("Inode %llu was marked as deleted!", 
-			       OCFS_I(inode)->ip_blkno);
-		status = -ENOENT;
-		goto leave;
-	}
-	spin_unlock(&OCFS_I(inode)->ip_lock);
-
-	status = ocfs_read_block(osb, OCFS_I(inode)->ip_blkno, &fe_bh, 
-				 OCFS_BH_CACHED, inode);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-
-	fe = (ocfs2_dinode *) fe_bh->b_data;
-
-	status = ocfs_refresh_inode(inode, fe);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-
-	ocfs_acquire_lockres_write(inode);
-	status = ocfs_update_lockres (osb, fe_bh, inode, 0);
-	ocfs_release_lockres_write(inode);
-
-	status = 0;
-leave:
-
-	if (fe_bh)
-		brelse(fe_bh);
-
-	LOG_EXIT_STATUS (status);
-	return status;
-}				/* ocfs_verify_update_inode */
-

Modified: branches/dlm-glue/src/inode.h
===================================================================
--- branches/dlm-glue/src/inode.h	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/inode.h	2004-10-26 01:03:25 UTC (rev 1592)
@@ -41,9 +41,8 @@
 ssize_t ocfs_rw_direct(int rw, struct file *filp, char *buf,
 		       size_t size, loff_t *offp);
 void ocfs_sync_blockdev(struct super_block *sb);
-int ocfs_verify_update_inode(ocfs_super *osb, struct inode *inode);
-int ocfs_refresh_inode(struct inode *inode, 
-		       ocfs2_dinode *fe);
+void ocfs_refresh_inode(struct inode *inode, 
+			ocfs2_dinode *fe);
 int ocfs_mark_inode_dirty(ocfs_journal_handle *handle, 
 			  struct inode *inode, 
 			  struct buffer_head *bh);

Modified: branches/dlm-glue/src/journal.c
===================================================================
--- branches/dlm-glue/src/journal.c	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/journal.c	2004-10-26 01:03:25 UTC (rev 1592)
@@ -63,85 +63,8 @@
 static int ocfs_wait_on_mount(ocfs_super *osb);
 static void ocfs_handle_move_locks(ocfs_journal *journal, 
 				   ocfs_journal_handle *handle);
-static void ocfs_journal_optimize_lock_list(ocfs_journal *journal);
 static void ocfs_commit_unstarted_handle(ocfs_journal_handle *handle);
 
-static void ocfs_journal_optimize_lock_list(ocfs_journal *journal)
-{
-	ocfs_journal_lock *lock = NULL;
-	ocfs_journal_lock *first = NULL; /* 1st update_oin release for
-					  * an inode. */
-	struct inode *curr_inode = NULL;
-	struct list_head *p, *n;
-
-	/* 1st pass: optimize away all UPDATE_OIN messages into one.
-	 * 2 types of UPDATE_OIN messages as of now: with size change
-	 * (truncate / extend) or without size change. We will take
-	 * *all* of them (regardless of type) and cram it into one
-	 * message. */
-	curr_inode = NULL;
-	list_for_each_safe(p, n, &journal->checkpointing_locks) {
-		lock = list_entry(p, ocfs_journal_lock, lock_list);
-
-		if (lock->inode != curr_inode) {
-			/* Ok, new inode. */
-			first = NULL;
-
-			curr_inode = lock->inode;
-		}
-
-		/* if it's not an update oin then just continue */
-		if (!(lock->flags & FLAG_FILE_UPDATE_OIN))
-			continue;
-
-		if (!first) {
-			first = lock;
-			/* nothing else to do to the 1st update release. */
-			continue;
-		}
-
-		/* only the 1st update_oin lock stays -- the
-		 * rest are either num_ident into it or
-		 * dropped */
-		list_del(&lock->lock_list);
-		atomic_dec(&journal->num_chkpt_locks);
-
-		/* we only incement first->num_ident if the current
-		 * lock has a size change AND first has recorded at
-		 * least one size change (which can include
-		 * itself). Otherwise we'll have an off by one as a
-		 * first with no size change recorded will keep at
-		 * least 1 reference for itself. */
-		if ((lock->flags & FLAG_FILE_EXTEND) 
-		    || (lock->flags & FLAG_FILE_TRUNCATE)) {
-			if ((first->flags & FLAG_FILE_EXTEND) 
-			    || (first->flags & FLAG_FILE_TRUNCATE))
-				first->num_ident++;
-			else
-				first->drop_holders++;
-		} else {
-			/* Ok, no size change on this particular lock,
-			 * so we're discarding it without updating the
-			 * num_ident value -- that's fine but we need
-			 * to manually drop the lockres->lock_holders
-			 * value on it's behalf */
-			first->drop_holders++;
-		}
-
-		/* record a size change in first if there was one. */
-		if (lock->flags & FLAG_FILE_EXTEND)
-			first->flags = first->flags | FLAG_FILE_EXTEND;
-		if (lock->flags & FLAG_FILE_TRUNCATE)
-			first->flags = first->flags | FLAG_FILE_TRUNCATE;
-
-		iput(lock->inode);
-
-		kmem_cache_free(OcfsGlobalCtxt.lock_cache, lock);
-	}
-
-	return;
-}
-
 /* 
  * ocfs_commit_cache()
  *
@@ -232,7 +155,6 @@
 		       cmt_locks);
 #endif
 
-	ocfs_journal_optimize_lock_list(journal);
 #ifdef VERBOSE_COMMIT_THREAD
 	if (flushed || cmt_locks)
 		printk("(%u) commit_thread: after optimization, %u locks "
@@ -245,11 +167,11 @@
 		if (!atomic_read(&journal->num_chkpt_locks))
 			BUG();
 
-		lock = list_entry(p, ocfs_journal_lock, lock_list);
+		lock = list_entry(p, ocfs_journal_lock, jl_lock_list);
 
-		list_del(&(lock->lock_list));
+		list_del(&(lock->jl_lock_list));
 
-		if (!lock->inode)
+		if (!lock->jl_inode)
 			BUG();
 
 #if 0
@@ -257,38 +179,23 @@
 		 * hang your box :) */
 		printk("commit_thread: release lock %u (inode %llu)\n", 
 		       atomic_read(&journal->num_chkpt_locks),
-		       OCFS_I(lock->inode)->ip_blkno);
+		       OCFS_I(lock->jl_inode)->ip_blkno);
 #endif
 		tmpstat = 0;
-		if (!INODE_DELETED(lock->inode))
-			tmpstat = ocfs_release_lock_full(osb, 
-							 lock->type,
-							 lock->flags,
-							 lock->inode,
-							 lock->num_ident);
-		else
-			LOG_ERROR_ARGS("commit_thread: Skipping release for "
-				       "inode %llu!\n", 
-				       OCFS_I(lock->inode)->ip_blkno);
+		OCFS_ASSERT(!INODE_DELETED(lock->jl_inode));
+		tmpstat = ocfs2_meta_unlock(lock->jl_inode, 1);
 		if (tmpstat < 0)
 			LOG_ERROR_ARGS("commit_thread: release_lock status is"
 				       " %d releasing lock on inode %llu!\n",
 				       tmpstat, OCFS_I(lock->inode)->ip_blkno);
+		iput(lock->jl_inode);
 
-		if (lock->drop_holders) {
-			lockres = GET_INODE_LOCKRES(lock->inode);
-			ocfs_acquire_lockres_write(lock->inode);
-			OCFS_ASSERT(lockres->lock_holders >= lock->drop_holders);
-			lockres->lock_holders -= lock->drop_holders;
-			ocfs_release_lockres_write(lock->inode);
-		}
-
-		iput(lock->inode);
-
 		atomic_dec(&journal->num_chkpt_locks);
 		kmem_cache_free(OcfsGlobalCtxt.lock_cache, lock);
 	}
 
+	kick_vote_thread(osb);
+
 finally:
 	LOG_EXIT_STATUS (status);
 	return status;
@@ -732,45 +639,35 @@
 	return(status);
 } /* ocfs_journal_dirty */
 
-void ocfs_handle_add_lock(ocfs_journal_handle *handle, __u32 type, 
-			  __u32 flags, struct inode *inode)
+/* We always assume you're adding a metadata lock at level 'ex' */
+int ocfs_handle_add_lock(ocfs_journal_handle *handle,
+			 struct inode *inode)
 {
+	int status;
 	ocfs_journal_lock *lock;
 
 	OCFS_ASSERT(inode);
-
-	LOG_ENTRY_ARGS("(inode=%llu, type=%u, flags=%u)\n",
-			OCFS_I(inode)->ip_blkno, type, flags);
-
 	lock = kmem_cache_alloc(OcfsGlobalCtxt.lock_cache, GFP_NOFS);
-	if (lock == NULL) {
-		LOG_ERROR_STR("Out of memory -- cannot add lock to release.");
+	if (!lock) {
+		status = -ENOMEM;
 		LOG_ERROR_STATUS(-ENOMEM);
-
-		BUG();
+		goto bail;
 	}
 
-	lock->type  = type;
-	lock->flags = flags;
-	lock->inode = inode;
-
-	/* stuff for commit thread optimization. */
-	lock->num_ident = 1;
-	/* this is for *additional* decrements of lock_holders, not
-	 * the one given by ocfs_release_lock... */
-	lock->drop_holders = 0;
-
 	if (!igrab(inode))
 		BUG();
+	lock->jl_inode = inode;
 
-	list_add_tail(&(lock->lock_list), &(handle->locks));
+	list_add_tail(&(lock->jl_lock_list), &(handle->locks));
 	handle->num_locks++;
 	spin_lock(&handle->journal->cmt_lock);
 	atomic_inc(&handle->journal->num_cmt_locks);
 	spin_unlock(&handle->journal->cmt_lock);
 
-	LOG_EXIT();
-	return;
+	status = 0;
+bail:
+	LOG_EXIT_STATUS(status);
+	return status;
 }
 
 /* move the locks off a journal handle and onto the
@@ -792,15 +689,15 @@
 	struct inode *inode;
 
 	list_for_each_safe(p, n, &(handle->locks)) {
-		lock = list_entry(p, ocfs_journal_lock, lock_list);
-		list_del(&lock->lock_list);
+		lock = list_entry(p, ocfs_journal_lock, jl_lock_list);
+		list_del(&lock->jl_lock_list);
 		handle->num_locks--;
 
-		inode = lock->inode;
+		inode = lock->jl_inode;
 
 		spin_lock(&journal->cmt_lock);
 		/* add the lock to the inode */
-		list_add_tail(&lock->lock_list, 
+		list_add_tail(&lock->jl_lock_list, 
 			      &OCFS_I(inode)->ip_pending_locks);
 		/* and make sure the inode is on the journals list */
 		if (list_empty(&OCFS_I(inode)->ip_j_inode))
@@ -847,8 +744,7 @@
 
 	SET_INODE_JOURNAL(inode);
 
-	status = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE,
-				    0, &bh, inode);
+	status = ocfs2_meta_lock(inode, NULL, &bh, 1);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STR("Could not get lock on journal!");
@@ -983,7 +879,7 @@
 	OCFS_I(inode)->ip_open_cnt--;
 
 	/* unlock our journal */
-	status = ocfs_release_lock (osb, OCFS_LKM_EXMODE, 0, inode);
+	status = ocfs2_meta_unlock(inode, 1);
 	if (status < 0)
 		LOG_ERROR_STATUS (status);
 
@@ -1145,7 +1041,7 @@
 	sigfillset(&current->blocked);
 	recalc_sigpending(current);
 	spin_unlock_irq(&current->sigmask_lock);
-#endif	
+#endif
 
 	status = ocfs_recover_node(osb, node_num);
 	if (status < 0)
@@ -1164,7 +1060,13 @@
 	LOG_ENTRY_ARGS("(node_num=%d, osb->node_num = %d)\n", node_num,
 		       osb->node_num);
 
-	arg = ocfs_malloc(sizeof(struct ocfs_recover_arg));
+	/* atomic_inc this here and let recover_vol dec it when
+	 * done. We do it this way to avoid races with umount. People
+	 * waiting on recovery will wait on this value to drop back
+	 * down to zero. */
+	atomic_inc(&osb->num_recovery_threads);
+
+	arg = kmalloc(sizeof(struct ocfs_recover_arg), GFP_KERNEL);
 	if (arg == NULL) {
 		LOG_ERROR_STATUS(-ENOMEM);
 		goto done;
@@ -1173,16 +1075,14 @@
 	arg->osb = osb;
 	arg->node_num = node_num;
 
-	/* atomic_inc this here and let recover_vol dec it when
-	 * done. We do it this way to avoid races with umount. */
-	atomic_inc(&osb->num_recovery_threads);
-
 	LOG_TRACE_STR("starting recovery thread...");
 
 	kernel_thread(__ocfs_recovery_thread, arg,
 		      CLONE_VM | CLONE_FS | CLONE_FILES);
 
 done:
+	wake_up_all(&osb->recovery_event);
+
 	LOG_EXIT();
 	return;
 }
@@ -1246,9 +1146,7 @@
 	if (osb->node_num == node_num)
 		BUG();
 
-	status = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE, FLAG_FILE_RECOVERY, 
-				    &bh, inode);
-
+	status = ocfs2_meta_lock(inode, NULL, &bh, 1);
 	if (status < 0) {
 		LOG_TRACE_ARGS("status returned from acquire_lock=%d\n", 
 			       status);
@@ -1334,9 +1232,7 @@
 
 	/* drop the lock on this nodes journal */
 	if (got_lock) {
-		tmpstat = ocfs_release_lock(osb, OCFS_LKM_EXMODE, 
-					    FLAG_FILE_RECOVERY,
-					    inode);
+		tmpstat = ocfs2_meta_unlock(inode, 1);
 		if (tmpstat < 0)
 			LOG_ERROR_STATUS(tmpstat);
 	}
@@ -1393,7 +1289,7 @@
 	}
 
 	down(&orphan_dir_inode->i_sem);
-	status = ocfs_acquire_lock_ro(osb, orphan_dir_inode);
+	status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0);
 	if (status < 0) {
 		up(&orphan_dir_inode->i_sem);
 		LOG_ERROR_STATUS(status);
@@ -1467,7 +1363,7 @@
 	}
 	up(&orphan_dir_inode->i_sem);
 
-	status = ocfs_release_lock_ro(osb, orphan_dir_inode);
+	status = ocfs2_meta_unlock(orphan_dir_inode, 0);
 	have_disk_lock = 0;
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
@@ -1487,7 +1383,7 @@
 	up(&osb->orphan_recovery_lock);
 
 	if (have_disk_lock) {
-		tmpstat = ocfs_release_lock_ro(osb, orphan_dir_inode);
+		tmpstat = ocfs2_meta_unlock(orphan_dir_inode, 0);
 		if (tmpstat < 0)
 			LOG_ERROR_STATUS(tmpstat);
 	}
@@ -1590,7 +1486,7 @@
 		status = ocfs_wait (osb->flush_event,
 			    atomic_read (&osb->flush_event_woken), 
 				    OCFS_CHECKPOINT_INTERVAL);
-		
+
 		atomic_set (&osb->flush_event_woken, 0);
 
 		switch (status) {

Modified: branches/dlm-glue/src/localalloc.c
===================================================================
--- branches/dlm-glue/src/localalloc.c	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/localalloc.c	2004-10-26 01:03:25 UTC (rev 1592)
@@ -265,15 +265,12 @@
 	}
 
 	ocfs_handle_add_inode(handle, main_bm_inode);
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 
-				   0, &main_bm_bh, main_bm_inode);
+	status = ocfs2_meta_lock(main_bm_inode, handle, &main_bm_bh, 1);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STATUS (status);
 		goto bail;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
-			     0, main_bm_inode);
 
 	/* WINDOW_MOVE_CREDITS is a bit heavy... */
 	handle = ocfs_start_trans(osb, handle, OCFS_WINDOW_MOVE_CREDITS);
@@ -435,15 +432,12 @@
 	}
 
 	ocfs_handle_add_inode(handle, main_bm_inode);
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 
-				   0, &main_bm_bh, main_bm_inode);
+	status = ocfs2_meta_lock(main_bm_inode, handle, &main_bm_bh, 1);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STATUS (status);
 		goto bail;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
-			     0, main_bm_inode);
 
 	handle = ocfs_start_trans(osb, handle, OCFS_WINDOW_MOVE_CREDITS);
 	if (!handle) {

Modified: branches/dlm-glue/src/namei.c
===================================================================
--- branches/dlm-glue/src/namei.c	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/namei.c	2004-10-26 01:03:25 UTC (rev 1592)
@@ -323,15 +323,12 @@
 		goto leave;
 	}
 
-	/* lock the parent directory */
-	status = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE, 0, 
-				    &parent_fe_bh, dir);
+	status = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STATUS (status);
 		goto leave;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0, dir);
 
 	dirfe = (ocfs2_dinode *) parent_fe_bh->b_data;
 	if (!dirfe->i_links_count) {
@@ -661,15 +658,12 @@
 		goto bail;
 	}
 
-	/* lock the parent directory */
-	err = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE, 0, 
-				    &parent_fe_bh, dir);
+	err = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1);
 	if (err < 0) {
 		if (err != -EINTR)
 			LOG_ERROR_STATUS (err);
 		goto bail;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0, dir);
 
 	err = ocfs_prepare_dir_for_insert(osb, dir, parent_fe_bh, 
 					     dentry->d_name.name, 
@@ -679,14 +673,12 @@
 		goto bail;
 	}
 
-	err = ocfs_acquire_lock (osb, OCFS_LKM_EXMODE, 0, &fe_bh, inode);
+	err = ocfs2_meta_lock(inode, handle, &fe_bh, 1);
 	if (err < 0) {
 		if (err != -EINTR)
 			LOG_ERROR_STATUS (err);
 		goto bail;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, FLAG_FILE_UPDATE_OIN, 
-			     inode);
 
 	fe = (ocfs2_dinode *) fe_bh->b_data;
 	if (fe->i_links_count >= OCFS2_LINK_MAX) {
@@ -790,13 +782,11 @@
 		goto leave;
 	}
 
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0, 
-				   &parent_node_bh, dir);
+	status = ocfs2_meta_lock(dir, handle, &parent_node_bh, 1);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto leave;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0, dir);
 
 	status = ocfs_find_files_on_disk(osb, dentry->d_name.name,
 					 dentry->d_name.len, &blkno,
@@ -1559,14 +1549,12 @@
 	}
 
 	/* lock the parent directory */
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0, 
-				   &parent_fe_bh, dir);
+	status = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STATUS (status);
 		goto bail;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0, dir);
 
 	dirfe = (ocfs2_dinode *) parent_fe_bh->b_data;
 	if (!dirfe->i_links_count) {
@@ -2053,14 +2041,11 @@
 	}
 
 	ocfs_handle_add_inode(handle, orphan_dir_inode);
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 0,
-				   &orphan_dir_bh, orphan_dir_inode);
+	status = ocfs2_meta_lock(orphan_dir_inode, handle, &orphan_dir_bh, 1);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto leave;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 0, 
-			     orphan_dir_inode);
 
 	status = ocfs_prepare_dir_for_insert(osb, orphan_dir_inode, 
 					     orphan_dir_bh, name, namelen, 

Modified: branches/dlm-glue/src/ocfs.h
===================================================================
--- branches/dlm-glue/src/ocfs.h	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/ocfs.h	2004-10-26 01:03:25 UTC (rev 1592)
@@ -186,14 +186,6 @@
 	NONLOCAL_EXT = 2
 } ocfs_ext_flag;
 
-/* The following are standard DLM lock types, of which we currently
- * only use a couple. */
-#define OCFS_LKM_NLMODE      (0)               /* null lock */
-#define OCFS_LKM_CRMODE      (1)               /* concurrent read */
-#define OCFS_LKM_CWMODE      (2)               /* concurrent write */
-#define OCFS_LKM_PRMODE      (3)               /* protected read */
-#define OCFS_LKM_PWMODE      (4)               /* protected write */
-#define OCFS_LKM_EXMODE      (5)               /* exclusive */
 
 #define  OCFS_INVALID_NODE_NUM         -1
 
@@ -364,6 +356,8 @@
 
 	u64             ip_blkno;
 
+	ocfs2_lock_res  ip_lockres;
+
 	/* protects allocation changes on this inode. */
 	struct rw_semaphore  ip_alloc_sem;
 
@@ -375,8 +369,6 @@
 	__u32             ip_open_flags;
 	struct ocfs2_extent_map ip_map;
 
-	atomic_t          ip_needs_verification;
-
 	struct semaphore  ip_io_sem;
 
 	/* Used by the journalling code to attach an inode to a
@@ -386,9 +378,6 @@
 	struct list_head            ip_handle_list;
 	struct _ocfs_journal_handle *ip_handle;
 
-	/* ip_node_extend_sem locks out extends on behalf of other nodes. */
-	struct rw_semaphore  ip_node_extend_sem;
-
 	struct list_head  ip_recovery_list;/* protected by recovery_list_sem */
 	__s32             ip_num_extends; /* protected by oin_num_ext_lock */
 
@@ -407,7 +396,6 @@
 	/* protected by recovery_lock. */
 	struct inode      *ip_next_orphan;
 
-	ocfs_lock_res     ip_lockres;
 	__u32 		  ip_dir_start_lookup;
 
 	/* ip_pending_locks and ip_j_inode are protected by the
@@ -426,7 +414,7 @@
 /* Eventually, the 'flags' and 'open_flags' fields need to be
  * merged. */
 /* open flags */
-#define  OCFS_OIN_OPEN_FOR_DIRECTIO              (0x00000001)
+#define  OCFS_INODE_OPEN_DIRECT                  (0x00000001)
 #define  OCFS_IN_FIRST_OPEN                      (0x00000002)
 
 /* 'flags' flags. */
@@ -440,6 +428,8 @@
 #define OCFS_INODE_SYSTEM_FILE      0x00000008
 /* are we going to let another node deal with deletion of this inode? */
 #define OCFS_INODE_SKIP_DELETE      0x00000010
+#define OCFS_INODE_IN_REFRESH       0x00000020
+#define OCFS_INODE_BITMAP           0x00000040
 
 #define OCFS_I(i)        ((ocfs_inode_private *)(i->u.generic_ip))
 
@@ -604,8 +594,22 @@
 	struct semaphore vote_sem; /* protects calls to ocfs_process_vote */
 	struct list_head vote_obj_queue;
 	spinlock_t vote_obj_queue_lock;
-	unsigned long voting_ino; /* only safe from the process_vote pid */
 	wait_queue_head_t open_event;
+
+	dlm_ctxt *dlm;
+
+	atomic_t recovery_count;
+	wait_queue_head_t recovery_event;
+
+	spinlock_t vote_task_lock;
+	struct task_struct *vote_task;
+	wait_queue_head_t vote_event;
+	atomic_t wake_vote_task;
+	int vote_exit;
+	struct list_head blocked_inode_list
+	struct list_head vote_list;
+	int vote_count;
+	struct completion vote_event_complete;
 };
 
 typedef struct _ocfs_comm_info

Modified: branches/dlm-glue/src/ocfs_journal.h
===================================================================
--- branches/dlm-glue/src/ocfs_journal.h	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/ocfs_journal.h	2004-10-26 01:03:25 UTC (rev 1592)
@@ -146,20 +146,13 @@
 
 typedef struct _ocfs_journal_lock ocfs_journal_lock;
 struct _ocfs_journal_lock {
-	/* release_lock arguments. */
-	__u32 type;
-	__u32 flags;
-	struct inode *inode;
-	unsigned int num_ident;
-
-	/* used by commit_cache */
-	unsigned int drop_holders;
+	struct inode     *jl_inode;
 	/* lock_list: we are either on 
 	 *  - handle->locks: if still running
 	 *  - inode->ip_pending_locks: if waiting for checkpoint
 	 *  - journal->checkpointing_locks: awaiting release after checkpoint
 	 */
-	struct list_head lock_list;
+	struct list_head  jl_lock_list;
 };
 
 struct _ocfs_journal_handle {
@@ -208,12 +201,18 @@
  *  ocfs_journal_wipe     - Wipe transactions from a journal. Optionally 
  *                          zero out each block.
  *  ocfs_recovery_thread  - Perform recovery on a node. osb is our own osb.
+ *  ocfs_start_checkpoint - Kick the commit thread to do a checkpoint.
  */
 int    ocfs_journal_init(struct _ocfs_super *osb);
 void   ocfs_journal_shutdown(struct _ocfs_super *osb);
 int    ocfs_journal_wipe(ocfs_journal *journal, int full);
 int    ocfs_journal_load(ocfs_journal *journal);
 void   ocfs_recovery_thread(struct _ocfs_super *osb, int node_num);
+static inline void ocfs_start_checkpoint(struct _ocfs_super *osb)
+{
+	atomic_set(&osb->flush_event_woken, 1);
+	wake_up(&osb->flush_event);
+}
 
 /*
  *  Transaction Handling:
@@ -292,10 +291,8 @@
  */
 int                  ocfs_journal_dirty(ocfs_journal_handle *handle, 
 					struct buffer_head *bh);
-void                 ocfs_handle_add_lock(ocfs_journal_handle *handle, 
-					  __u32 type,
-					  __u32 flags, 
-					  struct inode *inode);
+int                  ocfs_handle_add_lock(ocfs_journal_handle *handle,
+			                  struct inode *inode);
 /*
  * Use this to protect from other processes reading buffer state while
  * it's in flight.

Modified: branches/dlm-glue/src/suballoc.c
===================================================================
--- branches/dlm-glue/src/suballoc.c	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/suballoc.c	2004-10-26 01:03:25 UTC (rev 1592)
@@ -374,15 +374,12 @@
 	OCFS_ASSERT(!(handle->flags & OCFS_HANDLE_STARTED));
 
 	ocfs_handle_add_inode(handle, alloc_inode);
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE, 
-				   0, &bh, alloc_inode);
+	status = ocfs2_meta_lock(alloc_inode, handle, &bh, 1);
 	if (status < 0) {
 		if (status != -EINTR)
 			LOG_ERROR_STATUS (status);
 		goto bail;
 	}
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, 
-			     0, alloc_inode);
 
 	fe = (ocfs2_dinode *) bh->b_data;
 	OCFS_ASSERT_RO(IS_VALID_FILE_ENTRY(fe));

Modified: branches/dlm-glue/src/super.c
===================================================================
--- branches/dlm-glue/src/super.c	2004-10-26 00:58:07 UTC (rev 1591)
+++ branches/dlm-glue/src/super.c	2004-10-26 01:03:25 UTC (rev 1592)
@@ -1377,6 +1377,13 @@
 		goto done_nojournal;
 	}
 
+	atomic_set(&osb->recovery_count, 0);
+	init_waitqueue_head(&osb->recovery_event);
+	atomic_set(&osb->wake_vote_task, 0);
+	spin_lock_init(&osb->blocked_list_lock);
+	init_waitqueue_head(&osb->vote_event);
+	INIT_LIST_HEAD(&osb->blocked_inode_list);
+	INIT_LIST_HEAD(&osb->vote_list);
 	spin_lock_init(&osb->s_next_gen_lock);
 	get_random_bytes(&osb->s_next_generation, sizeof(u32));
 



More information about the Ocfs2-commits mailing list