Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:On entry, the page is fully not uptodate.* On exit the page is fully uptodate in the areas outside (from,to)* The filesystem needs to handle block truncation upon failure.

Proto:int nobh_write_begin(struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata, get_block_t *get_block)

Type:int

Parameter:

TypeParameterName
struct address_space *mapping
loff_tpos
unsignedlen
unsignedflags
struct page **pagep
void **fsdata
get_block_t *get_block
2579  inode = host
2580  blkbits = i_blkbits
2581  blocksize = 1 << blkbits
2589  nr_reads = 0
2590  ret = 0
2591  is_mapped_to_disk = 1
2593  index = pos >> PAGE_SHIFT determines the page size
2594  from = pos & PAGE_SIZE - 1
2595  to = from + len
2597  page = Find or create a page at the given pagecache position. Return the locked* page. This function is specifically for buffered writes.
2598  If Not page Then Return -ENOMEM
2600  pagep = page
2601  * fsdata = NULL
2603  If page_has_buffers(page) Then
2604  ret = __block_write_begin(page, pos, len, get_block)
2605  If Value for the false possibility is greater at compile time(ret) Then Go to out_release
2607  Return ret
2610  If PageMappedToDisk(page) Then Return 0
2622  head = Create the appropriate buffers when given a page for data area and* the size of each buffer
2623  If Not head Then
2624  ret = -ENOMEM
2625  Go to out_release
2628  block_in_file = Our offset within mapping. << PAGE_SHIFT determines the page size - blkbits
2635  When block_start < PAGE_SIZE cycle
2640  block_end = block_start + blocksize
2641  buffer state bitmap (see above) = 0
2642  create = 1
2643  If block_start >= to Then create = 0
2645  ret = get_block(inode, block_in_file + block_in_page, bh, create)
2647  If ret Then Go to failed
2649  If Not buffer_mapped(bh) Then is_mapped_to_disk = 0
2651  If buffer_new(bh) Then clean_bdev_bh_alias(bh)
2653  If PageUptodate(page) Then
2655  Continue
2657  If buffer_new(bh) || Not buffer_mapped(bh) Then
2660  Continue
2662  If Emit the buffer bitops functions. Note that there are also functions* of the form "mark_buffer_foo()". These are higher-level functions which* do something in addition to setting a b_state bit. Then Continue
2664  If block_start < from || block_end > to Then
2665  lock_buffer(bh)
2667  submit_bh(REQ_OP_READ, 0, bh)
2668  nr_reads++
2672  If nr_reads Then
2678  When bh cycle
2679  wait_on_buffer(bh)
2683  If ret Then Go to failed
2687  If is_mapped_to_disk Then SetPageMappedToDisk(page)
2690  fsdata = head
2692  Return 0
2694  failed :
2695  BUG_ON(!ret)
2703  Attach the singly-linked list of buffers created by nobh_write_begin, to* the page (converting it to circular linked list and taking care of page* dirty races).
2704  If a page has any new buffers, zero them out here, and mark them uptodate* and dirty so they'll be written out (in order to prevent uninitialised* block data from leaking). And clear the new bit.
2706  out_release :
2707  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.
2708  Perform a free_page(), also freeing any swap cache associated with* this page if it is the last user of the page.
2709  * pagep = NULL
2711  Return ret