From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/2] io: open pipes in non-blocking mode
Date: Tue, 4 Dec 2018 07:16:33 +1100 [thread overview]
Message-ID: <20181203201633.GF6311@dastard> (raw)
In-Reply-To: <20181203162030.GT8125@magnolia>
On Mon, Dec 03, 2018 at 08:20:30AM -0800, Darrick J. Wong wrote:
> On Mon, Dec 03, 2018 at 07:53:42AM +1100, Dave Chinner wrote:
> > From: Dave Chinner <dchinner@redhat.com>
> >
> > So that O_RDONLY open commands (such as from copy_range) do not
> > block forever waiting on a non-existent writer.
> >
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > ---
> > io/open.c | 13 +++++++++++++
> > 1 file changed, 13 insertions(+)
> >
> > diff --git a/io/open.c b/io/open.c
> > index 6ea3e9a2019f..b1d9a0fa317c 100644
> > --- a/io/open.c
> > +++ b/io/open.c
> > @@ -56,6 +56,7 @@ openfile(
> > struct fs_path *fs_path)
> > {
> > struct fs_path *fsp;
> > + struct stat st;
> > int fd;
> > int oflags;
> >
> > @@ -79,6 +80,18 @@ openfile(
> > if (flags & IO_NOFOLLOW)
> > oflags |= O_NOFOLLOW;
> >
> > + /*
> > + * if we've been passed a pipe to open, don't block waiting for a
> > + * reader or writer to appear. We want to either succeed or error out
> > + * immediately.
> > + */
> > + if (stat(path, &st) < 0 && errno != ENOENT) {
> > + perror("stat");
> > + return -1;
> > + }
> > + if (S_ISFIFO(st.st_mode))
>
> Hmm... does stat() set st.st_mode even if it returns ENOENT? Or are we
> possibly branching on an uninitialized st here?
>
> struct stat st = { 0 }; ?
Yeah, I'll fix that.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2018-12-03 20:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-02 20:53 [PATCH 0/2] xfs_io: additions for testing copy_range Dave Chinner
2018-12-02 20:53 ` [PATCH 1/2] io: open pipes in non-blocking mode Dave Chinner
2018-12-03 10:07 ` Jan Tulak
2018-12-03 16:20 ` Darrick J. Wong
2018-12-03 20:16 ` Dave Chinner [this message]
2018-12-05 3:52 ` Eric Sandeen
2018-12-02 20:53 ` [PATCH 2/2] xfs_io: allow open file permissions to be changed Dave Chinner
2018-12-03 10:17 ` Jan Tulak
2018-12-03 20:14 ` Dave Chinner
2018-12-03 16:24 ` Darrick J. Wong
2018-12-05 4:02 ` [PATCH 2/2 V2] " Dave Chinner
2018-12-05 4:23 ` Eric Sandeen
2018-12-05 4:04 ` [PATCH 2/2] " Eric Sandeen
2018-12-03 0:20 ` [PATCH 3/2] xfs_io: copy_file_range length is a size_t Dave Chinner
2018-12-03 10:08 ` Jan Tulak
2018-12-03 16:27 ` 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=20181203201633.GF6311@dastard \
--to=david@fromorbit.com \
--cc=darrick.wong@oracle.com \
--cc=linux-xfs@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