linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Shuah Khan <skhan@linuxfoundation.org>
Cc: axboe@kernel.dk, zohar@linux.vnet.ibm.com, mcgrof@kernel.org,
	keescook@chromium.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] fs: avoid fdput() after failed fdget() in ksys_sync_file_range()
Date: Fri, 8 May 2020 01:24:22 +0100	[thread overview]
Message-ID: <20200508002422.GL23230@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20200508000509.GK23230@ZenIV.linux.org.uk>

On Fri, May 08, 2020 at 01:05:09AM +0100, Al Viro wrote:
> On Thu, May 07, 2020 at 05:57:09PM -0600, Shuah Khan wrote:
> > Fix ksys_sync_file_range() to avoid fdput() after a failed fdget().
> > fdput() doesn't do fput() on this file since FDPUT_FPUT isn't set
> > in fd.flags. Fix it anyway since failed fdget() doesn't require
> > a fdput().
> > 
> > This was introdcued in a commit to add sync_file_range() helper.
> 
> Er...  What's the point microoptimizing the slow path here?

PS: I'm not saying the patch is incorrect, but Fixes: is IMO over the
top.  And looking at that thing,
{
        struct fd f = fdget(fd);
        int ret;

	if (unlikely(!f.file))
		return -EBADF;

	ret = sync_file_range(f.file, offset, nbytes, flags);
        fdput(f);
        return ret;
}

might be cleaner, but that's a matter of taste...

  reply	other threads:[~2020-05-08  0:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 23:57 [PATCH 0/2] fs: avoid fdput() after failed fdget() Shuah Khan
2020-05-07 23:57 ` [PATCH 1/2] fs: avoid fdput() after failed fdget() in ksys_sync_file_range() Shuah Khan
2020-05-08  0:05   ` Al Viro
2020-05-08  0:24     ` Al Viro [this message]
2020-05-08  2:21       ` Luis Chamberlain
2020-05-08 15:07         ` Shuah Khan
2020-05-07 23:57 ` [PATCH 2/2] fs: avoid fdput() after failed fdget() in kernel_read_file_from_fd() Shuah Khan

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=20200508002422.GL23230@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=axboe@kernel.dk \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=zohar@linux.vnet.ibm.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 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).