Recall from r349546 that PIPE_DIRECTW is a semaphore used to provide
mutual exclusion for the pipe_map fields (note that it is unrelated to
the global pipe_map). These fields hold an array of pages mapped in to
the writer until the reader drains them. PIPE_DIRECTW provides mutual
exclusion among multiple writers; prior to r349546, a reader would clear
PIPE_DIRECTW after draining the data, but this was incorrect because the
writer is responsible for doing run-down of the pipe_map fields.
r349546 changes things so that the writer clears PIPE_DIRECTW after the
reader drains data and wakes the writer up. However, this broke
pipe_poll() since it returned POLLIN if PIPE_DIRECTW is set. If
pipe_poll() executes after a reader has drained all data and before the
writer clears PIPE_DIRECTW, it would return POLLIN even though no data
is present.
Fix this by replacing most checks for PIPE_DIRECTW with tests for
pipe_map.cnt != 0. We still test PIPE_DIRECTW in filt_pipewrite() and
pipe_poll(POLLOUT) since a writer may block whenever PIPE_DIRECTW is
set.