Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\buffer.c Create Date:2022-07-28 20:14:10
Last Modify:2020-03-18 10:38:29 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:While block_write_full_page is writing back the dirty buffers under* the page lock, whoever dirtied the buffers may decide to clean them* again at any time

Proto:int __block_write_full_page(struct inode *inode, struct page *page, get_block_t *get_block, struct writeback_control *wbc, bh_end_io_t *handler)

Type:int

Parameter:

TypeParameterName
struct inode *inode
struct page *page
get_block_t *get_block
struct writeback_control *wbc
bh_end_io_t *handler
1718  nr_underway = 0
1719  write_flags = wbc_to_write_flags(wbc)
1721  head = create_page_buffers(page, inode, (1 << BH_Dirty) | (1 << BH_Uptodate))
1734  bh = head
1735  blocksize = size of mapping
1736  bbits = Size is a power-of-two in the range 512..PAGE_SIZE,* and the case we care about most is PAGE_SIZE.* So this *could* possibly be written with those* constraints in mind (relevant mostly if some* architecture has a slow bit-scan instruction)
1738  block = Our offset within mapping. << PAGE_SHIFT determines the page size - bbits
1739  last_block = 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 - 1 >> bbits
1745  Do
1746  If block > last_block Then
1757  Else if ( Not buffer_mapped(bh) || buffer_delay(bh)) && buffer_dirty(bh) Then
1760  err = get_block(inode, block, bh, 1)
1761  If err Then Go to recover
1764  If buffer_new(bh) Then
1770  bh = circular list of page's buffers
1771  block++
1772  When bh != head cycle
1774  Do
1775  If Not buffer_mapped(bh) Then Continue
1785  lock_buffer(bh)
1786  Else if Not trylock_buffer(bh) Then
1788  Continue
1790  If test_clear_buffer_dirty(bh) Then
1792  Else
1793  unlock_buffer(bh)
1795  When (bh = circular list of page's buffers ) != head cycle
1801  BUG_ON(Only test-and-set exist for PG_writeback. The unconditional operators are* risky: they bypass page accounting.)
1802  set_page_writeback(page)
1804  Do
1805  next = circular list of page's buffers
1806  If buffer_async_write(bh) Then
1809  nr_underway++
1811  bh = next
1812  When bh != head cycle
1813  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.
1815  err = 0
1816  done :
1817  If nr_underway == 0 Then
1823  d_page_writeback - end writeback against a page*@page: the page
1830  Return err
1832  recover :
1839  bh = head
1841  Do
1842  If buffer_mapped(bh) && buffer_dirty(bh) && Not buffer_delay(bh) Then
1844  lock_buffer(bh)
1846  Else
1853  When (bh = circular list of page's buffers ) != head cycle
1854  SetPageError(page)
1855  BUG_ON(Only test-and-set exist for PG_writeback. The unconditional operators are* risky: they bypass page accounting.)
1856  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
1857  set_page_writeback(page)
1858  Do
1859  next = circular list of page's buffers
1860  If buffer_async_write(bh) Then
1864  nr_underway++
1866  bh = next
1867  When bh != head cycle
1868  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.
1869  Go to done
Caller
NameDescribe
nobh_writepagebh_writepage() - based on block_full_write_page() except* that it tries to operate without attaching bufferheads to* the page.
block_write_full_pageThe generic ->writepage function for buffer-backed address_spaces