svn commit: r303154 - head/sys/kern

Konstantin Belousov kib at FreeBSD.org
Thu Jul 21 17:07:08 UTC 2016


Author: kib
Date: Thu Jul 21 17:07:06 2016
New Revision: 303154
URL: https://svnweb.freebsd.org/changeset/base/303154

Log:
  Declare aio requests on files from local filesystems safe.
  Two notes:
  - I allow AIO on reclaimed vnodes, since it is deterministically terminated
    fast.
  - devfs mounts are marked as MNT_LOCAL, but device vnodes have type
    VCHR, so the slow device io is not allowed.
  
  Reviewed by:	jhb
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week
  Differential revision:	https://reviews.freebsd.org/D7273

Modified:
  head/sys/kern/vfs_aio.c

Modified: head/sys/kern/vfs_aio.c
==============================================================================
--- head/sys/kern/vfs_aio.c	Thu Jul 21 16:58:53 2016	(r303153)
+++ head/sys/kern/vfs_aio.c	Thu Jul 21 17:07:06 2016	(r303154)
@@ -1664,7 +1664,10 @@ aio_queue_file(struct file *fp, struct k
 	struct aioliojob *lj;
 	struct kaioinfo *ki;
 	struct kaiocb *job2;
+	struct vnode *vp;
+	struct mount *mp;
 	int error, opcode;
+	bool safe;
 
 	lj = job->lio;
 	ki = job->userproc->p_aioinfo;
@@ -1685,7 +1688,16 @@ aio_queue_file(struct file *fp, struct k
 		goto done;
 #endif
 queueit:
-	if (!enable_aio_unsafe)
+	safe = false;
+	if (fp->f_type == DTYPE_VNODE) {
+		vp = fp->f_vnode;
+		if (vp->v_type == VREG || vp->v_type == VDIR) {
+			mp = fp->f_vnode->v_mount;
+			if (mp == NULL || (mp->mnt_flag & MNT_LOCAL) != 0)
+				safe = true;
+		}
+	}
+	if (!(safe || enable_aio_unsafe))
 		return (EOPNOTSUPP);
 
 	if (opcode == LIO_SYNC) {


More information about the svn-src-all mailing list