From: Al Viro <viro@zeniv.linux.org.uk>
To: Daniel Xu <dxu@dxuuu.xyz>
Cc: Dave Chinner <david@fromorbit.com>, Theodore Ts'o <tytso@mit.edu>,
lsf-pc@lists.linux-foundation.org,
Linux Filesystem Development List <linux-fsdevel@vger.kernel.org>,
bpf@vger.kernel.org
Subject: Re: [LSF/MM/BPF TOPIC] time to reconsider tracepoints in the vfs?
Date: Sat, 18 Jan 2025 03:37:23 +0000 [thread overview]
Message-ID: <20250118033723.GV1977892@ZenIV> (raw)
In-Reply-To: <oidb2ijfx64r4lgpf3ei7teexpa54ngnef3cmq5bsxsgxmtros@7pn2y34ud4l7>
On Fri, Jan 17, 2025 at 08:07:48PM -0700, Daniel Xu wrote:
> In addition to the points Andrii makes below, tracepoints also have a
> nice documenting property. They tend to get added to "places of
> interest". They're a great starting point for non kernel developers to
> dig into kernel internals. Often times tracepoint naming (as well as the
> exported fields) provide helpful hints.
>
> At least for me, if I'm mucking around new places (mostly net/) I'll
> tend to go look at the tracepoints to find the interesting codepaths.
Here's one for you:
trace_ocfs2_file_splice_read(inode, in, in->f_path.dentry,
(unsigned long long)OCFS2_I(inode)->ip_blkno,
in->f_path.dentry->d_name.len,
in->f_path.dentry->d_name.name,
flags);
The trouble is, what happens if your ->splice_read() races
with rename()? Yes, it is allowed to happen in parallel with
splice(2). Or with read(2), for that matter. Or close(2) (and
dup2(2) or exit(2) of something that happens to have the file
opened).
What happens is that
* you get len and name that might not match each other - you might
see len being 200 and name pointing to 40-byte array inside dentry.
* you get name that is not guaranteed to be *there* - you might
pick one before rename and have it freed and reused by the time you
try to access it.
* you get name that points to a string that might be modified
by another CPU right under you (for short names).
Doing that inside ->mkdir() - sure, no problem, the name _is_ stable
there. Doing that inside ->lookup() - fine on the entry, may be not
safe on the way out.
In filesystems it's living dangerously, but as long as you know what
you are doing you can get away with that (ocfs2 folks hadn't, but
it's not just ocfs2 - similar tracepoints exist for nfs, etc.)...
prev parent reply other threads:[~2025-01-18 3:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 12:49 [LSF/MM/BPF TOPIC] time to reconsider tracepoints in the vfs? Theodore Ts'o
2025-01-16 16:53 ` Al Viro
2025-01-16 17:29 ` [Lsf-pc] " Jan Kara
2025-01-16 17:20 ` Jan Kara
2025-01-20 15:43 ` Christian Brauner
2025-01-20 17:15 ` Jan Kara
2025-01-16 21:18 ` Dave Chinner
2025-01-16 21:43 ` Andrii Nakryiko
2025-01-17 2:20 ` Al Viro
2025-01-17 18:33 ` Andrii Nakryiko
2025-01-20 15:42 ` Christian Brauner
2025-01-18 3:07 ` Daniel Xu
2025-01-18 3:37 ` Al Viro [this message]
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=20250118033723.GV1977892@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=bpf@vger.kernel.org \
--cc=david@fromorbit.com \
--cc=dxu@dxuuu.xyz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=lsf-pc@lists.linux-foundation.org \
--cc=tytso@mit.edu \
/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