Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:__mpage_writepage

Proto:static int __mpage_writepage(struct page *page, struct writeback_control *wbc, void *data)

Type:int

Parameter:

TypeParameterName
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  If page_has_buffers(page) Then
522  head = If we *know* page->private refers to buffer_heads (page)
523  bh = head
526  page_block = 0
527  Do
529  If Not buffer_mapped(bh) Then
534  If buffer_dirty(bh) Then Go to confused
538  Continue
541  If first_unmapped != blocks_per_page Then Go to confused
546  If page_block Then
547  If start block number != blocks[page_block - 1] + 1 Then Go to confused
552  If boundary Then
556  bdev = b_bdev
557  When (bh = circular list of page's buffers ) != head cycle
559  If first_unmapped Then Go to page_is_mapped
568  Go to 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  When page_block < blocks_per_page cycle
580  buffer state bitmap (see above) = 0
581  size of mapping = 1 << blkbits
582  If get_block(inode, block_in_file, & map_bh, 1) Then Go to confused
584  If buffer_new( & map_bh) Then clean_bdev_bh_alias( & map_bh)
586  If buffer_boundary( & map_bh) Then
590  If page_block Then
591  If start block number != blocks[page_block - 1] + 1 Then Go to confused
594  blocks[page_block++] = start block number
595  boundary = buffer_boundary( & map_bh)
596  bdev = b_bdev
597  If block_in_file == last_block Then Break
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  If Our offset within mapping. >= end_index Then
616  offset = i_size & PAGE_SIZE - 1
618  If Our offset within mapping. > end_index || Not offset Then Go to confused
620  zero_user_segment(page, offset, PAGE_SIZE)
626  If bio && last_block_in_bio != blocks[0] - 1 Then bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio)
629  alloc_new :
630  If (bio == NULL) Then
631  If first_unmapped == blocks_per_page Then
636  bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9), BIO_MAX_PAGES, GFP_NOFS | __GFP_HIGH)
638  If (bio == NULL) Then Go to 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  If bio_add_page(bio, page, length, 0) < length Then
653  bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio)
654  Go to 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  If boundary || first_unmapped != blocks_per_page Then
663  bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio)
664  If boundary_block Then
668  Else
669  last_block_in_bio = blocks[blocks_per_page - 1]
671  Go to out
673  confused :
674  If bio Then bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio)
677  If use_writepage Then
678  ret = writepage(page, wbc)
679  Else
680  ret = -EAGAIN
681  Go to 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  Return ret
Caller
NameDescribe
mpage_writepage