From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top
Subject: Re: [RFC PATCH] pasta, passt-repair: Support multiple events per read() in inotify handlers
Date: Fri, 28 Mar 2025 10:23:40 +0100 [thread overview]
Message-ID: <20250328102340.0ede3ca8@elisabeth> (raw)
In-Reply-To: <Z-XhB5HtIdtERjWO@zatzit>
On Fri, 28 Mar 2025 10:36:39 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:
> On Thu, Mar 27, 2025 at 10:28:22PM +0100, Stefano Brivio wrote:
> > The current code assumes that we'll get one event per read() on
> > inotify descriptors, but that's not the case, not from documentation,
> > and not from reports.
> >
> > Add loops in the two inotify handlers we have, in pasta-specific code
> > and passt-repair, to go through all the events we receive.
> >
> > While in pasta the the inotify watch is in an epoll list, and we'll
>
> "the the"
>
> > get epoll wakeups as long as there's data to read, in passt-repair
> > that's not the case. So, in pasta we can simply size the buffer for
> > a single event and try to read one, but in passt-repair, we'll need
> > to size the buffer to a safer, reasonable amount of events.
>
> I'm not following the reasoning here. In passt-repair we're just
> looping on the read() until we find what we want, so we'll still
> eventually get what we want. AFAICT it's a stream-like interface, so
> we won't lose events just because we didn't get them in the first
> read().
Under the assumption that message (event) boundaries are preserved
across read() calls, yes.
And... this assumption actually holds (I had forgotten about that), so
expanding the buffer as I did makes no sense, because by reading
sizeof(struct inotify_event) + NAME_MAX + 1) bytes we always read one
or more events, but never a partial buffer.
So, yes, never mind.
> > Link: https://bugs.passt.top/show_bug.cgi?id=119
> > Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
>
> Otherwise, LGTM.
>
> > ---
> > I'm posting this as RFC because, while it seems to do the job and I
> > tested all the code paths, Coverity isn't amused by the fact that
> > we assume that inotify 'name' attributes (ev->name) are
> > NULL-terminated. They actually are, but the code is not very robust.
> >
> > Addressing that is kind of trivial but I keep getting it wrong, so
> > I'll start posting this and fix that up later (direct fixes/edits of
> > this patch are also welcome, of course).
>
> Ok, I might try to polish this up today
Thanks!
--
Stefano
next prev parent reply other threads:[~2025-03-28 9:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 21:28 [RFC PATCH] pasta, passt-repair: Support multiple events per read() in inotify handlers Stefano Brivio
2025-03-27 23:36 ` David Gibson
2025-03-28 9:23 ` Stefano Brivio [this message]
2025-03-28 9:32 ` David Gibson
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=20250328102340.0ede3ca8@elisabeth \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
/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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
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 IMAP folder(s).