From: "Pierre Barre" <pierre@barre.sh>
To: v9fs@lists.linux.dev
Subject: Directory lseek doesn't invalidate rdir buffer
Date: Tue, 02 Dec 2025 12:35:09 +0100 [thread overview]
Message-ID: <496d10b9-40fe-4f81-8014-37497c37ff63@app.fastmail.com> (raw)
Hi,
It seems that xfstests generic/637 fails on my 9P implementation because lseek() on a directory doesn't invalidate the rdir buffer. After seeking, getdents() returns stale cached entries instead of fetching from the new position.
v9fs_dir_operations_dotl uses generic_file_llseek, which updates f_pos but doesn't clear fid->rdir. Then v9fs_dir_readdir_dotl() only calls p9_client_readdir when rdir->tail == rdir->head, otherwise it returns cached data without checking if ctx->pos changed.
Would a custom v9fs_dir_llseek that clears rdir->head and rdir->tail before calling generic_file_llseek be the right fix?
NFS does the following:
static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence)
[...]
if (offset != filp->f_pos) {
filp->f_pos = offset;
dir_ctx->page_index = 0;
if (!nfs_readdir_use_cookie(filp)) {
dir_ctx->dir_cookie = 0;
dir_ctx->last_cookie = 0;
} else {
dir_ctx->dir_cookie = offset;
dir_ctx->last_cookie = offset;
}
dir_ctx->eof = false;
}
spin_unlock(&filp->f_lock);
return offset;
}
Thanks,
Pierre
reply other threads:[~2025-12-02 11:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=496d10b9-40fe-4f81-8014-37497c37ff63@app.fastmail.com \
--to=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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).