函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\migrate.c Create Date:2022-07-27 17:32:54
Last Modify:2022-05-20 09:53:13 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:__buffer_migrate_page

函数原型:static int __buffer_migrate_page(struct address_space *mapping, struct page *newpage, struct page *page, enum migrate_mode mode, bool check_refs)

返回类型:int

参数:

类型参数名称
struct address_space *mapping
struct page *newpage
struct page *page
enum migrate_modemode
boolcheck_refs
744  如果非page_has_buffers(page)则返回:Common logic to directly migrate a single LRU page suitable for* pages that do not use PagePrivate/PagePrivate2.* Pages are locked upon entry and exit.
748  expected_count等于expected_page_refs(mapping, page)
749  如果page_count(page)不等于expected_count则返回:负EAGAIN
752  head等于If we *know* page->private refers to buffer_heads (page)
753  如果非Returns true if all buffers are successfully locked 则返回:负EAGAIN
756  如果check_refs
758  bool invalidated = false
760  recheck_buffers :
761  busy = false
762  加自旋锁
763  bh等于head
764  循环
766  busy = true
767  退出
770 bh不等于head循环
771  如果busy
772  如果invalidated
773  rc等于负EAGAIN
774  转到:unlock_buffers
778  invalidated = true
779  转到:recheck_buffers
783  rc等于Replace the page in the mapping.* The number of remaining references must be:* 1 for anonymous pages without a mapping* 2 for pages with a mapping* 3 for pages with a mapping and PagePrivate/PagePrivate2 set.
784  如果rc不等于Return values from addresss_space_operations.migratepage():* - negative errno on page migration failure;* - zero on page migration success;则转到:unlock_buffers
787  Private page markings that may be used by the filesystem that owns the page* for its own purposes.* - PG_private and PG_private_2 cause releasepage() and co to be invoked
788  set_page_private(newpage, page_private(page))
789  set_page_private(page, 0)
790  Perform a free_page(), also freeing any swap cache associated with* this page if it is the last user of the page.
791  get_page(newpage)
793  bh等于head
794  循环
795  set_bh_page(bh, newpage, bh_offset(bh))
796  bh等于 circular list of page's buffers
798 bh不等于head循环
800  Private page markings that may be used by the filesystem that owns the page* for its own purposes.* - PG_private and PG_private_2 cause releasepage() and co to be invoked
802  如果mode不等于MIGRATE_SYNC_NO_COPYmigrate_page_copy(newpage, page)
804  否则Copy the page to its new location
807  rc等于Return values from addresss_space_operations.migratepage():* - negative errno on page migration failure;* - zero on page migration success;
808  unlock_buffers :
809  如果check_refs自旋锁解锁
811  bh等于head
812  循环
813  unlock_buffer(bh)
814  bh等于 circular list of page's buffers
816 bh不等于head循环
818  返回:rc
调用者
名称描述
buffer_migrate_pageMigration function for pages with buffers. This function can only be used* if the underlying filesystem guarantees that no other references to "page"* exist. For example attached buffer heads are accessed only under page lock.
buffer_migrate_page_norefsSame as above except that this variant is more careful and checks that there* are also no buffer head references. This function is the right one for* mappings where buffer heads are directly looked up and referenced (such as* block device mappings).