public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dominique Martinet <asmadeus@codewreck.org>
To: David Laight <david.laight.linux@gmail.com>
Cc: Pierre Barre <pierre@barre.sh>,
	Eric Van Hensbergen <ericvh@kernel.org>,
	Latchesar Ionkov <lucho@ionkov.net>,
	Christian Schoenebeck <linux_oss@crudebyte.com>,
	v9fs@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] 9p: use kvzalloc for readdir buffer
Date: Thu, 16 Apr 2026 11:31:02 +0900	[thread overview]
Message-ID: <aeBJ5pT0WtMp-LO5@codewreck.org> (raw)
In-Reply-To: <20260415113625.6d38441d@pumpkin>

David Laight wrote on Wed, Apr 15, 2026 at 11:36:25AM +0100:
> > Perhaps what you describe can explain what I was seeing there:
> > https://lore.kernel.org/v9fs/496d10b9-40fe-4f81-8014-37497c37ff63@app.fastmail.com/
> (After seeking, getdents() returns stale cached entries instead of fetching from the new position.)
> 
> Absolutely.
> But the fix probably isn't trivial.
> The offset that you need for the seek isn't directly related to the number
> of bytes copied to the user buffer - which is what I suspect ftell() (or
> whatever gets used) returns.
> I think there is some mechanism for arbitrary directory offsets; but IIRC that
> requires the code put the 'file system offset for the next directory entry'
> somewhere in the directory entry.
> Such an offset would have to be one the remote system would understand.
> 
> A partial 'non-fix' would be to reject seeks to other than offset 0.


Thank you both for working on this and reviewing -- this is all
historical code that hasn't seen much love.


9p Treaddir sends an offset on each call, so I think it'd be fine to
invalidate buffer/remember whatever the client set in a custom llseek
function and send this to the server on readdir call, but I honestly
didn't give this any more thought than the past 2 mintes (I'm totally
swamped and can't keep up/didn't even notice the bug report this
december, sorry :/)
I think some filesystems only allow seeks to 0 already? So given there
is a precendent this might be fine, but I don't see the harm in allowing
custom offsets: the server needs to be able to deal with junk offsets in
read requests anyway, so it's not a problem for me if userspace can set
something invalid and get itself stuck on EINVAL or whatever.


As for locking the vfs takes the file's f_lock for seek, but there
doesn't seem to be anything in the readdir path that would do that, so I
guess it probably would blow up with parallel readdirs on the same fd,
and could use improving...

-- 
Dominique Martinet | Asmadeus

  reply	other threads:[~2026-04-16  2:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-15  5:45 [PATCH] 9p: use kvzalloc for readdir buffer Pierre Barre
2026-04-15  9:01 ` David Laight
2026-04-15  9:27   ` Pierre Barre
2026-04-15 10:36     ` David Laight
2026-04-16  2:31       ` Dominique Martinet [this message]
2026-04-16  9:18         ` David Laight

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=aeBJ5pT0WtMp-LO5@codewreck.org \
    --to=asmadeus@codewreck.org \
    --cc=david.laight.linux@gmail.com \
    --cc=ericvh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux_oss@crudebyte.com \
    --cc=lucho@ionkov.net \
    --cc=pierre@barre.sh \
    --cc=v9fs@lists.linux.dev \
    /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