Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\migrate.c Create Date:2022-07-28 15:58:48
Last Modify:2022-05-20 09:53:13 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:__buffer_migrate_page

Proto:static int __buffer_migrate_page(struct address_space *mapping, struct page *newpage, struct page *page, enum migrate_mode mode, bool check_refs)

Type:int

Parameter:

TypeParameterName
struct address_space *mapping
struct page *newpage
struct page *page
enum migrate_modemode
boolcheck_refs
744  If Not page_has_buffers(page) Then Return 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  If page_count(page) != expected_count Then Return -EAGAIN
752  head = If we *know* page->private refers to buffer_heads (page)
753  If Not Returns true if all buffers are successfully locked Then Return -EAGAIN
756  If check_refs Then
758  bool invalidated = false
760  recheck_buffers :
761  busy = false
762  spin_lock( & private_lock)
763  bh = head
764  Do
766  busy = true
767  Break
770  When bh != head cycle
771  If busy Then
772  If invalidated Then
773  rc = -EAGAIN
774  Go to unlock_buffers
778  invalidated = true
779  Go to 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  If rc != Return values from addresss_space_operations.migratepage():* - negative errno on page migration failure;* - zero on page migration success; Then Go to 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  Do
795  set_bh_page(bh, newpage, bh_offset(bh))
796  bh = circular list of page's buffers
798  When bh != head cycle
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  If mode != MIGRATE_SYNC_NO_COPY Then migrate_page_copy(newpage, page)
804  Else 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  If check_refs Then spin_unlock( & private_lock)
811  bh = head
812  Do
813  unlock_buffer(bh)
814  bh = circular list of page's buffers
816  When bh != head cycle
818  Return rc
Caller
NameDescribe
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).