2015-12-15 15:59:39

by Stanislav Kinsburskiy

[permalink] [raw]
Subject: [PATCH] fcntl: allow to set O_DIRECT flag on pipe

With packetized mode for pipes, it's not possible to set O_DIRECT on pipe file
via sys_fcntl, because of unsupported (by pipes) sanity checks.
Ability to set this flag will be used by CRIU to migrate packetized pipes.

Signed-off-by: Stanislav Kinsburskiy <[email protected]>
---
fs/fcntl.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/fcntl.c b/fs/fcntl.c
index ee85cd4..4463a87 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -51,7 +51,8 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
if (arg & O_NDELAY)
arg |= O_NONBLOCK;

- if (arg & O_DIRECT) {
+ /* Pipe packetized mode is controlled by O_DIRECT flag */
+ if (!IS_FIFO(f->f_mode) && (arg & O_DIRECT)) {
if (!filp->f_mapping || !filp->f_mapping->a_ops ||
!filp->f_mapping->a_ops->direct_IO)
return -EINVAL;


2015-12-15 16:15:25

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] fcntl: allow to set O_DIRECT flag on pipe

Hi Stanislav,

[auto build test ERROR on v4.4-rc5]
[also build test ERROR on next-20151215]

url: https://github.com/0day-ci/linux/commits/Stanislav-Kinsburskiy/fcntl-allow-to-set-O_DIRECT-flag-on-pipe/20151216-000234
config: x86_64-randconfig-x011-12141150 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All errors (new ones prefixed by >>):

fs/fcntl.c: In function 'setfl':
>> fs/fcntl.c:55:7: error: implicit declaration of function 'IS_FIFO' [-Werror=implicit-function-declaration]
if (!IS_FIFO(f->f_mode) && (arg & O_DIRECT)) {
^
>> fs/fcntl.c:55:15: error: 'f' undeclared (first use in this function)
if (!IS_FIFO(f->f_mode) && (arg & O_DIRECT)) {
^
fs/fcntl.c:55:15: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errors

vim +/IS_FIFO +55 fs/fcntl.c

49 /* required for strict SunOS emulation */
50 if (O_NONBLOCK != O_NDELAY)
51 if (arg & O_NDELAY)
52 arg |= O_NONBLOCK;
53
54 /* Pipe packetized mode is controlled by O_DIRECT flag */
> 55 if (!IS_FIFO(f->f_mode) && (arg & O_DIRECT)) {
56 if (!filp->f_mapping || !filp->f_mapping->a_ops ||
57 !filp->f_mapping->a_ops->direct_IO)
58 return -EINVAL;

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (1.49 kB)
.config.gz (20.73 kB)
Download all attachments

2015-12-15 16:16:46

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] fcntl: allow to set O_DIRECT flag on pipe

Hi Stanislav,

[auto build test WARNING on v4.4-rc5]
[also build test WARNING on next-20151215]

url: https://github.com/0day-ci/linux/commits/Stanislav-Kinsburskiy/fcntl-allow-to-set-O_DIRECT-flag-on-pipe/20151216-000234
config: i386-randconfig-x009-12141102 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All warnings (new ones prefixed by >>):

In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/linux/syscalls.h:70,
from fs/fcntl.c:7:
fs/fcntl.c: In function 'setfl':
fs/fcntl.c:55:7: error: implicit declaration of function 'IS_FIFO' [-Werror=implicit-function-declaration]
if (!IS_FIFO(f->f_mode) && (arg & O_DIRECT)) {
^
include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
if (__builtin_constant_p((cond)) ? !!(cond) : \
^
>> fs/fcntl.c:55:2: note: in expansion of macro 'if'
if (!IS_FIFO(f->f_mode) && (arg & O_DIRECT)) {
^
fs/fcntl.c:55:15: error: 'f' undeclared (first use in this function)
if (!IS_FIFO(f->f_mode) && (arg & O_DIRECT)) {
^
include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
if (__builtin_constant_p((cond)) ? !!(cond) : \
^
>> fs/fcntl.c:55:2: note: in expansion of macro 'if'
if (!IS_FIFO(f->f_mode) && (arg & O_DIRECT)) {
^
fs/fcntl.c:55:15: note: each undeclared identifier is reported only once for each function it appears in
if (!IS_FIFO(f->f_mode) && (arg & O_DIRECT)) {
^
include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
if (__builtin_constant_p((cond)) ? !!(cond) : \
^
>> fs/fcntl.c:55:2: note: in expansion of macro 'if'
if (!IS_FIFO(f->f_mode) && (arg & O_DIRECT)) {
^
cc1: some warnings being treated as errors

vim +/if +55 fs/fcntl.c

1 /*
2 * linux/fs/fcntl.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
> 7 #include <linux/syscalls.h>
8 #include <linux/init.h>
9 #include <linux/mm.h>
10 #include <linux/fs.h>
11 #include <linux/file.h>
12 #include <linux/fdtable.h>
13 #include <linux/capability.h>
14 #include <linux/dnotify.h>
15 #include <linux/slab.h>
16 #include <linux/module.h>
17 #include <linux/pipe_fs_i.h>
18 #include <linux/security.h>
19 #include <linux/ptrace.h>
20 #include <linux/signal.h>
21 #include <linux/rcupdate.h>
22 #include <linux/pid_namespace.h>
23 #include <linux/user_namespace.h>
24 #include <linux/shmem_fs.h>
25
26 #include <asm/poll.h>
27 #include <asm/siginfo.h>
28 #include <asm/uaccess.h>
29
30 #define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | O_DIRECT | O_NOATIME)
31
32 static int setfl(int fd, struct file * filp, unsigned long arg)
33 {
34 struct inode * inode = file_inode(filp);
35 int error = 0;
36
37 /*
38 * O_APPEND cannot be cleared if the file is marked as append-only
39 * and the file is open for write.
40 */
41 if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
42 return -EPERM;
43
44 /* O_NOATIME can only be set by the owner or superuser */
45 if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
46 if (!inode_owner_or_capable(inode))
47 return -EPERM;
48
49 /* required for strict SunOS emulation */
50 if (O_NONBLOCK != O_NDELAY)
51 if (arg & O_NDELAY)
52 arg |= O_NONBLOCK;
53
54 /* Pipe packetized mode is controlled by O_DIRECT flag */
> 55 if (!IS_FIFO(f->f_mode) && (arg & O_DIRECT)) {
56 if (!filp->f_mapping || !filp->f_mapping->a_ops ||
57 !filp->f_mapping->a_ops->direct_IO)
58 return -EINVAL;

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (4.24 kB)
.config.gz (22.68 kB)
Download all attachments