Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:__blkdev_direct_IO

Proto:static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)

Type:ssize_t

Parameter:

TypeParameterName
struct kiocb *iocb
struct iov_iter *iter
intnr_pages
340  file = ki_filp
341  inode = bdev_file_inode(file)
342  bdev = I_BDEV(inode)
346  is_poll = (ki_flags & IOCB_HIPRI) != 0
347  is_read = iov_iter_rw(iter) == generic data direction definitions
348  pos = The 'ki_filp' pointer is shared in a union for aio
349  qc = BLK_QC_T_NONE
350  ret = 0
352  If (pos | iov_iter_alignment(iter)) & bdev_logical_block_size(bdev) - 1 Then Return -EINVAL
356  bio = bio_alloc_bioset(GFP_KERNEL, nr_pages, & blkdev_dio_pool)
358  dio = container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(bio, structblkdev_dio, bio)
359  is_sync = is_sync = is_sync_kiocb(iocb)
360  If is_sync Then
361  waiter = current process
362  get a reference to a bio, so it won't disappear. the intended use is* something like:* bio_get(bio);* submit_bio(rw, bio);* if (bio->bi_flags ...)* do_something* bio_put(bio);* without the bio_get(), it could potentially complete I/O before submit_bio
363  Else
364  iocb = iocb
367  size = 0
368  multi_bio = false
369  should_dirty = is_read && iter_is_iovec(iter)
375  If Not is_poll Then blk_start_plug( & plug)
378  cycle
379  bio_set_dev(bio, bdev)
380  device address in 512 byte sectors = pos >> 9
381  bi_write_hint = ki_hint
382  bi_private = dio
383  bi_end_io = blkdev_bio_end_io
384  bi_ioprio = See linux/ioprio.h
386  ret = bio_iov_iter_get_pages(bio, iter)
389  bio_endio(bio)
390  Break
393  If is_read Then
397  Else
402  size += residual I/O count
403  pos += residual I/O count
405  nr_pages = iov_iter_npages(iter, BIO_MAX_PAGES)
406  If Not nr_pages Then
407  bool polled = false
409  If ki_flags & IOCB_HIPRI Then
414  qc = submit_bio(bio)
418  Break
421  If Not multi_bio Then
429  multi_bio = true
430  atomic_set( & ref, 2)
431  Else
432  atomic_inc( & ref)
435  submit_bio(bio)
436  bio = bio_alloc(GFP_KERNEL, nr_pages)
439  If Not is_poll Then blk_finish_plug( & plug)
442  If Not is_sync Then Return -cb queued, will get completion event
445  cycle
446  set_current_state(TASK_UNINTERRUPTIBLE)
447  If Not READ_ONCE(waiter) Then Break
450  If Not (ki_flags & IOCB_HIPRI) || Not blk_poll(bdev_get_queue(bdev), qc, true) Then io_schedule()
454  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;* (Used in tsk->state: )
456  If Not ret Then ret = blk_status_to_errno(bi_status)
458  If Value is more likely to compile time(!ret) Then ret = size
461  bio_put( & bio)
462  Return ret
Caller
NameDescribe
blkdev_direct_IO