linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: наб <nabijaczleweli@nabijaczleweli.xyz>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jan Kara <jack@suse.cz>,
	Chung-Chiang Cheng <cccheng@synology.com>
Subject: Re: [PATCH v2 0/3] fanotify accounting for fs/splice.c
Date: Tue, 27 Jun 2023 09:14:21 +0300	[thread overview]
Message-ID: <CAOQ4uxh7i_s4R9pFJPENALdWGG5-dDhqPLEUXuJqSoHraktFiA@mail.gmail.com> (raw)
In-Reply-To: <pw3ljisf6ctpku2o44bdy3aaqdt4ofnedrdt4a4qylhasxsli6@wxhy3nsjcwn4>

On Tue, Jun 27, 2023 at 2:08 AM наб <nabijaczleweli@nabijaczleweli.xyz> wrote:
>
> "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.
>

Thank you for doing this thorough research on all the variants!

It would be great if you could add test coverage for these syscalls.

Simplest would be to clone an LTP inotify test, e.g.
ltp/testcases/kernel/syscalls/inotify/inotify01

for the different splice syscall variants (sendfile as well).

LTP already has other tests for all those syscalls, so there are plenty
of examples of how to use the LTP helpers to test those syscalls.

You can either clone one inotify test per syscall, or clone one inotify
test that creates a fifo instead of a file that inotify watches
and use a test cases array for the different syscalls to test
(see example of test cases array in inotify10 test).

Thanks,
Amir.

  reply	other threads:[~2023-06-27  6:14 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26  3:04 splice(-> FIFO) never wakes up inotify IN_MODIFY? Ahelenia Ziemiańska
2023-06-26  6:11 ` Amir Goldstein
2023-06-26 12:19   ` Ahelenia Ziemiańska
2023-06-26 12:57     ` Ahelenia Ziemiańska
2023-06-26 13:51       ` Jan Kara
2023-06-26 14:25         ` Ahelenia Ziemiańska
2023-06-26 15:00           ` Jan Kara
2023-06-26 15:15             ` Ahelenia Ziemiańska
2023-06-26 16:52               ` Jan Kara
2023-06-26 14:53     ` Amir Goldstein
2023-06-26 15:12       ` Ahelenia Ziemiańska
2023-06-26 16:21         ` Amir Goldstein
2023-06-26 17:14           ` Ahelenia Ziemiańska
2023-06-26 18:57             ` Amir Goldstein
2023-06-26 23:08               ` [PATCH v2 0/3] fanotify accounting for fs/splice.c наб
2023-06-27  6:14                 ` Amir Goldstein [this message]
2023-06-27 16:55                   ` [PATCH v3 0/3+1] " Ahelenia Ziemiańska
2023-06-27 16:55                     ` [PATCH v3 1/3] splice: always fsnotify_access(in), fsnotify_modify(out) on success Ahelenia Ziemiańska
2023-06-27 18:10                       ` Amir Goldstein
2023-06-27 20:13                         ` Ahelenia Ziemiańska
2023-06-27 16:55                     ` [PATCH v3 2/3] splice: fsnotify_access(fd)/fsnotify_modify(fd) in vmsplice Ahelenia Ziemiańska
2023-06-27 18:11                       ` Amir Goldstein
2023-06-27 16:55                     ` [PATCH v3 3/3] splice: fsnotify_access(in), fsnotify_modify(out) on success in tee Ahelenia Ziemiańska
2023-06-27 16:57                     ` [LTP PATCH] inotify13: new test for fs/splice.c functions vs pipes vs inotify Ahelenia Ziemiańska
2023-06-27 18:31                       ` Amir Goldstein
2023-06-27 20:59                         ` [LTP RFC PATCH v2] " Ahelenia Ziemiańska
2023-06-28  0:21                           ` [LTP RFC PATCH v3] " Ahelenia Ziemiańska
2023-06-28  5:30                             ` Amir Goldstein
2023-06-28 16:03                               ` Ahelenia Ziemiańska
2023-06-27 22:57                         ` [LTP PATCH] " Petr Vorel
2023-06-27 18:03                     ` [PATCH v3 0/3+1] fanotify accounting for fs/splice.c Amir Goldstein
2023-06-27 20:34                       ` Ahelenia Ziemiańska
2023-06-27 20:50                         ` [PATCH v4 0/3] " Ahelenia Ziemiańska
2023-06-27 20:50                           ` [PATCH v4 1/3] splice: always fsnotify_access(in), fsnotify_modify(out) on success Ahelenia Ziemiańska
2023-06-28  6:33                             ` Amir Goldstein
2023-06-28 10:11                               ` Jan Kara
2023-06-28 17:09                               ` Ahelenia Ziemiańska
2023-06-28 18:38                                 ` Amir Goldstein
2023-06-28 20:18                                   ` Ahelenia Ziemiańska
2023-06-30 11:03                                     ` Amir Goldstein
2023-06-27 20:50                           ` [PATCH v4 2/3] splice: fsnotify_access(fd)/fsnotify_modify(fd) in vmsplice Ahelenia Ziemiańska
2023-06-27 20:51                           ` [PATCH v4 3/3] splice: fsnotify_access(in), fsnotify_modify(out) on success in tee Ahelenia Ziemiańska
2023-06-28  6:02                           ` [PATCH v4 0/3] fanotify accounting for fs/splice.c Amir Goldstein
2023-06-28 11:38                           ` Jan Kara
2023-06-28 13:41                             ` Amir Goldstein
2023-06-28 18:54                             ` Ahelenia Ziemiańska
2023-06-29  8:45                               ` Jan Kara
2023-06-28  4:51                     ` [PATCH v3 0/3+1] " Christoph Hellwig
2023-06-28 10:38                       ` Jan Kara
2023-06-26 23:09               ` [PATCH v2 1/3] splice: always fsnotify_access(in), fsnotify_modify(out) on success Ahelenia Ziemiańska
2023-06-27  6:02                 ` Amir Goldstein
2023-06-26 23:09               ` [PATCH v2 2/3] splice: fsnotify_modify(fd) in vmsplice Ahelenia Ziemiańska
2023-06-27  6:27                 ` Amir Goldstein
2023-06-26 23:09               ` [PATCH v2 3/3] splice: fsnotify_access(in), fsnotify_modify(out) on success in tee Ahelenia Ziemiańska
2023-06-27  6:20                 ` Amir Goldstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOQ4uxh7i_s4R9pFJPENALdWGG5-dDhqPLEUXuJqSoHraktFiA@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=cccheng@synology.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nabijaczleweli@nabijaczleweli.xyz \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).