函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:aio_setup_ring

函数原型:static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events)

返回类型:int

参数:

类型参数名称
struct kioctx *ctx
unsigned intnr_events
463  mm等于mm
470  nr_events加等于2
472  size等于sizeof(structaio_ring)
473  size加等于sizeof(structio_event)乘nr_events
475  nr_pages等于PFN_UP(size)
476  如果nr_pages小于0则返回:负EINVAL
479  file等于aio_private_file(ctx, nr_pages)
480  如果是错误
481  aio_ring_file = NULL
482  返回:负ENOMEM
485  aio_ring_file等于file
486  nr_events等于PAGE_SIZEnr_pagessizeof(structaio_ring)的差除sizeof(structio_event)
489  ring_pages等于internal_pages
490  如果nr_pages大于AIO_RING_PAGES
491  ring_pages等于分配数组内存并置零
493  如果非ring_pages
495  返回:负ENOMEM
499 i小于nr_pages循环
501  page等于d_or_create_page - locate or add a pagecache page*@mapping: the page's address_space*@index: the page's index into the mapping*@gfp_mask: page allocation mode* Looks up the page cache slot at @mapping & @offset
503  如果非page退出
505  pr_debug("pid(%d) page[%d]->count=%d\n", pid, i, page_count(page))
507  SetPageUptodate(page)
508  lock_page - unlock a locked page*@page: the page* Unlocks the page and wakes up sleepers in ___wait_on_page_locked().* Also wakes sleepers in wait_on_page_writeback() because the wakeup* mechanism between PageLocked pages and PageWriteback pages is shared.
510  ring_pages[i]等于page
512  nr_pages等于i
514  如果此条件成立可能性小(为编译器优化)(i != nr_pages)则
515  aio_free_ring(ctx)
516  返回:负ENOMEM
519  mmap_size等于nr_pagesPAGE_SIZE
520  pr_debug("attempting mmap of %lu bytes\n", mmap_size)
522  如果lock for writing
523  mmap_size等于0
524  aio_free_ring(ctx)
525  返回:负EINTR
528  mmap_base等于do_mmap_pgoff(aio_ring_file, 0, mmap_size, page can be read | page can be written , Share changes , 0, & unused, NULL)
531  lease a write lock
532  如果是错误
533  mmap_size等于0
534  aio_free_ring(ctx)
535  返回:负ENOMEM
538  pr_debug("mmap address: 0x%08lx\n", mmap_base)
540  user_id等于mmap_base
541  Size of ringbuffer, in units of struct io_event 等于nr_events
543  ring等于kmap_atomic(ring_pages[0])
544  number of io_events 等于nr_events
545  kernel internal index number 等于0U的反
546  Written to by userland or under ring_lock * mutex by aio_read_events_ring(). 等于tail等于0
547  magic等于AIO_RING_MAGIC
548  compat_features等于AIO_RING_COMPAT_FEATURES
549  incompat_features等于AIO_RING_INCOMPAT_FEATURES
550  size of aio_ring 等于sizeof(structaio_ring)
551  Prevent people trying to call kunmap_atomic() as if it were kunmap()* kunmap_atomic() should get the return value of kmap_atomic, not the page.(ring)
552  flush_dcache_page(ring_pages[0])
554  返回:0
调用者
名称描述
ioctx_allocx_alloc* Allocates and initializes an ioctx. Returns an ERR_PTR if it failed.