linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: dsterba@suse.cz, Chris Mason <clm@fb.com>,
	Josef Bacik <josef@toxicpanda.com>,
	linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: no need to check return value of debugfs_create functions
Date: Thu, 24 Jan 2019 17:36:01 +0100	[thread overview]
Message-ID: <20190124163601.GY2900@twin.jikos.cz> (raw)
In-Reply-To: <20190114142104.GA12343@kroah.com>

On Mon, Jan 14, 2019 at 03:21:04PM +0100, Greg Kroah-Hartman wrote:
> On Fri, Jan 04, 2019 at 02:44:49PM +0100, David Sterba wrote:
> > On Fri, Jan 04, 2019 at 02:25:20PM +0100, Greg Kroah-Hartman wrote:
> > > When calling debugfs functions, there is no need to ever check the
> > > return value.  The function can work or not, but the code logic should
> > > never do something different based on this.
> > > 
> > > Cc: Chris Mason <clm@fb.com>
> > > Cc: Josef Bacik <josef@toxicpanda.com>
> > > Cc: David Sterba <dsterba@suse.com>
> > > Cc: linux-btrfs@vger.kernel.org
> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > ---
> > >  fs/btrfs/sysfs.c | 10 ++--------
> > >  1 file changed, 2 insertions(+), 8 deletions(-)
> > > 
> > > Meta-comment, why is there a btrfs debugfs directory at all?  All you
> > > have here is a single "test" file that doesn't do anything except expose
> > > a variable that never changes.  What is this directory and single file
> > > for?  Can I just delete the whole thing?
> > 
> > As explained in the commit that introduces the function
> > (1bae30982bc86ab66d61ccb):
> > 
> >   Help during debugging to export various interesting infromation and
> >   tunables without the need of extra mount options or ioctls.
> > 
> >   Usage:
> >   * declare your variable in sysfs.h, and include where you need it
> >   * define the variable in sysfs.c and make it visible via
> >     debugfs_create_TYPE
> > 
> >   Depends on CONFIG_DEBUG_FS.
> > 
> > It's there for developers, so don't delete it. Which also means the
> > error code should be handled and not ignored.
> 
> If no one has used it, why keep it?

That no one can tell for sure, we don't get notified. I know that
implementing the debugfs support was not all trivial and saved time.
If this savs time to other developers, why delete it?

> Anyway, if you want it there, that's fine, but no, the error message can
> be ignored.  You should never have a different code flow if a debugfs
> call fails or not.  So the patch I posted here is still correct and
> should be applied.

I disagree with that. The usecase is for devleopers, who intentionally
add own debugging information. It does not mean the code changes gets
committed in the end, but the debugfs infrastructure is used and should
work reliably at this point. This means that either the data get
exported or there's an early exit when something goes wrong. Silent
failure in this case can waste hours of testing or debugging.

I fail to see your logic to never rely on debugfs calls success/failure.
Debugfs is a tool like any other, with narrow group of users and
usecases but can be valuable.

If you need to extend return values or do other cleanups, then fine, but
I'm not going to apply the patch in its current form as it would harm my
own usecase, sorry.

> > I can enhance the comment so it's explained in-place and not too
> > tempting to remove it. This is not the first time somebody wants to
> > remove it
> > (https://lore.kernel.org/linux-btrfs/d6715b5b-0aa3-3032-43c6-eccd907a60b8@redhat.com/),
> 
> If it keeps wanting to get removed, that's a big hint maybe you should :)

If there's a good explanation why it should be removed, then yes. If
there's a reason to keep it, then no. So far I've seen drive-by attempts
to remove some seemingly unused code by people who don't work in the
area of the subsystem and may not understand its purpose.

  reply	other threads:[~2019-01-24 16:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-04 13:25 [PATCH] btrfs: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-01-04 13:36 ` Nikolay Borisov
2019-01-04 14:07   ` Greg Kroah-Hartman
2019-01-04 13:44 ` David Sterba
2019-01-14 14:21   ` Greg Kroah-Hartman
2019-01-24 16:36     ` David Sterba [this message]
2019-02-01  9:17       ` Greg Kroah-Hartman

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=20190124163601.GY2900@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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 NNTP newsgroup(s).