diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2020-09-22 06:36:29 -0600 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2020-09-24 05:54:26 -0600 |
commit | edd580643f2cf1434e252cd7779e83182ea84945 (patch) | |
tree | fa5e5ad8e791f4262814e79f07e29421a5871038 /usr/src/uts/common | |
parent | 6d40a71ead689b14c68d91a5d92845e5f3daa020 (diff) | |
download | illumos-gate-edd580643f2cf1434e252cd7779e83182ea84945.tar.gz |
12363 add O_DIRECT support
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Reviewed by: C Fraire <cfraire@me.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/uts/common')
-rw-r--r-- | usr/src/uts/common/fs/vnode.c | 19 | ||||
-rw-r--r-- | usr/src/uts/common/sys/fcntl.h | 5 | ||||
-rw-r--r-- | usr/src/uts/common/sys/file.h | 3 |
3 files changed, 24 insertions, 3 deletions
diff --git a/usr/src/uts/common/fs/vnode.c b/usr/src/uts/common/fs/vnode.c index afdb3baf40..962df4ff50 100644 --- a/usr/src/uts/common/fs/vnode.c +++ b/usr/src/uts/common/fs/vnode.c @@ -21,7 +21,7 @@ /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018, Joyent, Inc. + * Copyright 2020 Joyent, Inc. * Copyright 2016 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2011, 2017 by Delphix. All rights reserved. */ @@ -51,6 +51,7 @@ #include <sys/vfs.h> #include <sys/vfs_opreg.h> #include <sys/vnode.h> +#include <sys/filio.h> #include <sys/rwstlock.h> #include <sys/fem.h> #include <sys/stat.h> @@ -1218,6 +1219,22 @@ top: if ((error = VOP_SETATTR(vp, &vattr, 0, CRED(), NULL)) != 0) goto out; } + + /* + * Turn on directio, if requested. + */ + if (filemode & FDIRECT) { + if ((error = VOP_IOCTL(vp, _FIODIRECTIO, DIRECTIO_ON, 0, + CRED(), NULL, NULL)) != 0) { + /* + * On Linux, O_DIRECT returns EINVAL when the file + * system does not support directio, so we'll do the + * same. + */ + error = EINVAL; + goto out; + } + } out: ASSERT(vp->v_count > 0); diff --git a/usr/src/uts/common/sys/fcntl.h b/usr/src/uts/common/sys/fcntl.h index cf55ebbf2a..4af23583fd 100644 --- a/usr/src/uts/common/sys/fcntl.h +++ b/usr/src/uts/common/sys/fcntl.h @@ -37,7 +37,7 @@ */ /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */ -/* Copyright 2015, Joyent, Inc. */ +/* Copyright 2020 Joyent, Inc. */ #ifndef _SYS_FCNTL_H #define _SYS_FCNTL_H @@ -89,6 +89,9 @@ extern "C" { #if !defined(_STRICT_SYMBOLS) || defined(_XPG7) #define O_DIRECTORY 0x1000000 /* fail if not a directory */ #endif +#if !defined(_STRICT_SYMBOLS) +#define O_DIRECT 0x2000000 /* direct disk access hint */ +#endif /* * fcntl(2) requests diff --git a/usr/src/uts/common/sys/file.h b/usr/src/uts/common/sys/file.h index ba3af01c7e..d300b940e2 100644 --- a/usr/src/uts/common/sys/file.h +++ b/usr/src/uts/common/sys/file.h @@ -27,7 +27,7 @@ /* All Rights Reserved */ /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */ -/* Copyright 2015 Joyent, Inc. */ +/* Copyright 2020 Joyent, Inc. */ #ifndef _SYS_FILE_H #define _SYS_FILE_H @@ -119,6 +119,7 @@ typedef struct fpollinfo { #define FCLOEXEC 0x800000 /* O_CLOEXEC = 0x800000 */ #define FDIRECTORY 0x1000000 /* O_DIRECTORY = 0x1000000 */ +#define FDIRECT 0x2000000 /* O_DIRECT = 0x2000000 */ #if defined(_KERNEL) || defined(_FAKE_KERNEL) |