Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\pipe.c Create Date:2022-07-28 20:04:29
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:pipe_write

Proto:static ssize_t pipe_write(struct kiocb *iocb, struct iov_iter *from)

Type:ssize_t

Parameter:

TypeParameterName
struct kiocb *iocb
struct iov_iter *from
433  filp = ki_filp
434  pipe = needed for tty driver, and maybe others
436  ret = 0
437  total_len = iov_iter_count(from)
439  bool was_empty = false
442  If Value for the false possibility is greater at compile time(total_len == 0) Then Return 0
445  __pipe_lock(pipe)
447  If Not readers Then
448  send_sig(SIGPIPE, current process, 0)
449  ret = -EPIPE
450  Go to out
464  head = head
465  was_empty = pipe_empty - Return true if the pipe is empty*@head: The pipe ring head pointer*@tail: The pipe ring tail pointer
466  chars = total_len & PAGE_SIZE - 1
467  If chars && Not was_empty Then
468  mask = ring_size - 1
469  buf = bufs[(head - 1) & mask]
470  offset = offset + len
472  If pipe_buf_can_merge(buf) && offset + chars <= PAGE_SIZE Then
474  If ret Then Go to out
479  ret = -EFAULT
480  Go to out
483  len += ret
484  If Not iov_iter_count(from) Then Go to out
489  cycle
490  If Not readers Then
492  If Not ret Then ret = -EPIPE
494  Break
497  head = head
499  mask = ring_size - 1
500  buf = bufs[head & mask]
501  page = tmp_page
504  If Not page Then
518  spin_lock_irq( & lock)
520  head = head
522  spin_unlock_irq( & lock)
523  Continue
526  head = head + 1
527  spin_unlock_irq( & lock)
530  buf = bufs[head & mask]
531  page = page
533  offset = 0
534  len = 0
535  flags = 0
536  If is_packetized(filp) Then
540  tmp_page = NULL
544  If Not ret Then ret = -EFAULT
546  Break
548  ret += copied
549  offset = 0
550  len = copied
552  If Not iov_iter_count(from) Then Break
556  If Not pipe_full - Return true if the pipe is full*@head: The pipe ring head pointer*@tail: The pipe ring tail pointer*@limit: The maximum amount of slots available. Then Continue
560  If f_flags & O_NONBLOCK Then
561  If Not ret Then ret = -EAGAIN
563  Break
568  Break
577  __pipe_unlock(pipe)
578  If was_empty Then
582  wait_event_interruptible - sleep until a condition gets true*@wq_head: the waitqueue to wait on*@condition: a C expression for the event to wait for* The process is put to sleep (TASK_INTERRUPTIBLE) until the(wait, Done while waiting without holding the pipe lock - thus the READ_ONCE() )
583  __pipe_lock(pipe)
584  was_empty = pipe_empty - Return true if the pipe is empty*@head: The pipe ring head pointer*@tail: The pipe ring tail pointer
586  out :
587  __pipe_unlock(pipe)
598  If was_empty Then
599  wake_up_interruptible_sync_poll( & wait, Epoll event masks | EPOLLRDNORM)
600  an be called from interrupts
602  If ret > 0 && sb_start_write_trylock(i_sb) Then
603  err = file_update_time(filp)
604  If err Then ret = err
606  sb_end_write - drop write access to a superblock*@sb: the super we wrote to* Decrement number of writers to the filesystem. Wake up possible waiters* wanting to freeze the filesystem.
608  Return ret