View | Details | Raw Unified | Return to bug 216458 | Differences between
and this patch

Collapse All | Expand All

(-)linux-4.18.0-372.26.1.el8.x86_64/fs/pipe.c,kbz216458 (-9 / +28 lines)
Lines 307-313 pipe_read(struct kiocb *iocb, struct iov Link Here
307
		if (bufs)	/* More to do? */
307
		if (bufs)	/* More to do? */
308
			continue;
308
			continue;
309
		if (!pipe->writers)
309
		if (!pipe->writers)
310
		{       do_wakeup = 1;
310
			break;
311
			break;
312
		}
311
		if (!pipe->waiting_writers) {
313
		if (!pipe->waiting_writers) {
312
			/* syscall merging: Usually we must not sleep
314
			/* syscall merging: Usually we must not sleep
313
			 * if O_NONBLOCK is set, or if we got some data.
315
			 * if O_NONBLOCK is set, or if we got some data.
Lines 328-344 pipe_read(struct kiocb *iocb, struct iov Link Here
328
		}
330
		}
329
		if (do_wakeup) {
331
		if (do_wakeup) {
330
			wake_up_interruptible_sync_poll(&pipe->wait, EPOLLOUT | EPOLLWRNORM);
332
			wake_up_interruptible_sync_poll(&pipe->wait, EPOLLOUT | EPOLLWRNORM);
331
 			kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
333
			if ( pipe->fasync_writers )
334
				kill_fasync(&pipe->fasync_writers, SIGIO, ( ret > 0 ) ? POLL_OUT : ((!pipe->readers) ? POLL_HUP : POLL_OUT));
332
		}
335
		}
333
		pipe_wait(pipe);
336
		pipe_wait(pipe);
334
	}
337
	}
335
	__pipe_unlock(pipe);
338
	__pipe_unlock(pipe);
336
339
337
	/* Signal writers asynchronously that there is more room. */
340
	if ( (!pipe->writers) && pipe->fasync_readers )
338
	if (do_wakeup) {
341
	       	kill_fasync(&pipe->fasync_readers, SIGIO, POLL_HUP);
342
343
	if ( do_wakeup ) {
344
		/* Signal writers asynchronously that there is more room. */
339
		wake_up_interruptible_sync_poll(&pipe->wait, EPOLLOUT | EPOLLWRNORM);
345
		wake_up_interruptible_sync_poll(&pipe->wait, EPOLLOUT | EPOLLWRNORM);
340
		kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
346
		if ( pipe->fasync_writers )
347
			kill_fasync(&pipe->fasync_writers, SIGIO, (ret > 0) ? POLL_OUT  : ((!pipe->readers) ? POLL_HUP : POLL_OUT));
341
	}
348
	}
349
342
	if (ret > 0)
350
	if (ret > 0)
343
		file_accessed(filp);
351
		file_accessed(filp);
344
	return ret;
352
	return ret;
Lines 464-470 pipe_write(struct kiocb *iocb, struct io Link Here
464
		}
472
		}
465
		if (do_wakeup) {
473
		if (do_wakeup) {
466
			wake_up_interruptible_sync_poll(&pipe->wait, EPOLLIN | EPOLLRDNORM);
474
			wake_up_interruptible_sync_poll(&pipe->wait, EPOLLIN | EPOLLRDNORM);
467
			kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
475
			if ( pipe->fasync_readers )
476
				kill_fasync(&pipe->fasync_readers, SIGIO, (ret > 0) ? POLL_IN : ((!pipe->writers) ? POLL_HUP : POLL_IN));
468
			do_wakeup = 0;
477
			do_wakeup = 0;
469
		}
478
		}
470
		pipe->waiting_writers++;
479
		pipe->waiting_writers++;
Lines 473-483 pipe_write(struct kiocb *iocb, struct io Link Here
473
	}
482
	}
474
out:
483
out:
475
	__pipe_unlock(pipe);
484
	__pipe_unlock(pipe);
485
476
	if (do_wakeup) {
486
	if (do_wakeup) {
477
		wake_up_interruptible_sync_poll(&pipe->wait, EPOLLIN | EPOLLRDNORM);
487
		wake_up_interruptible_sync_poll(&pipe->wait, EPOLLIN | EPOLLRDNORM);
478
		kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
488
		if ( pipe->fasync_readers )
489
			kill_fasync(&pipe->fasync_readers, SIGIO, (ret > 0) ? POLL_IN : ((!pipe->writers) ? POLL_HUP : POLL_IN));
479
	}
490
	}
480
	if (ret > 0 && sb_start_write_trylock(file_inode(filp)->i_sb)) {
491
492
	if ((ret > 0) && sb_start_write_trylock(file_inode(filp)->i_sb)) {
481
		int err = file_update_time(filp);
493
		int err = file_update_time(filp);
482
		if (err)
494
		if (err)
483
			ret = err;
495
			ret = err;
Lines 569-577 pipe_release(struct inode *inode, struct Link Here
569
581
570
	if (pipe->readers || pipe->writers) {
582
	if (pipe->readers || pipe->writers) {
571
		wake_up_interruptible_sync_poll(&pipe->wait, EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM | EPOLLERR | EPOLLHUP);
583
		wake_up_interruptible_sync_poll(&pipe->wait, EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM | EPOLLERR | EPOLLHUP);
572
		kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
584
		if ( pipe->fasync_readers && !pipe->writers )
573
		kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
585
			kill_fasync(&pipe->fasync_readers, SIGIO, POLL_HUP);
586
		else if (pipe->fasync_readers)
587
			kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
588
		if ( pipe->fasync_writers && !pipe->readers )
589
			kill_fasync(&pipe->fasync_writers, SIGIO, POLL_HUP);
590
		else if (pipe->fasync_writers)
591
			kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
574
	}
592
	}
593
575
	__pipe_unlock(pipe);
594
	__pipe_unlock(pipe);
576
595
577
	put_pipe_info(inode, pipe);
596
	put_pipe_info(inode, pipe);

Return to bug 216458