[Ocfs2-commits] zab commits r2641 - in branches/locking-changes: Documentation/filesystems fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Oct 6 16:42:27 CDT 2005


Author: zab
Signed-off-by: mfasheh
Date: 2005-10-06 16:42:25 -0500 (Thu, 06 Oct 2005)
New Revision: 2641

Modified:
   branches/locking-changes/Documentation/filesystems/ocfs2.txt
   branches/locking-changes/fs/ocfs2/aops.c
   branches/locking-changes/fs/ocfs2/file.c
Log:
o fix up o_direct's i_alloc_sem/rw_lock ordering to match setattr

Signed-off-by: mfasheh
  


Modified: branches/locking-changes/Documentation/filesystems/ocfs2.txt
===================================================================
--- branches/locking-changes/Documentation/filesystems/ocfs2.txt	2005-10-05 23:04:11 UTC (rev 2640)
+++ branches/locking-changes/Documentation/filesystems/ocfs2.txt	2005-10-06 21:42:25 UTC (rev 2641)
@@ -42,10 +42,10 @@
 O_DIRECT file write:
 + ocfs2_file_aio_write
   ( i_sem
+  ( i_alloc_sem
   ( rw_lock
   () meta_lock
   + __blkdev_direct_IO
-    ( i_alloc_sem
     + ocfs2_direct_io_get_blocks
       ( meta_lock
       ( ip_alloc_sem
@@ -53,9 +53,9 @@
       ) meta_lock
   ) i_sem
 + dio_complete
-    ) i_alloc_sem
   + ocfs2_dio_end_io
     ) rw_lock
+    ) i_alloc_sem
 
 buffered file read (nopage when buf is mmaped):
 + ocfs2_file_aio_read
@@ -79,17 +79,17 @@
 
 O_DIRECT file read:
 + ocfs2_file_aio_read
+  ( i_alloc_sem
+  ) rw_lock
   + __blkdev_direct_IO
-    () i_sem
-    ( i_alloc_sem
     + ocfs2_direct_io_get_blocks
       ( meta_lock
       ( ip_alloc_sem
       ) ip_alloc_sem
       ) meta_lock
 + dio_complete
+  + ocfs2_dio_end_io
     ) i_alloc_sem
-  + ocfs2_dio_end_io
     ) rw_lock
 
 truncate:

Modified: branches/locking-changes/fs/ocfs2/aops.c
===================================================================
--- branches/locking-changes/fs/ocfs2/aops.c	2005-10-05 23:04:11 UTC (rev 2640)
+++ branches/locking-changes/fs/ocfs2/aops.c	2005-10-06 21:42:25 UTC (rev 2641)
@@ -595,6 +595,7 @@
 	/* this io's submitter should not have unlocked this before we could */
 	BUG_ON(!ocfs2_iocb_is_rw_locked(iocb));
 	ocfs2_iocb_clear_rw_locked(iocb);
+	up_read(&inode->i_alloc_sem);
 	ocfs2_rw_unlock(inode, 0);
 }
 
@@ -609,9 +610,11 @@
 	int ret;
 
 	mlog_entry_void();
-	ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
-				 offset, nr_segs, ocfs2_direct_IO_get_blocks,
-				 ocfs2_dio_end_io);
+	ret = blockdev_direct_IO_no_locking(rw, iocb, inode,
+					    inode->i_sb->s_bdev, iov, offset,
+					    nr_segs, 
+					    ocfs2_direct_IO_get_blocks,
+					    ocfs2_dio_end_io);
 	mlog_exit(ret);
 	return ret;
 }

Modified: branches/locking-changes/fs/ocfs2/file.c
===================================================================
--- branches/locking-changes/fs/ocfs2/file.c	2005-10-05 23:04:11 UTC (rev 2640)
+++ branches/locking-changes/fs/ocfs2/file.c	2005-10-06 21:42:25 UTC (rev 2641)
@@ -882,7 +882,7 @@
 {
 	struct iovec local_iov = { .iov_base = (void __user *)buf,
 				   .iov_len = count };
-	int ret, rw_level = -1, meta_level = -1;
+	int ret, rw_level = -1, meta_level = -1, have_alloc_sem = 0;
 	u32 clusters;
 	struct file *filp = iocb->ki_filp;
 	struct inode *inode = filp->f_dentry->d_inode;
@@ -915,6 +915,11 @@
 
 
 	down(&inode->i_sem);
+	/* to match setattr's i_sem -> i_alloc_sem -> rw_lock ordering */
+	if (filp->f_flags & O_DIRECT) {
+		have_alloc_sem = 1;
+		down_read(&inode->i_alloc_sem);
+	}
 
 	/* concurrent O_DIRECT writes are allowed */
 	rw_level = (filp->f_flags & O_DIRECT) ? 0 : 1;
@@ -1039,12 +1044,16 @@
 	 * async dio is going to do it in the future or an end_io after an
 	 * error has already done it.
 	 */
-	if (ret == -EIOCBQUEUED || !ocfs2_iocb_is_rw_locked(iocb))
+	if (ret == -EIOCBQUEUED || !ocfs2_iocb_is_rw_locked(iocb)) {
 		rw_level = -1;
+		have_alloc_sem = 0;
+	}
 
 out:
 	if (meta_level != -1)
 		ocfs2_meta_unlock(inode, meta_level);
+	if (have_alloc_sem)
+		up_read(&inode->i_alloc_sem);
 	if (rw_level != -1) 
 		ocfs2_rw_unlock(inode, rw_level);
 	up(&inode->i_sem);
@@ -1058,7 +1067,7 @@
 				   size_t count,
 				   loff_t pos)
 {
-	int ret = 0, rw_level = -1;
+	int ret = 0, rw_level = -1, have_alloc_sem = 0;
 	struct file *filp = iocb->ki_filp;
 	struct inode *inode = filp->f_dentry->d_inode;
 #ifdef OCFS2_ORACORE_WORKAROUNDS
@@ -1096,6 +1105,9 @@
 	 * need locks to protect pending reads from racing with truncate.
 	 */
 	if (filp->f_flags & O_DIRECT) {
+		down_read(&inode->i_alloc_sem);
+		have_alloc_sem = 1;
+
 		ret = ocfs2_rw_lock(inode, 0);
 		if (ret < 0) {
 			mlog_errno(ret);
@@ -1114,10 +1126,14 @@
 	BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT));
 
 	/* see ocfs2_file_aio_write */
-	if (ret == -EIOCBQUEUED || !ocfs2_iocb_is_rw_locked(iocb))
+	if (ret == -EIOCBQUEUED || !ocfs2_iocb_is_rw_locked(iocb)) {
 		rw_level = -1;
+		have_alloc_sem = 0;
+	}
 
 bail:
+	if (have_alloc_sem)
+		up_read(&inode->i_alloc_sem);
 	if (rw_level != -1) 
 		ocfs2_rw_unlock(inode, rw_level);
 	mlog_exit(ret);



More information about the Ocfs2-commits mailing list