函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\iomap\direct-io.c Create Date:2022-07-29 11:07:47
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:map_dio_rw() always completes O_[D]SYNC writes regardless of whether the IO* is being issued as AIO or not. This allows us to optimise pure data writes* to use REQ_FUA rather than requiring generic_write_sync() to issue a* REQ_FLUSH post write

函数原型:ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, const struct iomap_ops *ops, const struct iomap_dio_ops *dops, bool wait_for_completion)

返回类型:ssize_t

参数:

类型参数名称
struct kiocb *iocb
struct iov_iter *iter
const struct iomap_ops *ops
const struct iomap_dio_ops *dops
boolwait_for_completion
405  mapping等于f_mapping
406  inode等于file_inode(文件指针)
407  count等于iov_iter_count(iter)
408  pos等于文件偏移
409  end等于文件偏移count减1, ret等于0
410  flags等于direct I/O
414  lockdep_assert_held( & i_rwsem)
416  如果非count则返回:0
419  如果WARN_ON(is_sync_kiocb(iocb) && !wait_for_completion)则返回:负EIO
422  dio等于开辟内存
423  如果非dio则返回:负ENOMEM
426  iocb等于iocb
427  atomic_set( & ref, 1)
428  size等于0
429  i_size等于NOTE: in a 32bit arch with a preemptable kernel and* an UP compile the i_size_read/write must be atomic* with respect to the local cpu (unlike with preempt disabled),* but they don't need to be atomic with respect to other cpus like in* true SMP (so they
430  dops等于dops
431  error等于0
432  flags等于0
434  iter等于iter
435  waiter等于当前进程
436  cookie等于BLK_QC_T_NONE
437  last_queue = NULL
439  如果iov_iter_rw(iter)恒等于generic data direction definitions
440  如果pos大于等于i_size则转到:out_free_dio
443  如果iter_is_iovec(iter)则flags或等于IOMAP_DIO_DIRTY
445  否则
446  flags或等于writing, must allocate blocks
447  flags或等于IOMAP_DIO_WRITE
450  如果ki_flags按位与IOCB_DSYNCflags或等于IOMAP_DIO_NEED_SYNC
459  如果ki_flags按位与IOCB_DSYNC按位或IOCB_SYNC的值的值恒等于IOCB_DSYNCflags或等于Private flags for iomap_dio, must not overlap with the public ones in* iomap.h:
463  如果ki_flags按位与IOCB_NOWAIT
465  ret等于负EAGAIN
466  转到:out_free_dio
468  flags或等于do not block
471  ret等于lemap_write_and_wait_range - write out & wait on a file range*@mapping: the address_space for the pages*@lstart: offset in bytes where the range starts*@lend: offset in bytes where the range ends (inclusive)
472  如果ret则转到:out_free_dio
481  ret等于validate_inode_pages2_range - remove range of pages from an address_space*@mapping: the address_space*@start: the page offset 'from' which to invalidate*@end: the page offset 'to' which to invalidate (inclusive)* Any pages which are found to be mapped
483  如果retWarn about a page cache invalidation failure during a direct I/O write.
485  ret等于0
487  如果iov_iter_rw(iter)恒等于WRITE且非wait_for_completion且非s_dio_done_wq
489  ret等于Create workqueue for deferred direct IO completions. We allocate the* workqueue when it's first needed. This avoids creating workqueue for* filesystems that don't need it and also allows us to create the workqueue
490  如果ret小于0则转到:out_free_dio
494  允许I/O信号请求
496  blk_start_plug( & plug)
497  循环
498  ret等于Execute a iomap write on a segment of the mapping that spans a* contiguous range of pages that have identical block mapping state
500  如果ret小于等于0则
502  如果ret恒等于负ENOTBLK
503  wait_for_completion = true
504  ret等于0
506  退出
508  pos加等于ret
510  如果iov_iter_rw(iter)恒等于generic data direction definitions pos大于等于i_size
517  退出
519 count等于iov_iter_count(iter)大于0循环
520  blk_finish_plug( & plug)
522  如果ret小于0则Set an error in the dio if none is set yet. We have to use cmpxchg* as the submission context and the completion context(s) can race to* update the error.
529  如果flags按位与Private flags for iomap_dio, must not overlap with the public ones in* iomap.h:flags与等于IOMAP_DIO_NEED_SYNC的反
532  WRITE_ONCE( for ->iopoll , cookie)
533  WRITE_ONCE(private, last_queue)
550  wait_for_completion等于wait_for_completion
551  如果非atomic_dec_and_test( & ref)则
552  如果非wait_for_completion则返回:负cb queued, will get completion event
555  循环
557  如果非READ_ONCE(waiter)则退出
560  如果非ki_flags按位与IOCB_HIPRI的值或非last_queue或非blk_poll(last_queue, cookie, true)则io_schedule()
566  set_current_state() includes a barrier so that the write of current->state* is correctly serialised wrt the caller's subsequent test of whether to* actually sleep:* for (;;) {* set_current_state(TASK_UNINTERRUPTIBLE);* if (!need_sleep)* break;* (就绪态)
569  返回:iomap_dio_complete(dio)
571  out_free_dio :
572  释放内存
573  返回:ret