summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_aio.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/vfs_aio.c')
-rw-r--r--sys/kern/vfs_aio.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
index 3c9aa44..ead5e7c 100644
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syscall.h>
#include <sys/sysent.h>
#include <sys/sysctl.h>
+#include <sys/syslog.h>
#include <sys/sx.h>
#include <sys/taskqueue.h>
#include <sys/vnode.h>
@@ -110,6 +111,11 @@ static int enable_aio_unsafe = 0;
SYSCTL_INT(_vfs_aio, OID_AUTO, enable_unsafe, CTLFLAG_RW, &enable_aio_unsafe, 0,
"Permit asynchronous IO on all file types, not just known-safe types");
+static unsigned int unsafe_warningcnt = 1;
+SYSCTL_UINT(_vfs_aio, OID_AUTO, unsafe_warningcnt, CTLFLAG_RW,
+ &unsafe_warningcnt, 0,
+ "Warnings that will be triggered upon failed IO requests on unsafe files");
+
static int max_aio_procs = MAX_AIO_PROCS;
SYSCTL_INT(_vfs_aio, OID_AUTO, max_aio_procs, CTLFLAG_RW, &max_aio_procs, 0,
"Maximum number of kernel processes to use for handling async IO ");
@@ -1664,7 +1670,10 @@ aio_queue_file(struct file *fp, struct kaiocb *job)
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,8 +1694,20 @@ aio_queue_file(struct file *fp, struct kaiocb *job)
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)) {
+ counted_warning(&unsafe_warningcnt,
+ "is attempting to use unsafe AIO requests");
return (EOPNOTSUPP);
+ }
if (opcode == LIO_SYNC) {
AIO_LOCK(ki);
OpenPOWER on IntegriCloud