函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:__mpage_writepage

函数原型:static int __mpage_writepage(struct page *page, struct writeback_control *wbc, void *data)

返回类型:int

参数:

类型参数名称
struct page *page
struct writeback_control *wbc
void *data
499  mpd等于data
500  bio等于bio
501  mapping等于 See page-flags.h for PAGE_MAPPING_FLAGS
502  inode等于host
503  blkbits等于i_blkbits
505  blocks_per_page等于PAGE_SIZE右移blkbits
510  first_unmapped等于blocks_per_page
511  struct block_device * bdev = NULL
512  boundary等于0
513  boundary_block等于0
514  struct block_device * boundary_bdev = NULL
517  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
518  ret等于0
519  op_flags等于wbc_to_write_flags(wbc)
521  如果page_has_buffers(page)则
522  head等于If we *know* page->private refers to buffer_heads (page)
523  bh等于head
526  page_block等于0
527  循环
529  如果非buffer_mapped(bh)则
534  如果buffer_dirty(bh)则转到:confused
538  继续下一循环
541  如果first_unmapped不等于blocks_per_page则转到:confused
546  如果page_block
547  如果 start block number 不等于blocks[page_block - 1]加1则转到:confused
552  如果boundary
556  bdev等于b_bdev
557 bh等于 circular list of page's buffers 不等于head循环
559  如果first_unmapped则转到:page_is_mapped
568  转到:confused
574  BUG_ON(!PageUptodate(page))
575  block_in_file等于 Our offset within mapping. 左移PAGE_SHIFT determines the page size blkbits
576  last_block等于i_size减1右移blkbits
577  the page this bh is mapped to 等于page
578 page_block小于blocks_per_page循环
580  buffer state bitmap (see above) 等于0
581  size of mapping 等于1左移blkbits
582  如果get_block(inode, block_in_file, & map_bh, 1)则转到:confused
584  如果buffer_new( & map_bh)则clean_bdev_bh_alias( & map_bh)
586  如果buffer_boundary( & map_bh)则
588  boundary_bdev等于b_bdev
590  如果page_block
591  如果 start block number 不等于blocks[page_block - 1]加1则转到:confused
594  blocks[page_block++]等于 start block number
595  boundary等于buffer_boundary( & map_bh)
596  bdev等于b_bdev
597  如果block_in_file恒等于last_block退出
599  block_in_file自加
601  BUG_ON(page_block == 0)
603  first_unmapped等于page_block
605  page_is_mapped :
606  end_index等于i_size右移PAGE_SHIFT determines the page size
607  如果 Our offset within mapping. 大于等于end_index
616  offset等于i_size按位与PAGE_SIZE减1
618  如果 Our offset within mapping. 大于end_index或非offset则转到:confused
620  zero_user_segment(page, offset, PAGE_SIZE)
626  如果biolast_block_in_bio不等于blocks[0]减1则bio等于mpage_bio_submit(REQ_OP_WRITE, op_flags, bio)
629  alloc_new :
630  如果(bio == NULL)则
631  如果first_unmapped恒等于blocks_per_page
636  bio等于mpage_alloc(bdev, blocks[0] << (blkbits - 9), BIO_MAX_PAGES, GFP_NOFS | __GFP_HIGH)
638  如果(bio == NULL)则转到:confused
641  wbc_init_bio(wbc, bio)
642  bi_write_hint等于i_write_hint
650  wbc_account_cgroup_owner(wbc, page, PAGE_SIZE)
651  length等于first_unmapped左移blkbits
652  如果bio_add_page(bio, page, length, 0)小于length
653  bio等于mpage_bio_submit(REQ_OP_WRITE, op_flags, bio)
654  转到:alloc_new
657  We have our BIO, so we can now mark the buffers clean. Make* sure to only clean buffers which we know we'll be writing.
659  BUG_ON(Only test-and-set exist for PG_writeback. The unconditional operators are* risky: they bypass page accounting.)
660  set_page_writeback(page)
661  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.
662  如果boundaryfirst_unmapped不等于blocks_per_page
663  bio等于mpage_bio_submit(REQ_OP_WRITE, op_flags, bio)
664  如果boundary_block
668  否则
669  last_block_in_bio等于blocks[blocks_per_page - 1]
671  转到:out
673  confused :
674  如果biobio等于mpage_bio_submit(REQ_OP_WRITE, op_flags, bio)
677  如果use_writepage
678  ret等于writepage(page, wbc)
679  否则
680  ret等于负EAGAIN
681  转到:out
686  mapping_set_error - record a writeback error in the address_space*@mapping - the mapping in which an error should be set*@error - the error to set in the mapping* When writeback fails in some way, we must record that error so that
687  out :
688  bio等于bio
689  返回:ret
调用者
名称描述
mpage_writepage