[Ocfs2-commits] khackel commits r1268 - trunk/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Jul 15 13:33:49 CDT 2004


Author: khackel
Date: 2004-07-15 12:33:47 -0500 (Thu, 15 Jul 2004)
New Revision: 1268

Modified:
   trunk/src/file.c
Log:
fiddling with directio read/write some more

Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c	2004-07-15 03:09:55 UTC (rev 1267)
+++ trunk/src/file.c	2004-07-15 17:33:47 UTC (rev 1268)
@@ -660,6 +660,8 @@
 	int status;
 	__u64 newsize;
 	struct super_block *sb = inode->i_sb;
+	int do_direct_io = 0;
+	int sector_size;
 
 	LOG_SET_CONTEXT(WRITE);
 
@@ -680,6 +682,7 @@
 	}
 
 	osb = OCFS_SB(inode->i_sb);
+	sector_size = 1 << osb->s_sectsize_bits;
 
 	if (osb->osb_flags & OCFS_OSB_FLAGS_SHUTDOWN) {
 		LOG_TRACE_STR ("Volume has already started shutdown");
@@ -693,17 +696,16 @@
 		*ppos = inode->i_size;
 	}
 
-#if 0
-	int sector_size = 1 << osb->s_sectsize_bits;
 	if (filp->f_flags & O_DIRECT) {
 		/* anything special for o_direct? */
 		LOG_TRACE_STR ("O_DIRECT");
 		if (((*ppos) & (sector_size - 1)) || (count & (sector_size - 1)) || 
 		    ((unsigned long)buf & (sector_size - 1)) || (inode->i_size & (sector_size - 1))) {
-			filp->f_flags &= ~O_DIRECT;
-		}
+			do_direct_io = 0;
+			filp->f_flags |= O_SYNC;
+		} else
+			do_direct_io = 1;
 	}
-#endif
 
 	if (atomic_read(&OCFS_I(inode)->ip_needs_verification)) {
 		LOG_TRACE_STR ("OIN_NEEDS_VERIFICATION");
@@ -767,9 +769,19 @@
 	 * direct-io is pass in method for getting blocks via the
 	 * address_space_operations struct
 	 */
-	ret = generic_file_write (filp, buf, count, ppos);
+	{
+		/* ick.  seems to be our only way of toggling 
+		 * directio for 2.6 */
+		unsigned int savedflags = filp->f_flags;
+		if (do_direct_io) 
+			filp->f_flags |= O_DIRECT;
+		else
+			filp->f_flags &= ~O_DIRECT;
+		ret = generic_file_write (filp, buf, count, ppos);
+		filp->f_flags = savedflags;
+	}
 #else
-	if (filp->f_flags & O_DIRECT)
+	if (do_direct_io)
 		ret = ocfs_rw_direct (WRITE, filp, (char *) buf, count, ppos);
 	else
 		ret = generic_file_write (filp, buf, count, ppos);
@@ -822,11 +834,11 @@
 	if (filp->f_flags & O_DIRECT) {
 		/* anything special for o_direct? */
 		LOG_TRACE_STR ("O_DIRECT");
-
 		if (((*ppos) & (sector_size - 1)) || (count & (sector_size - 1)) || 
 		    ((unsigned long)buf & (sector_size - 1)) || (inode->i_size & (sector_size - 1))) {
-			filp->f_flags &= ~O_DIRECT;
-		}
+			do_direct_io = 0;
+		} else
+			do_direct_io = 1;
 	}
 
 	if (atomic_read(&OCFS_I(inode)->ip_needs_verification)) {
@@ -847,9 +859,21 @@
 	 * direct-io is pass in method for getting blocks via the
 	 * address_space_operations struct
 	 */
+	{
+		/* ick.  seems to be our only way of toggling 
+		 * directio for 2.6 */
+		unsigned int savedflags = filp->f_flags;
+		if (do_direct_io) 
+			filp->f_flags |= O_DIRECT;
+		else
+			filp->f_flags &= ~O_DIRECT;
+		ret = generic_file_write (filp, buf, count, ppos);
+		filp->f_flags = savedflags;
+	}
+
 	ret = generic_file_read (filp, buf, count, ppos);
 #else
-	if (filp->f_flags & O_DIRECT)
+	if (do_direct_io)
 		ret = ocfs_rw_direct (READ, filp, buf, count, ppos);
 	else
 		ret = generic_file_read (filp, buf, count, ppos);



More information about the Ocfs2-commits mailing list