Lines Matching +full:t +full:- +full:head

1 // SPDX-License-Identifier: GPL-2.0
39 * than two, then a write to a non-empty pipe may block even if the pipe is not
45 * own risk, namely: pipe writes to non-full pipes may block until the pipe is
51 * The max size that a non-root user is allowed to grow the pipe. Can
52 * be set by root in /proc/sys/fs/pipe-max-size
63 * We use head and tail indices that aren't masked off, except at the point of
65 * isn't a dead spot in the buffer, but the ring has to be a power of two and
67 * -- David Howells 2019-09-23.
70 * -- Julian Bradfield 1999-06-07.
73 * -- Jeremy Elson <jelson@circlemud.org> 2001-08-16
76 * -- Manfred Spraul <manfred@colorfullife.com> 2002-05-09
79 #define cmp_int(l, r) ((l > r) - (l < r))
91 if (pipe->files) in pipe_lock()
92 mutex_lock(&pipe->mutex); in pipe_lock()
98 if (pipe->files) in pipe_unlock()
99 mutex_unlock(&pipe->mutex); in pipe_unlock()
118 struct page *page = buf->page; in anon_pipe_buf_release()
121 * If nobody else uses this page, and we don't already have a in anon_pipe_buf_release()
122 * temporary page, let's keep track of it as a one-deep in anon_pipe_buf_release()
125 if (page_count(page) == 1 && !pipe->tmp_page) in anon_pipe_buf_release()
126 pipe->tmp_page = page; in anon_pipe_buf_release()
134 struct page *page = buf->page; in anon_pipe_buf_try_steal()
144 * generic_pipe_buf_try_steal - attempt to take ownership of a &pipe_buffer
158 struct page *page = buf->page; in generic_pipe_buf_try_steal()
174 * generic_pipe_buf_get - get a reference to a &struct pipe_buffer
185 return try_get_page(buf->page); in generic_pipe_buf_get()
190 * generic_pipe_buf_release - put a reference to a &struct pipe_buffer
200 put_page(buf->page); in generic_pipe_buf_release()
210 /* Done while waiting without holding the pipe lock - thus the READ_ONCE() */
213 unsigned int head = READ_ONCE(pipe->head); in pipe_readable() local
214 unsigned int tail = READ_ONCE(pipe->tail); in pipe_readable()
215 unsigned int writers = READ_ONCE(pipe->writers); in pipe_readable()
217 return !pipe_empty(head, tail) || !writers; in pipe_readable()
232 spin_lock_irq(&pipe->rd_wait.lock); in pipe_update_tail()
234 if (buf->flags & PIPE_BUF_FLAG_LOSS) in pipe_update_tail()
235 pipe->note_loss = true; in pipe_update_tail()
237 pipe->tail = ++tail; in pipe_update_tail()
238 spin_unlock_irq(&pipe->rd_wait.lock); in pipe_update_tail()
244 * without the spinlock - the mutex is enough. in pipe_update_tail()
246 pipe->tail = ++tail; in pipe_update_tail()
254 struct file *filp = iocb->ki_filp; in pipe_read()
255 struct pipe_inode_info *pipe = filp->private_data; in pipe_read()
264 mutex_lock(&pipe->mutex); in pipe_read()
274 was_full = pipe_full(pipe->head, pipe->tail, pipe->max_usage); in pipe_read()
276 /* Read ->head with a barrier vs post_one_notification() */ in pipe_read()
277 unsigned int head = smp_load_acquire(&pipe->head); in pipe_read() local
278 unsigned int tail = pipe->tail; in pipe_read()
279 unsigned int mask = pipe->ring_size - 1; in pipe_read()
282 if (pipe->note_loss) { in pipe_read()
287 ret = -ENOBUFS; in pipe_read()
296 ret = -EFAULT; in pipe_read()
300 total_len -= sizeof(n); in pipe_read()
301 pipe->note_loss = false; in pipe_read()
305 if (!pipe_empty(head, tail)) { in pipe_read()
306 struct pipe_buffer *buf = &pipe->bufs[tail & mask]; in pipe_read()
307 size_t chars = buf->len; in pipe_read()
312 if (buf->flags & PIPE_BUF_FLAG_WHOLE) { in pipe_read()
314 ret = -ENOBUFS; in pipe_read()
327 written = copy_page_to_iter(buf->page, buf->offset, chars, to); in pipe_read()
330 ret = -EFAULT; in pipe_read()
334 buf->offset += chars; in pipe_read()
335 buf->len -= chars; in pipe_read()
338 if (buf->flags & PIPE_BUF_FLAG_PACKET) { in pipe_read()
340 buf->len = 0; in pipe_read()
343 if (!buf->len) in pipe_read()
345 total_len -= chars; in pipe_read()
348 if (!pipe_empty(head, tail)) /* More to do? */ in pipe_read()
352 if (!pipe->writers) in pipe_read()
356 if ((filp->f_flags & O_NONBLOCK) || in pipe_read()
357 (iocb->ki_flags & IOCB_NOWAIT)) { in pipe_read()
358 ret = -EAGAIN; in pipe_read()
361 mutex_unlock(&pipe->mutex); in pipe_read()
364 * We only get here if we didn't actually read anything. in pipe_read()
366 * However, we could have seen (and removed) a zero-sized in pipe_read()
370 * You can't make zero-sized pipe buffers by doing an empty in pipe_read()
381 wake_up_interruptible_sync_poll(&pipe->wr_wait, EPOLLOUT | EPOLLWRNORM); in pipe_read()
382 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); in pipe_read()
385 * But because we didn't read anything, at this point we can in pipe_read()
386 * just return directly with -ERESTARTSYS if we're interrupted, in pipe_read()
390 if (wait_event_interruptible_exclusive(pipe->rd_wait, pipe_readable(pipe)) < 0) in pipe_read()
391 return -ERESTARTSYS; in pipe_read()
393 mutex_lock(&pipe->mutex); in pipe_read()
394 was_full = pipe_full(pipe->head, pipe->tail, pipe->max_usage); in pipe_read()
397 if (pipe_empty(pipe->head, pipe->tail)) in pipe_read()
399 mutex_unlock(&pipe->mutex); in pipe_read()
402 wake_up_interruptible_sync_poll(&pipe->wr_wait, EPOLLOUT | EPOLLWRNORM); in pipe_read()
404 wake_up_interruptible_sync_poll(&pipe->rd_wait, EPOLLIN | EPOLLRDNORM); in pipe_read()
405 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); in pipe_read()
413 return (file->f_flags & O_DIRECT) != 0; in is_packetized()
416 /* Done while waiting without holding the pipe lock - thus the READ_ONCE() */
419 unsigned int head = READ_ONCE(pipe->head); in pipe_writable() local
420 unsigned int tail = READ_ONCE(pipe->tail); in pipe_writable()
421 unsigned int max_usage = READ_ONCE(pipe->max_usage); in pipe_writable()
423 return !pipe_full(head, tail, max_usage) || in pipe_writable()
424 !READ_ONCE(pipe->readers); in pipe_writable()
430 struct file *filp = iocb->ki_filp; in pipe_write()
431 struct pipe_inode_info *pipe = filp->private_data; in pipe_write()
432 unsigned int head; in pipe_write() local
446 * since we don't actually need that, it's simpler to just bail here. in pipe_write()
449 return -EXDEV; in pipe_write()
455 mutex_lock(&pipe->mutex); in pipe_write()
457 if (!pipe->readers) { in pipe_write()
459 ret = -EPIPE; in pipe_write()
464 * If it wasn't empty we try to merge new data into in pipe_write()
468 * page-aligns the rest of the writes for large writes in pipe_write()
471 head = pipe->head; in pipe_write()
472 was_empty = pipe_empty(head, pipe->tail); in pipe_write()
473 chars = total_len & (PAGE_SIZE-1); in pipe_write()
475 unsigned int mask = pipe->ring_size - 1; in pipe_write()
476 struct pipe_buffer *buf = &pipe->bufs[(head - 1) & mask]; in pipe_write()
477 int offset = buf->offset + buf->len; in pipe_write()
479 if ((buf->flags & PIPE_BUF_FLAG_CAN_MERGE) && in pipe_write()
485 ret = copy_page_from_iter(buf->page, offset, chars, from); in pipe_write()
487 ret = -EFAULT; in pipe_write()
491 buf->len += ret; in pipe_write()
498 if (!pipe->readers) { in pipe_write()
501 ret = -EPIPE; in pipe_write()
505 head = pipe->head; in pipe_write()
506 if (!pipe_full(head, pipe->tail, pipe->max_usage)) { in pipe_write()
507 unsigned int mask = pipe->ring_size - 1; in pipe_write()
509 struct page *page = pipe->tmp_page; in pipe_write()
515 ret = ret ? : -ENOMEM; in pipe_write()
518 pipe->tmp_page = page; in pipe_write()
526 pipe->head = head + 1; in pipe_write()
529 buf = &pipe->bufs[head & mask]; in pipe_write()
530 buf->page = page; in pipe_write()
531 buf->ops = &anon_pipe_buf_ops; in pipe_write()
532 buf->offset = 0; in pipe_write()
533 buf->len = 0; in pipe_write()
535 buf->flags = PIPE_BUF_FLAG_PACKET; in pipe_write()
537 buf->flags = PIPE_BUF_FLAG_CAN_MERGE; in pipe_write()
538 pipe->tmp_page = NULL; in pipe_write()
543 ret = -EFAULT; in pipe_write()
547 buf->len = copied; in pipe_write()
553 if (!pipe_full(head, pipe->tail, pipe->max_usage)) in pipe_write()
557 if ((filp->f_flags & O_NONBLOCK) || in pipe_write()
558 (iocb->ki_flags & IOCB_NOWAIT)) { in pipe_write()
560 ret = -EAGAIN; in pipe_write()
565 ret = -ERESTARTSYS; in pipe_write()
572 * after waiting we need to re-check whether the pipe in pipe_write()
575 mutex_unlock(&pipe->mutex); in pipe_write()
577 wake_up_interruptible_sync_poll(&pipe->rd_wait, EPOLLIN | EPOLLRDNORM); in pipe_write()
578 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); in pipe_write()
579 wait_event_interruptible_exclusive(pipe->wr_wait, pipe_writable(pipe)); in pipe_write()
580 mutex_lock(&pipe->mutex); in pipe_write()
581 was_empty = pipe_empty(pipe->head, pipe->tail); in pipe_write()
585 if (pipe_full(pipe->head, pipe->tail, pipe->max_usage)) in pipe_write()
587 mutex_unlock(&pipe->mutex); in pipe_write()
601 if (was_empty || pipe->poll_usage) in pipe_write()
602 wake_up_interruptible_sync_poll(&pipe->rd_wait, EPOLLIN | EPOLLRDNORM); in pipe_write()
603 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); in pipe_write()
605 wake_up_interruptible_sync_poll(&pipe->wr_wait, EPOLLOUT | EPOLLWRNORM); in pipe_write()
606 if (ret > 0 && sb_start_write_trylock(file_inode(filp)->i_sb)) { in pipe_write()
610 sb_end_write(file_inode(filp)->i_sb); in pipe_write()
617 struct pipe_inode_info *pipe = filp->private_data; in pipe_ioctl()
618 unsigned int count, head, tail, mask; in pipe_ioctl() local
622 mutex_lock(&pipe->mutex); in pipe_ioctl()
624 head = pipe->head; in pipe_ioctl()
625 tail = pipe->tail; in pipe_ioctl()
626 mask = pipe->ring_size - 1; in pipe_ioctl()
628 while (tail != head) { in pipe_ioctl()
629 count += pipe->bufs[tail & mask].len; in pipe_ioctl()
632 mutex_unlock(&pipe->mutex); in pipe_ioctl()
639 mutex_lock(&pipe->mutex); in pipe_ioctl()
641 mutex_unlock(&pipe->mutex); in pipe_ioctl()
651 return -ENOIOCTLCMD; in pipe_ioctl()
655 /* No kernel lock held - fine */
660 struct pipe_inode_info *pipe = filp->private_data; in pipe_poll()
661 unsigned int head, tail; in pipe_poll() local
664 WRITE_ONCE(pipe->poll_usage, true); in pipe_poll()
667 * Reading pipe state only -- no need for acquiring the semaphore. in pipe_poll()
672 if (filp->f_mode & FMODE_READ) in pipe_poll()
673 poll_wait(filp, &pipe->rd_wait, wait); in pipe_poll()
674 if (filp->f_mode & FMODE_WRITE) in pipe_poll()
675 poll_wait(filp, &pipe->wr_wait, wait); in pipe_poll()
682 head = READ_ONCE(pipe->head); in pipe_poll()
683 tail = READ_ONCE(pipe->tail); in pipe_poll()
686 if (filp->f_mode & FMODE_READ) { in pipe_poll()
687 if (!pipe_empty(head, tail)) in pipe_poll()
689 if (!pipe->writers && filp->f_pipe != pipe->w_counter) in pipe_poll()
693 if (filp->f_mode & FMODE_WRITE) { in pipe_poll()
694 if (!pipe_full(head, tail, pipe->max_usage)) in pipe_poll()
700 if (!pipe->readers) in pipe_poll()
711 spin_lock(&inode->i_lock); in put_pipe_info()
712 if (!--pipe->files) { in put_pipe_info()
713 inode->i_pipe = NULL; in put_pipe_info()
716 spin_unlock(&inode->i_lock); in put_pipe_info()
725 struct pipe_inode_info *pipe = file->private_data; in pipe_release()
727 mutex_lock(&pipe->mutex); in pipe_release()
728 if (file->f_mode & FMODE_READ) in pipe_release()
729 pipe->readers--; in pipe_release()
730 if (file->f_mode & FMODE_WRITE) in pipe_release()
731 pipe->writers--; in pipe_release()
734 if (!pipe->readers != !pipe->writers) { in pipe_release()
735 wake_up_interruptible_all(&pipe->rd_wait); in pipe_release()
736 wake_up_interruptible_all(&pipe->wr_wait); in pipe_release()
737 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); in pipe_release()
738 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT); in pipe_release()
740 mutex_unlock(&pipe->mutex); in pipe_release()
749 struct pipe_inode_info *pipe = filp->private_data; in pipe_fasync()
752 mutex_lock(&pipe->mutex); in pipe_fasync()
753 if (filp->f_mode & FMODE_READ) in pipe_fasync()
754 retval = fasync_helper(fd, filp, on, &pipe->fasync_readers); in pipe_fasync()
755 if ((filp->f_mode & FMODE_WRITE) && retval >= 0) { in pipe_fasync()
756 retval = fasync_helper(fd, filp, on, &pipe->fasync_writers); in pipe_fasync()
757 if (retval < 0 && (filp->f_mode & FMODE_READ)) in pipe_fasync()
758 /* this can happen only if on == T */ in pipe_fasync()
759 fasync_helper(-1, filp, 0, &pipe->fasync_readers); in pipe_fasync()
761 mutex_unlock(&pipe->mutex); in pipe_fasync()
768 return atomic_long_add_return(new - old, &user->pipe_bufs); in account_pipe_buffers()
815 pipe->bufs = kcalloc(pipe_bufs, sizeof(struct pipe_buffer), in alloc_pipe_info()
818 if (pipe->bufs) { in alloc_pipe_info()
819 init_waitqueue_head(&pipe->rd_wait); in alloc_pipe_info()
820 init_waitqueue_head(&pipe->wr_wait); in alloc_pipe_info()
821 pipe->r_counter = pipe->w_counter = 1; in alloc_pipe_info()
822 pipe->max_usage = pipe_bufs; in alloc_pipe_info()
823 pipe->ring_size = pipe_bufs; in alloc_pipe_info()
824 pipe->nr_accounted = pipe_bufs; in alloc_pipe_info()
825 pipe->user = user; in alloc_pipe_info()
826 mutex_init(&pipe->mutex); in alloc_pipe_info()
827 lock_set_cmp_fn(&pipe->mutex, pipe_lock_cmp_fn, NULL); in alloc_pipe_info()
844 if (pipe->watch_queue) in free_pipe_info()
845 watch_queue_clear(pipe->watch_queue); in free_pipe_info()
848 (void) account_pipe_buffers(pipe->user, pipe->nr_accounted, 0); in free_pipe_info()
849 free_uid(pipe->user); in free_pipe_info()
850 for (i = 0; i < pipe->ring_size; i++) { in free_pipe_info()
851 struct pipe_buffer *buf = pipe->bufs + i; in free_pipe_info()
852 if (buf->ops) in free_pipe_info()
856 if (pipe->watch_queue) in free_pipe_info()
857 put_watch_queue(pipe->watch_queue); in free_pipe_info()
859 if (pipe->tmp_page) in free_pipe_info()
860 __free_page(pipe->tmp_page); in free_pipe_info()
861 kfree(pipe->bufs); in free_pipe_info()
873 d_inode(dentry)->i_ino); in pipefs_dname()
882 struct inode *inode = new_inode_pseudo(pipe_mnt->mnt_sb); in get_pipe_inode()
888 inode->i_ino = get_next_ino(); in get_pipe_inode()
894 inode->i_pipe = pipe; in get_pipe_inode()
895 pipe->files = 2; in get_pipe_inode()
896 pipe->readers = pipe->writers = 1; in get_pipe_inode()
897 inode->i_fop = &pipefifo_fops; in get_pipe_inode()
905 inode->i_state = I_DIRTY; in get_pipe_inode()
906 inode->i_mode = S_IFIFO | S_IRUSR | S_IWUSR; in get_pipe_inode()
907 inode->i_uid = current_fsuid(); in get_pipe_inode()
908 inode->i_gid = current_fsgid(); in get_pipe_inode()
927 return -ENFILE; in create_pipe_files()
930 error = watch_queue_init(inode->i_pipe); in create_pipe_files()
932 free_pipe_info(inode->i_pipe); in create_pipe_files()
942 free_pipe_info(inode->i_pipe); in create_pipe_files()
947 f->private_data = inode->i_pipe; in create_pipe_files()
948 f->f_pipe = 0; in create_pipe_files()
953 put_pipe_info(inode, inode->i_pipe); in create_pipe_files()
957 res[0]->private_data = inode->i_pipe; in create_pipe_files()
958 res[0]->f_pipe = 0; in create_pipe_files()
971 return -EINVAL; in __do_pipe_flags()
991 files[0]->f_mode |= FMODE_NOWAIT; in __do_pipe_flags()
992 files[1]->f_mode |= FMODE_NOWAIT; in __do_pipe_flags()
1031 error = -EFAULT; in do_pipe2()
1062 wait_event_interruptible(pipe->rd_wait, pipe_readable(pipe)); in pipe_wait_readable()
1069 wait_event_interruptible(pipe->wr_wait, pipe_writable(pipe)); in pipe_wait_writable()
1091 prepare_to_wait(&pipe->rd_wait, &rdwait, TASK_INTERRUPTIBLE); in wait_for_partner()
1094 finish_wait(&pipe->rd_wait, &rdwait); in wait_for_partner()
1099 return cur == *cnt ? -ERESTARTSYS : 0; in wait_for_partner()
1104 wake_up_interruptible_all(&pipe->rd_wait); in wake_up_partner()
1110 bool is_pipe = inode->i_sb->s_magic == PIPEFS_MAGIC; in fifo_open()
1113 filp->f_pipe = 0; in fifo_open()
1115 spin_lock(&inode->i_lock); in fifo_open()
1116 if (inode->i_pipe) { in fifo_open()
1117 pipe = inode->i_pipe; in fifo_open()
1118 pipe->files++; in fifo_open()
1119 spin_unlock(&inode->i_lock); in fifo_open()
1121 spin_unlock(&inode->i_lock); in fifo_open()
1124 return -ENOMEM; in fifo_open()
1125 pipe->files = 1; in fifo_open()
1126 spin_lock(&inode->i_lock); in fifo_open()
1127 if (unlikely(inode->i_pipe)) { in fifo_open()
1128 inode->i_pipe->files++; in fifo_open()
1129 spin_unlock(&inode->i_lock); in fifo_open()
1131 pipe = inode->i_pipe; in fifo_open()
1133 inode->i_pipe = pipe; in fifo_open()
1134 spin_unlock(&inode->i_lock); in fifo_open()
1137 filp->private_data = pipe; in fifo_open()
1140 mutex_lock(&pipe->mutex); in fifo_open()
1145 switch (filp->f_mode & (FMODE_READ | FMODE_WRITE)) { in fifo_open()
1152 pipe->r_counter++; in fifo_open()
1153 if (pipe->readers++ == 0) in fifo_open()
1156 if (!is_pipe && !pipe->writers) { in fifo_open()
1157 if ((filp->f_flags & O_NONBLOCK)) { in fifo_open()
1160 filp->f_pipe = pipe->w_counter; in fifo_open()
1162 if (wait_for_partner(pipe, &pipe->w_counter)) in fifo_open()
1171 * POSIX.1 says that O_NONBLOCK means return -1 with in fifo_open()
1174 ret = -ENXIO; in fifo_open()
1175 if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers) in fifo_open()
1178 pipe->w_counter++; in fifo_open()
1179 if (!pipe->writers++) in fifo_open()
1182 if (!is_pipe && !pipe->readers) { in fifo_open()
1183 if (wait_for_partner(pipe, &pipe->r_counter)) in fifo_open()
1196 pipe->readers++; in fifo_open()
1197 pipe->writers++; in fifo_open()
1198 pipe->r_counter++; in fifo_open()
1199 pipe->w_counter++; in fifo_open()
1200 if (pipe->readers == 1 || pipe->writers == 1) in fifo_open()
1205 ret = -EINVAL; in fifo_open()
1210 mutex_unlock(&pipe->mutex); in fifo_open()
1214 if (!--pipe->readers) in fifo_open()
1215 wake_up_interruptible(&pipe->wr_wait); in fifo_open()
1216 ret = -ERESTARTSYS; in fifo_open()
1220 if (!--pipe->writers) in fifo_open()
1221 wake_up_interruptible_all(&pipe->rd_wait); in fifo_open()
1222 ret = -ERESTARTSYS; in fifo_open()
1226 mutex_unlock(&pipe->mutex); in fifo_open()
1244 * Currently we rely on the pipe array holding a power-of-2 number
1263 * occupancy doesn't exceed nr_slots; if it does, EBUSY will be
1269 unsigned int head, tail, mask, n; in pipe_resize_ring() local
1274 return -ENOMEM; in pipe_resize_ring()
1276 spin_lock_irq(&pipe->rd_wait.lock); in pipe_resize_ring()
1277 mask = pipe->ring_size - 1; in pipe_resize_ring()
1278 head = pipe->head; in pipe_resize_ring()
1279 tail = pipe->tail; in pipe_resize_ring()
1281 n = pipe_occupancy(head, tail); in pipe_resize_ring()
1283 spin_unlock_irq(&pipe->rd_wait.lock); in pipe_resize_ring()
1285 return -EBUSY; in pipe_resize_ring()
1293 unsigned int h = head & mask; in pipe_resize_ring()
1294 unsigned int t = tail & mask; in pipe_resize_ring() local
1295 if (h > t) { in pipe_resize_ring()
1296 memcpy(bufs, pipe->bufs + t, in pipe_resize_ring()
1299 unsigned int tsize = pipe->ring_size - t; in pipe_resize_ring()
1301 memcpy(bufs + tsize, pipe->bufs, in pipe_resize_ring()
1303 memcpy(bufs, pipe->bufs + t, in pipe_resize_ring()
1308 head = n; in pipe_resize_ring()
1311 kfree(pipe->bufs); in pipe_resize_ring()
1312 pipe->bufs = bufs; in pipe_resize_ring()
1313 pipe->ring_size = nr_slots; in pipe_resize_ring()
1314 if (pipe->max_usage > nr_slots) in pipe_resize_ring()
1315 pipe->max_usage = nr_slots; in pipe_resize_ring()
1316 pipe->tail = tail; in pipe_resize_ring()
1317 pipe->head = head; in pipe_resize_ring()
1320 pipe->max_usage = nr_slots; in pipe_resize_ring()
1321 pipe->nr_accounted = nr_slots; in pipe_resize_ring()
1324 spin_unlock_irq(&pipe->rd_wait.lock); in pipe_resize_ring()
1327 wake_up_interruptible(&pipe->wr_wait); in pipe_resize_ring()
1333 * pipe size if successful, or return -ERROR on error.
1342 return -EBUSY; in pipe_set_size()
1348 return -EINVAL; in pipe_set_size()
1357 if (nr_slots > pipe->max_usage && in pipe_set_size()
1359 return -EPERM; in pipe_set_size()
1361 user_bufs = account_pipe_buffers(pipe->user, pipe->nr_accounted, nr_slots); in pipe_set_size()
1363 if (nr_slots > pipe->max_usage && in pipe_set_size()
1367 ret = -EPERM; in pipe_set_size()
1375 return pipe->max_usage * PAGE_SIZE; in pipe_set_size()
1378 (void) account_pipe_buffers(pipe->user, nr_slots, pipe->nr_accounted); in pipe_set_size()
1383 * Note that i_pipe and i_cdev share the same location, so checking ->i_pipe is
1388 struct pipe_inode_info *pipe = file->private_data; in get_pipe_info()
1390 if (file->f_op != &pipefifo_fops || !pipe) in get_pipe_info()
1404 return -EBADF; in pipe_fcntl()
1406 mutex_lock(&pipe->mutex); in pipe_fcntl()
1413 ret = pipe->max_usage * PAGE_SIZE; in pipe_fcntl()
1416 ret = -EINVAL; in pipe_fcntl()
1420 mutex_unlock(&pipe->mutex); in pipe_fcntl()
1430 * pipefs should _never_ be mounted by userland - too much of security hassle,
1431 * no real gain from having the whole file system mounted. So we don't need
1432 * any operations on the root directory. However, we need a non-trivial
1433 * d_name - pipe: will go nicely and kill the special-casing in procfs.
1440 return -ENOMEM; in pipefs_init_fs_context()
1441 ctx->ops = &pipefs_ops; in pipefs_init_fs_context()
1442 ctx->dops = &pipefs_dentry_operations; in pipefs_init_fs_context()
1462 return -EINVAL; in do_proc_dopipe_max_size_conv()
1482 .procname = "pipe-max-size",
1489 .procname = "pipe-user-pages-hard",
1496 .procname = "pipe-user-pages-soft",