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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Jun 22 22:55:51 CDT 2004


Author: mfasheh
Date: 2004-06-22 21:55:49 -0500 (Tue, 22 Jun 2004)
New Revision: 1195

Modified:
   trunk/src/dir.c
   trunk/src/inode.c
Log:
* verify_update_inode now verifies directories too.

* take a readdir lock in ocfs_readdir (we were missing this before)



Modified: trunk/src/dir.c
===================================================================
--- trunk/src/dir.c	2004-06-23 02:27:19 UTC (rev 1194)
+++ trunk/src/dir.c	2004-06-23 02:55:49 UTC (rev 1195)
@@ -78,6 +78,8 @@
 	struct inode *inode = filp->f_dentry->d_inode;
 	struct super_block * sb = inode->i_sb;
 	int we_are_brown = 0;
+	int have_disk_lock = 0;
+	ocfs_super *osb = OCFS_SB(sb);
 
 	LOG_SET_CONTEXT(READDIR);
 
@@ -85,6 +87,33 @@
 
 	stored = 0;
 	bh = NULL;
+
+	/* NOTE: We only take a write lock here because of the
+	 * acquire_lock call. We should investigate whether taking a
+	 * read lock is such a bad idea in this case... */
+	down_write(&OCFS_I(inode)->ip_io_sem);
+
+	error = ocfs_acquire_lock(osb, OCFS_DLM_ENABLE_CACHE_LOCK,
+				  FLAG_DIR|FLAG_READDIR, NULL, inode);
+	if (error < 0) {
+		if (error != -EINTR)
+			LOG_ERROR_STATUS (error);
+		/* we haven't got any yet, so propagate the error. */
+		stored = error;
+		goto bail;
+	}
+	have_disk_lock = 1;
+
+#if 0
+	error = ocfs_verify_update_inode(osb, inode, &trunc, 0);
+	if (error < 0) {
+		LOG_ERROR_STATUS(error);
+		stored = error;
+		goto bail;
+	}
+	printk("dir (%lu) size is %llu\n", inode->i_ino, inode->i_size);
+#endif
+
 	offset = filp->f_pos & (sb->s_blocksize - 1);
 
 	while (!error && !stored && filp->f_pos < inode->i_size) {
@@ -151,7 +180,7 @@
 				filp->f_pos = (filp->f_pos |
 					       (sb->s_blocksize - 1)) + 1;
 				brelse (bh);
-				return stored;
+				goto bail;
 			}
 			offset += le16_to_cpu(de->rec_len);
 			if (le64_to_cpu(de->inode)) {
@@ -186,10 +215,23 @@
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 	update_atime(inode);
 #endif
-	LOG_EXIT_STATUS(0);
 
+	stored = 0;
+bail:
+
+	if (have_disk_lock) {
+		error = ocfs_release_lock (osb, OCFS_DLM_ENABLE_CACHE_LOCK,
+					     FLAG_DIR|FLAG_READDIR, NULL, 
+					     inode);
+		if (error < 0)
+			LOG_ERROR_STATUS (error);
+	}
+
+	up_write(&OCFS_I(inode)->ip_io_sem);
+
+	LOG_EXIT_STATUS(stored);
 	LOG_CLEAR_CONTEXT();
-	return 0;
+	return stored;
 }
 
 
@@ -207,14 +249,14 @@
 	int tmpstat;
 	int lock_acq = 0;
 	struct buffer_head *bh = NULL;
-	__u32 lock_type = OCFS_DLM_ENABLE_CACHE_LOCK;
 
 	LOG_ENTRY_ARGS ("(osb=%p, parent=%llu, name='%*s', fe_off=%p, inode=%p)\n",
 			osb, OCFS_I(inode)->ip_blkno, namelen, name, fe_off, inode);
 
 	if (take_lock) {
 		/* Get a lock on the directory... */
-		status = ocfs_acquire_lock (osb, lock_type, FLAG_DIR|FLAG_READDIR, 
+		status = ocfs_acquire_lock (osb, OCFS_DLM_ENABLE_CACHE_LOCK,
+					    FLAG_DIR|FLAG_READDIR, 
 					    &bh, inode);
 		if (status < 0) {
 			/* Volume should be disabled in this case */
@@ -238,7 +280,7 @@
 
 	if (take_lock && lock_acq)
 	{
-		tmpstat = ocfs_release_lock (osb, lock_type,
+		tmpstat = ocfs_release_lock (osb, OCFS_DLM_ENABLE_CACHE_LOCK,
 					     FLAG_DIR|FLAG_READDIR, bh, inode);
 		if (tmpstat < 0) {
 			LOG_ERROR_STATUS (tmpstat);

Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c	2004-06-23 02:27:19 UTC (rev 1194)
+++ trunk/src/inode.c	2004-06-23 02:55:49 UTC (rev 1195)
@@ -1941,10 +1941,6 @@
 
 	fe = (ocfs2_dinode *) fe_bh->b_data;
 
-	/* Make sure that what we found is not a directory. */
-	if (S_ISDIR(inode->i_mode))
-		goto leave;
-
 	/* Add checks as needed */
 	if ((fe->i_dtime) || (!(fe->i_flags & OCFS2_VALID_FL))) {
 		if (fe->i_dtime)



More information about the Ocfs2-commits mailing list