lkml.org 
[lkml]   [2023]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject[PATCH v2 0/3] fanotify accounting for fs/splice.c
"people just forget to add inotify hooks to their I/O routines as a rule"?
Guess what I did, fully knowing that some are missing in this file :)

==> te.c <==
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
int main() {
ssize_t rd, acc = 0;
while ((rd = tee(0, 1, 128 * 1024 * 1024, 0)) > 0)
acc += rd;
fprintf(stderr, "te=%zd: %m\n", acc);
}

==> vm.c <==
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
static char sb[1024 * 1024];
int main() {
memcpy(sb, "żupan", sizeof("żupan"));
ssize_t rd =
vmsplice(1, &(struct iovec){.iov_base = sb, .iov_len = sizeof(sb)}, 1,
SPLICE_F_GIFT);
fprintf(stderr, "vm=%zd: %m\n", rd);
}


echo zupa | ./te > fifo tees a few times and then blocks when the pipe
fills, at which point we get into the broken state.

Similarly, ./vm > fifo (with the default 64k F_GETPIPE_SZ) enters that
same state instantly.

With 2/3 and 3/3, they instead do
1: mask=2, cook=0, len=0, name=
rd=80
1: mask=2, cook=0, len=0, name=
rd=80
...
in a loop, as-expected, and
# ./vm > fifo
vm=65200: Success
1: mask=2, cook=0, len=0, name=
rd=65200

I took the liberty of marking 2/3 and 3/3 as Fixes: of the original
fanotify-in-splice commit as well, I think they fit the bill.

Ahelenia Ziemiańska (3):
splice: always fsnotify_access(in), fsnotify_modify(out) on success
splice: fsnotify_modify(fd) in vmsplice
splice: fsnotify_access(in), fsnotify_modify(out) on success in tee

fs/splice.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)

--
2.39.2
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2023-06-27 01:09    [W:0.074 / U:0.664 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site