Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jul 2012 12:30:10 GMT
From:      David Xu <listlog2011@gmail.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/170203: [kern] piped dd's don't behave sanely when dealing with a fifo
Message-ID:  <201207271230.q6RCUAu8043530@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/170203; it has been noted by GNATS.

From: David Xu <listlog2011@gmail.com>
To: Bruce Evans <brde@optusnet.com.au>
Cc: davidxu@FreeBSD.org, Garrett Cooper <yanegomi@gmail.com>,
        freebsd-bugs@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/170203: [kern] piped dd's don't behave sanely when dealing
 with a fifo
Date: Fri, 27 Jul 2012 20:29:02 +0800

 On 2012/7/27 19:08, Bruce Evans wrote:
 > On Fri, 27 Jul 2012, David Xu wrote:
 >
 >> On 2012/7/27 10:07, Bruce Evans wrote:
 >>>
 >>> I think it's working almost as expected.  Large blocks give non-atomic
 >>> I/O, so the reader sees small blocks, then EOF when it gets ahead of
 >>> the writer.  This always happens without SMP.
 >>>
 >>> Not is a bug (debugged below).  There is no SIGPIPE at the start of
 >>> write() because there is a reader then, and no SIGPIPE for the next
 >>> write() because there is no next write() -- the current one doesn't
 >>> notice when the reader goes away.
 >>>
 >> After fixed dd to not open fifo output file in O_RDWR mode, I still 
 >> found the
 >> writer is blocked there even the reader is already exited.
 >
 > I'm not sure that dd's open is a bug.  It must be intentional to use
 > O_RDWR for some cases.
 >
 Don't know if original author even thought about FIFO.
 
 > POSIX (old 2001 draft) doesn't say anything about dd's open mode.
 >
 >> I think this is definitely a bug. if reader is exited, the writer 
 >> should be aborted too,
 >> but I found it still be blocked in state "pipedwt", obviously, the 
 >> code in
 >> /sys/fs/fifo_vnops.c wants to wake up the writer when the reader is 
 >> closing the fifo,
 >> but it failed, because the bit flag PIPE_WANTW is forgotten to be set 
 >> by writer,
 >> so it skips executing wakeup(), and then the writer has no chance to 
 >> find EOF bit flag
 >> is set.
 >
 > Does this affect nameless pipes too?  The old implementation presumably
 > doesn't have this bug.
 >
 It is easy to repeat the bug for named pipes,  don't know if nameless 
 pipes have
 same bug,  I can not reproduce it yet.
 
 
 > Bruce
 > .
 >
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207271230.q6RCUAu8043530>