[Ocfs2-commits] zab commits r2468 - trunk/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Jul 12 18:09:55 CDT 2005


Author: zab
Signed-off-by: mfasheh
Date: 2005-07-12 18:09:53 -0500 (Tue, 12 Jul 2005)
New Revision: 2468

Modified:
   trunk/fs/ocfs2/aio.c
Log:
o don't return ERESTARTSYS from aio_{read,write}, it gets sent straight to
  userspace via the AIO core.

Signed-off-by: mfasheh


Modified: trunk/fs/ocfs2/aio.c
===================================================================
--- trunk/fs/ocfs2/aio.c	2005-07-11 21:43:21 UTC (rev 2467)
+++ trunk/fs/ocfs2/aio.c	2005-07-12 23:09:53 UTC (rev 2468)
@@ -220,8 +220,27 @@
 	struct file *filp = iocb->ki_filp;
 	struct inode *inode = filp->f_dentry->d_inode;
 	struct ocfs2_backing_inode *target_binode;
-	ssize_t ret;
+	ssize_t ret, ret2;
+	sigset_t blocked, oldset;
 
+	/*
+	 * The DLM doesn't block waiting for network traffic or anything, it
+	 * modifies state and calls our callback when things have changed.
+	 * However, it still likes to check signals and return ERESTARTSYS.
+	 * The AIO core does not appreciate ERESTARTSYS as its semantics are
+	 * not exactly clear for submission, etc.  So we block signals and
+	 * ensure that the DLM won't notice them.  The caller, particularly
+	 * sys_io_getevents(), will eventually check signals before sleeping
+	 * and so things should still work as expected, if perhaps with
+	 * slightly higher signal delivery latency.
+	 */
+	sigfillset(&blocked);
+	ret = sigprocmask(SIG_BLOCK, &blocked, &oldset);
+	if (ret < 0) {
+		mlog_errno(ret);
+		goto out;
+	}
+
 	mlog(0, "iocb %p okp %p\n", iocb, okp);
 
 	if (okp == NULL) {
@@ -229,14 +248,14 @@
 		if (IS_ERR(okp)) {
 			ret = PTR_ERR(okp);
 			mlog_errno(ret);
-			goto out;
+			goto setmask;
 		}
 
 		ret = ocfs2_setup_io_locks(inode->i_sb, inode, buf, count,
 					   &okp->kp_ctxt, &target_binode);
 		if (ret < 0) {
 			mlog_errno(ret);
-			goto out;
+			goto setmask;
 		}
 
 		okp->kp_ctxt.b_cb = ocfs2_aio_kick;
@@ -251,7 +270,7 @@
 	ret = ocfs2_lock_buffer_inodes(&okp->kp_ctxt, NULL);
 	if (ret < 0) {
 		mlog_errno(ret);
-		goto out;
+		goto setmask;
 	}
 
 	/* hold the ip_alloc_sem across the op */
@@ -261,6 +280,15 @@
 	}
 
 	ret = generic_file_aio_read(iocb, buf, count, pos);
+
+setmask:
+	ret2 = sigprocmask(SIG_SETMASK, &oldset, NULL);
+	if (ret2 < 0) {
+		mlog_errno(ret2);
+		if (ret == 0)
+			ret = ret2;
+	}
+
 out:
 	/* ki_dtor will always be called eventually, no tear down here */
 	mlog(0, "iocb %p returning %lld\n", iocb, (long long)ret);
@@ -275,10 +303,19 @@
 	struct ocfs2_kiocb_private *okp = iocb->private;
 	struct file *filp = iocb->ki_filp;
 	struct inode *inode = filp->f_dentry->d_inode;
-	ssize_t ret = 0;
+	ssize_t ret = 0, ret2;
+	sigset_t blocked, oldset;
 	struct iovec local_iov = { .iov_base = (void __user *)buf,
 				   .iov_len = count };
 
+	/* explained up in ocfs2_file_aio_read() */
+	sigfillset(&blocked);
+	ret = sigprocmask(SIG_BLOCK, &blocked, &oldset);
+	if (ret < 0) {
+		mlog_errno(ret);
+		goto out;
+	}
+
 	mlog(0, "iocb %p okp %p\n", iocb, okp);
 
 	if (okp == NULL) {
@@ -286,7 +323,7 @@
 		if (IS_ERR(okp)) {
 			ret = PTR_ERR(okp);
 			mlog_errno(ret);
-			goto out;
+			goto up_io;
 		}
 
 		okp->kp_ctxt.b_cb = ocfs2_aio_kick;
@@ -314,7 +351,7 @@
 		}
 		if (ret) {
 			mlog_errno(ret);
-			goto out;
+			goto up_io;
 		}
 	}
 
@@ -324,7 +361,7 @@
 		okp->kp_have_alloc_sem = 1;
 	}
 
-out:
+up_io:
 	/*
 	 * never hold i_sem when we leave this function, nor when we call
 	 * g_f_a_w().  we've done all extending and inode field updating under
@@ -339,6 +376,13 @@
 		ret = generic_file_aio_write_nolock(iocb, &local_iov, 1,
 						    &iocb->ki_pos);
 
+	ret2 = sigprocmask(SIG_SETMASK, &oldset, NULL);
+	if (ret2 < 0) {
+		mlog_errno(ret2);
+		if (ret == 0)
+			ret = ret2;
+	}
+out:
 	/* ki_dtor will always be called eventually, no tear down here */
 	mlog(0, "iocb %p returning %lld\n", iocb, (long long)ret);
 	return ret;



More information about the Ocfs2-commits mailing list