Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\fadvise.c Create Date:2022-07-28 14:07:01
Last Modify:2020-03-17 21:10:40 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could* deactivate the pages and clear PG_Referenced.

Proto:int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice)

Type:int

Parameter:

TypeParameterName
struct file *file
loff_toffset
loff_tlen
intadvice
40  inode = file_inode(file)
41  If S_ISFIFO(i_mode) Then Return -ESPIPE
44  mapping = f_mapping
45  If Not mapping || len < 0 Then Return -EINVAL
48  bdi = inode_to_bdi(host)
50  If IS_DAX(inode) || bdi == noop_backing_dev_info Then
52  Case advice == No further special treatment.
53  Case advice == Expect random page references.
54  Case advice == Expect sequential page references.
55  Case advice == Will need these pages.
56  Case advice == Data will be accessed once.
59  Break
60  Default
61  Return -EINVAL
63  Return 0
71  endbyte = offset + len
72  If Not len || endbyte < len Then endbyte = -1
74  Else endbyte--
78  Case advice == No further special treatment.
79  Maximum readahead window = max readahead in PAGE_SIZE units
80  spin_lock( & * Protects f_ep_links, f_flags. * Must not be taken from IRQ context.)
81  f_mode &= ~Expect random access pattern
82  spin_unlock( & * Protects f_ep_links, f_flags. * Must not be taken from IRQ context.)
83  Break
84  Case advice == Expect random page references.
85  spin_lock( & * Protects f_ep_links, f_flags. * Must not be taken from IRQ context.)
86  f_mode |= Expect random access pattern
87  spin_unlock( & * Protects f_ep_links, f_flags. * Must not be taken from IRQ context.)
88  Break
89  Case advice == Expect sequential page references.
90  Maximum readahead window = max readahead in PAGE_SIZE units * 2
91  spin_lock( & * Protects f_ep_links, f_flags. * Must not be taken from IRQ context.)
92  f_mode &= ~Expect random access pattern
93  spin_unlock( & * Protects f_ep_links, f_flags. * Must not be taken from IRQ context.)
94  Break
95  Case advice == Will need these pages.
97  start_index = offset >> PAGE_SHIFT determines the page size
98  end_index = endbyte >> PAGE_SHIFT determines the page size
101  nrpages = end_index - start_index + 1
102  If Not nrpages Then nrpages = ~0UL
109  force_page_cache_readahead(mapping, file, start_index, nrpages)
110  Break
111  Case advice == Data will be accessed once.
112  Break
113  Case advice == Don't need these pages.
114  If Not inode_write_congested(host) Then __filemap_fdatawrite_range - start writeback on mapping dirty pages in range*@mapping: address space structure to write*@start: offset in bytes where the range starts*@end: offset in bytes where the range ends (inclusive)*@sync_mode: enable synchronous
123  start_index = offset + PAGE_SIZE - 1 >> PAGE_SHIFT determines the page size
124  end_index = endbyte >> PAGE_SHIFT determines the page size
132  If (endbyte & ~PAGE_MASK) != ~PAGE_MASK && endbyte != i_size - 1 Then
139  If end_index == 0 Then Break
142  end_index--
145  If end_index >= start_index Then
157  lru_add_drain()
168  If count < end_index - start_index + 1 Then
174  Break
175  Default
176  Return -EINVAL
178  Return 0
Caller
NameDescribe
vfs_fadvise