From: Dave Chinner <david@fromorbit.com>
To: Timur Tabi <ttabi@nvidia.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"rafael@kernel.org" <rafael@kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"michael@ellerman.id.au" <michael@ellerman.id.au>
Subject: Re: [PATCH] debufgs: debugfs_create_blob can set the file size
Date: Thu, 8 Feb 2024 09:47:45 +1100 [thread overview]
Message-ID: <ZcQIkejkOoQy8lrR@dread.disaster.area> (raw)
In-Reply-To: <33f582cce59ac14ce454aa49e14f50e535684004.camel@nvidia.com>
On Wed, Feb 07, 2024 at 10:18:26PM +0000, Timur Tabi wrote:
> On Thu, 2024-02-08 at 09:06 +1100, Dave Chinner wrote:
> > So fix the debugfs_create_file_*() functions to pass a length
> > and that way you fix all the "debugfs files have zero length but
> > still have data that can be read" problems for everyone? Then the
> > zero length problem can be isolated to just the debug objects that don't
> > know their size (i.e. are streams of data, not fixed size).
> >
> > IMO, it doesn't help anyone to have one part of the debugfs
> > blob/file API to set inode->i_size correctly, but then leave the
> > majority of the users still behaving the problematic way (i.e. zero
> > size yet with data that can be read). It's just a recipe for
> > confusion....
>
> I don't disagree, but that's a much more ambitious change than I am prepared
> to make.
TANSTAAFL.
"That's somebody else's problem" is what everyone says about fixing
problems once they've worked out the minimal fix that addresses
their specific issue.
We need a new rule: do not leave technical debt behind that other
people will still have to clean up after you get what you need.
> debugfs_create_file_size() already exists, it's just that
> debugfs_create_blob() doesn't use it. I think the problem is that the file
> size is not always known, or at least not always the fixed, so setting the
> initial file size isn't always an option.
Yes, that's exactly what I said:
"Then the zero length problem can be isolated to just the debug
objects that don't know their size (i.e. are streams of data, not
fixed size)."
Make the majority behave correctly by default, force those that want
a file to work like a stream to explicitly say they want a zero
sized debugfs file.
Indeed - those that want a stream should call a helper function like
debugfs_create_data_stream() to indicate what is emitted from that
file is an unknown amount of data, and that it should be read until
no more data is present by userspace.
The hack of using zero length files for these can then be hidden
behind the API that documents exactly the type of data being
exported by the subsystem....
> On a side note, debugfs_create_file_size() does the same thing that my v1
> patch does:
>
> struct dentry *de = debugfs_create_file(name, mode, parent, data, fops);
> if (!IS_ERR(de))
> d_inode(de)->i_size = file_size;
>
> Shouldn't this function also use i_size_write()?
Yes, it should.
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2024-02-07 22:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-07 20:06 [PATCH] debufgs: debugfs_create_blob can set the file size Timur Tabi
2024-02-07 21:40 ` Dave Chinner
2024-02-07 21:44 ` Timur Tabi
2024-02-07 22:06 ` Dave Chinner
2024-02-07 22:18 ` Timur Tabi
2024-02-07 22:47 ` Dave Chinner [this message]
2024-02-07 22:07 ` Darrick J. Wong
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=ZcQIkejkOoQy8lrR@dread.disaster.area \
--to=david@fromorbit.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=michael@ellerman.id.au \
--cc=rafael@kernel.org \
--cc=ttabi@nvidia.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.