[Ocfs2-commits] mfasheh commits r1367 - trunk/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Aug 20 16:02:44 CDT 2004


Author: mfasheh
Date: 2004-08-20 15:02:42 -0500 (Fri, 20 Aug 2004)
New Revision: 1367

Modified:
   trunk/src/dlm.c
   trunk/src/dlm.h
   trunk/src/file.c
   trunk/src/namei.c
Log:
* fix up rename as we weren't doing a change master when we move
  directories.



Modified: trunk/src/dlm.c
===================================================================
--- trunk/src/dlm.c	2004-08-20 17:48:53 UTC (rev 1366)
+++ trunk/src/dlm.c	2004-08-20 20:02:42 UTC (rev 1367)
@@ -431,26 +431,22 @@
 	return status;
 }				/* ocfs_update_disk_lock */
 
-/*
- * ocfs_notify_on_open()
- *
- * 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).
- */
-int ocfs_notify_on_open (ocfs_super * osb, struct inode *inode)
+int ocfs_notify_cluster(ocfs_super *osb, 
+			struct inode *inode,
+			u32 message_flags)
 {
 	int status = -EAGAIN;
 	int disk_vote = 0;
 	ocfs_lock_res *lockres = GET_INODE_LOCKRES(inode);
 	u32 flags;
 
-	LOG_ENTRY ();
+	LOG_ENTRY_ARGS("(inode = %llu, flags = 0x%x)\n", 
+		       OCFS_I(inode)->ip_blkno, message_flags);
 
 	while (status == -EAGAIN) {
 		ocfs_acquire_lockres(lockres, 0); // ocfs_file_open 
 
-		flags = FLAG_TRUNCATE_PAGES;
+		flags = message_flags;
 		if (ocfs_inode_is_new(osb, inode))
 			flags |= FLAG_FAST_PATH_LOCK;
 
@@ -476,11 +472,10 @@
 		}
 		ocfs_release_lockres (lockres); // ocfs_file_open 
 	}
-
 bail:
 	LOG_EXIT_STATUS (status);
 	return status;
-}				/* ocfs_notify_on_open */
+}
 
 enum {
 	invalid_path = 0,
@@ -651,7 +646,7 @@
 
 	/* some lock requests are simple messages and don't require a
 	 * master change. */
-	if ((flags & FLAG_TRUNCATE_PAGES) || (flags & FLAG_FILE_RENAME))
+	if (flags & FLAG_TRUNCATE_PAGES)
 		goto do_lock;
 
 	if ((lockres->master_node_num != osb->node_num)
@@ -1023,7 +1018,7 @@
 vote_success:
 	if (need_to_zap_buffers)
 		ocfs_inc_inode_seq(osb, inode);
-	
+
 	/* just alerting owner on open */
 	if (flags & FLAG_TRUNCATE_PAGES)
 		goto bail;

Modified: trunk/src/dlm.h
===================================================================
--- trunk/src/dlm.h	2004-08-20 17:48:53 UTC (rev 1366)
+++ trunk/src/dlm.h	2004-08-20 20:02:42 UTC (rev 1367)
@@ -41,8 +41,24 @@
 	ocfs_release_lock_full(osb, lock_type, flags, inode, 1)
 int ocfs_release_lock_full(ocfs_super *osb, __u32 lock_type,
 			   __u32 flags, struct inode *inode, __u32 num_ident);
-int ocfs_notify_on_open(ocfs_super *osb, struct inode *inode);
 void ocfs_get_publish_vote_map(ocfs_super *osb, ocfs_publish *publish,
 			       ocfs_node_map *vote_map);
+int ocfs_notify_cluster(ocfs_super *osb, 
+			struct inode *inode,
+			u32 message_flags);
+static inline int ocfs_notify_on_rename(ocfs_super *osb, struct inode *inode)
+{
+	/* whatcha tryin' to do to us! */
+	OCFS_ASSERT(!S_ISDIR(inode->i_mode));
 
+	return(ocfs_notify_cluster(osb, 
+				   inode, 
+				   FLAG_RELEASE_DENTRY|FLAG_FILE_RENAME));
+}
+static inline int ocfs_notify_on_open(ocfs_super *osb, struct inode *inode)
+{
+	return(ocfs_notify_cluster(osb, 
+				   inode, 
+				   FLAG_TRUNCATE_PAGES));
+}
 #endif /* OCFS2_DLM_H */

Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c	2004-08-20 17:48:53 UTC (rev 1366)
+++ trunk/src/file.c	2004-08-20 20:02:42 UTC (rev 1367)
@@ -219,6 +219,10 @@
 		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))))

Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c	2004-08-20 17:48:53 UTC (rev 1366)
+++ trunk/src/namei.c	2004-08-20 20:02:42 UTC (rev 1367)
@@ -963,12 +963,11 @@
 	ocfs2_dinode *newfe = NULL;
 	struct buffer_head *newfe_bh = NULL;
 	ocfs_super *osb = NULL;
-	__u64 oldfe_lockid;
 	u64 newfe_blkno;
 	ocfs_journal_handle *handle = NULL;
 	struct buffer_head *old_dir_bh = NULL;
 	struct buffer_head *new_dir_bh = NULL;
-	__u32 oldfe_flags = FLAG_RELEASE_DENTRY | FLAG_FILE_RENAME;
+	__u32 oldfe_flags;
 	__u32 newfe_flags = FLAG_RELEASE_DENTRY;
 	struct ocfs2_dir_entry *old_de = NULL, *new_de = NULL; // dirent for old_dentry 
 							       // and new_dentry
@@ -986,8 +985,6 @@
 
 	osb = OCFS_SB(old_dir->i_sb);
 
-	oldfe_lockid = OCFS_I(old_inode)->ip_blkno << old_inode->i_sb->s_blocksize_bits;
-
 	double_down_write(&OCFS_I(old_dir)->ip_io_sem, 
 			  &OCFS_I(new_dir)->ip_io_sem);
 	down_write(&OCFS_I(old_inode)->ip_io_sem);
@@ -1046,19 +1043,22 @@
 		}
 	}
 
-	if (S_ISDIR(old_inode->i_mode))
-		oldfe_flags = FLAG_DIR;
+	if (S_ISDIR(old_inode->i_mode)) {
+		/* Directories actually require metadata updates to
+		 * the directory info so we can't get away with not
+		 * doing node locking on it. */
+		oldfe_flags  = FLAG_RELEASE_DENTRY|FLAG_FILE_RENAME|FLAG_DIR;
 
-	status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE,
-				   oldfe_flags, NULL, old_inode);
-	if (status < 0) {
-		LOG_ERROR_STATUS(status);
-		goto finally;
-	}
+		status = ocfs_acquire_lock(osb, OCFS_LKM_EXMODE,
+					   oldfe_flags, NULL, old_inode);
+		if (status < 0) {
+			LOG_ERROR_STATUS(status);
+			goto finally;
+		}
 
-	ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, oldfe_flags, old_inode);
+		ocfs_handle_add_lock(handle, OCFS_LKM_EXMODE, oldfe_flags, 
+				     old_inode);
 
-	if (S_ISDIR(old_inode->i_mode)) {
 		status = -EIO;
 		old_inode_de_bh = ocfs_bread (handle, old_inode, 0, 0, &status, 0);
 		if (!old_inode_de_bh)
@@ -1072,6 +1072,14 @@
 		if (!new_inode && new_dir!=old_dir &&
 		    new_dir->i_nlink >= OCFS2_LINK_MAX)
 			goto finally;
+	} else {
+		/* Ah, the simple case - we're a file so just send a
+		 * message. */
+		status = ocfs_notify_on_rename(osb, old_inode);
+		if (status < 0) {
+			LOG_ERROR_STATUS(status);
+			goto finally;
+		}
 	}
 	
 	status = -ENOENT;
@@ -1199,7 +1207,8 @@
 	} else {
 		/* if the name was not found in new_dir, add it now */
 		status = ocfs_add_entry (handle, new_dentry, old_inode, 
-					 oldfe_lockid >> old_inode->i_sb->s_blocksize_bits, new_dir_bh);
+					 OCFS_I(old_inode)->ip_blkno, 
+					 new_dir_bh);
 	}
 
 finally:



More information about the Ocfs2-commits mailing list