函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:__blkdev_direct_IO_simple

函数原型:static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)

返回类型:ssize_t

参数:

类型参数名称
struct kiocb *iocb
struct iov_iter *iter
intnr_pages
205  file等于文件指针
206  bdev等于I_BDEV(bdev_file_inode(file))
208  pos等于文件偏移
209  bool should_dirty = false
214  如果pos按位或iov_iter_alignment(iter)的值按位与bdev_logical_block_size(bdev)减1则返回:负EINVAL
218  如果nr_pages小于等于DIO_INLINE_BIO_VECSvecs等于inline_vecs
220  否则
221  vecs等于分配数组内存
223  如果非vecs则返回:负ENOMEM
227  bio_init( & bio, vecs, nr_pages)
228  bio_set_dev( & bio, bdev)
229  device address in 512 byte sectors 等于pos右移9位
230  bi_write_hint等于ki_hint
231  bi_private等于当前进程
232  bi_end_io等于blkdev_bio_end_io_simple
233  bi_ioprio等于 See linux/ioprio.h
235  ret等于bio_iov_iter_get_pages( & bio, iter)
236  如果此条件成立可能性小(为编译器优化)(ret)则转到:out
238  ret等于 residual I/O count
240  如果iov_iter_rw(iter)恒等于generic data direction definitions
241  bottom bits req flags, * top bits REQ_OP. Use * accessors.等于REQ_OP_READ
242  如果iter_is_iovec(iter)则should_dirty = true
244  否则
245  bottom bits req flags, * top bits REQ_OP. Use * accessors.等于dio_bio_write_op(iocb)
246  task_io_account_write(ret)
248  如果ki_flags按位与IOCB_HIPRIMark a bio as polled. Note that for async polled IO, the caller must* expect -EWOULDBLOCK if we cannot allocate a request (or other resources).* We cannot block waiting for requests on polled IO, as those completions* must be found by the caller
251  qc等于submit_bio( & bio)
252  循环
253  set_current_state(深度睡眠态)
254  如果非READ_ONCE(bi_private)则退出
256  如果非ki_flags按位与IOCB_HIPRI的值或非blk_poll(bdev_get_queue(bdev), qc, true)则io_schedule()
260  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;* (就绪态)
262  bio_release_pages( & bio, should_dirty)
263  如果此条件成立可能性小(为编译器优化)(bi_status)则ret等于blk_status_to_errno(bi_status)
266  out :
267  如果vecs不等于inline_vecs释放内存
270  bio_uninit( & bio)
272  返回:ret
调用者
名称描述
blkdev_direct_IO