From adrian@FreeBSD.org  Mon Jan 17 12:36:07 2000
Return-Path: <adrian@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21])
	by hub.freebsd.org (Postfix) with ESMTP id D4B8314E58
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Jan 2000 12:36:06 -0800 (PST)
	(envelope-from adrian@FreeBSD.org)
Received: (from adrian@localhost)
	by freefall.freebsd.org (8.9.3/8.9.2) id MAA22032;
	Mon, 17 Jan 2000 12:36:06 -0800 (PST)
	(envelope-from adrian@FreeBSD.org)
Message-Id: <200001172036.MAA22032@freefall.freebsd.org>
Date: Mon, 17 Jan 2000 12:36:06 -0800 (PST)
From: adrian@freebsd.org
Reply-To: adrian@freebsd.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: posix AIO broken for normal files
X-Send-Pr-Version: 3.2

>Number:         16163
>Category:       kern
>Synopsis:       posix AIO broken for normal files
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 17 12:40:03 PST 2000
>Closed-Date:    Tue Jan 18 05:48:16 PST 2000
>Last-Modified:  Tue Jan 18 05:48:46 PST 2000
>Originator:     Adrian Chadd
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:

4.0-CURRENT box built about 8 hours before this PR..

>Description:

Trying to use aio_* on a normal file (not a socket or a device) gives 
ENOTBLK.

The code calls aio_qphysio() which it expects to fall through with
a return value of -1 if it can't queue it the non-thread way. This
routine is only valid for VCHRs. However, the vn_isdisk() call
isn't checked to see if the return is ENOTBLK, and any error triggers
a return which causes the aio_* routines to error out without
queueing the IO request the "normal" way.

>How-To-Repeat:

Try to write some AIO code, that talks to normal disk files, and not
special stuff (sockets or VCHRs).

>Fix:
	

Index: vfs_aio.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/vfs_aio.c,v
retrieving revision 1.65
diff -u -r1.65 vfs_aio.c
--- vfs_aio.c	2000/01/14 02:53:26	1.65
+++ vfs_aio.c	2000/01/17 20:26:54
@@ -944,8 +944,16 @@
 
 	vp = (struct vnode *)fp->f_data;
 
+	/*
+	 * If its not a disk, we don't want to return a positive error.
+	 * It causes the aio code to not fall through to try the thread
+	 * way when you're talking to a regular file.
+	 */
 	if (!vn_isdisk(vp, &error))
-		return (error);
+		if (error == ENOTBLK)
+			return -1;
+		else
+			return (error);
 
  	if (cb->aio_nbytes % vp->v_rdev->si_bsize_phys)
 		return (-1);

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: adrian 
State-Changed-When: Tue Jan 18 05:48:16 PST 2000 
State-Changed-Why:  
Patch applied by green, with a quick style fix. 
>Unformatted:
