summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_aio.c
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-08-01 12:53:16 -0300
committerRenato Botelho <renato@netgate.com>2016-08-01 12:53:16 -0300
commit80c20d0bef69a2c543d1bc2dddd2bc34198fec9b (patch)
treefc6009a2d49da5ab043d4c847a288f71ec6aa731 /sys/kern/vfs_aio.c
parentf235fecdc77c17505022bc5202d74f3d36b33359 (diff)
parenteed7d9e93aec04a3f6a7d157c4cac7452a6c1727 (diff)
downloadFreeBSD-src-80c20d0bef69a2c543d1bc2dddd2bc34198fec9b.zip
FreeBSD-src-80c20d0bef69a2c543d1bc2dddd2bc34198fec9b.tar.gz
Merge remote-tracking branch 'origin/stable/11' into devel-11
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