Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Compare extents of two files to see if they are the same.* Caller must have locked both inodes to prevent write races.

Proto:static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, struct inode *dest, loff_t destoff, loff_t len, bool *is_same)

Type:int

Parameter:

TypeParameterName
struct inode *src
loff_tsrcoff
struct inode *dest
loff_tdestoff
loff_tlen
bool *is_same
1868  error = -EINVAL
1869  same = true
1870  When len cycle
1871  src_poff = srcoff & PAGE_SIZE - 1
1872  dest_poff = destoff & PAGE_SIZE - 1
1873  cmp_len = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value(PAGE_SIZE - src_poff, PAGE_SIZE - dest_poff)
1875  cmp_len = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value(cmp_len, len)
1876  If cmp_len <= 0 Then Go to out_error
1879  src_page = Read a page's worth of file data into the page cache.
1880  If IS_ERR(src_page) Then
1881  error = PTR_ERR(src_page)
1882  Go to out_error
1884  dest_page = Read a page's worth of file data into the page cache.
1885  If IS_ERR(dest_page) Then
1886  error = PTR_ERR(dest_page)
1888  Go to out_error
1891  Lock two pages, ensuring that we lock in offset order if the pages are from* the same file.
1901  same = false
1902  Go to unlock
1905  src_addr = kmap_atomic(src_page)
1906  dest_addr = kmap_atomic(dest_page)
1908  flush_dcache_page(src_page)
1909  flush_dcache_page(dest_page)
1911  If memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len) Then same = false
1914  Prevent people trying to call kunmap_atomic() as if it were kunmap()* kunmap_atomic() should get the return value of kmap_atomic, not the page.(dest_addr)
1915  Prevent people trying to call kunmap_atomic() as if it were kunmap()* kunmap_atomic() should get the return value of kmap_atomic, not the page.(src_addr)
1916  unlock :
1917  Unlock two pages, being careful not to unlock the same page twice.
1918  Perform a free_page(), also freeing any swap cache associated with* this page if it is the last user of the page.
1919  Perform a free_page(), also freeing any swap cache associated with* this page if it is the last user of the page.
1921  If Not same Then Break
1924  srcoff += cmp_len
1925  destoff += cmp_len
1926  len -= cmp_len
1929  is_same = same
1930  Return 0
1932  out_error :
1933  Return error
Caller
NameDescribe
generic_remap_file_range_prepCheck that the two inodes are eligible for cloning, the ranges make* sense, and then flush all dirty data. Caller must ensure that the* inodes have been locked against any other modifications.