• Home
  • Raw
  • Download

Lines Matching +full:page +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0
14 * Seek for SEEK_DATA / SEEK_HOLE within @page, starting at @lastoff.
15 * Returns true if found and updates @lastoff to the offset in file.
18 page_seek_hole_data(struct inode *inode, struct page *page, loff_t *lastoff, in page_seek_hole_data() argument
21 const struct address_space_operations *ops = inode->i_mapping->a_ops; in page_seek_hole_data()
24 loff_t poff = page_offset(page); in page_seek_hole_data()
31 * Last offset smaller than the start of the page means we found in page_seek_hole_data()
40 * Just check the page unless we can and should check block ranges: in page_seek_hole_data()
42 if (bsize == PAGE_SIZE || !ops->is_partially_uptodate) in page_seek_hole_data()
43 return PageUptodate(page) == seek_data; in page_seek_hole_data()
45 lock_page(page); in page_seek_hole_data()
46 if (unlikely(page->mapping != inode->i_mapping)) in page_seek_hole_data()
52 if (ops->is_partially_uptodate(page, off, bsize) == seek_data) { in page_seek_hole_data()
53 unlock_page(page); in page_seek_hole_data()
60 unlock_page(page); in page_seek_hole_data()
65 * Seek for SEEK_DATA / SEEK_HOLE in the page cache.
67 * Within unwritten extents, the page cache determines which parts are holes
71 * Returns the resulting offset on successs, and -ENOENT otherwise.
74 page_cache_seek_hole_data(struct inode *inode, loff_t offset, loff_t length, in page_cache_seek_hole_data() argument
77 pgoff_t index = offset >> PAGE_SHIFT; in page_cache_seek_hole_data()
78 pgoff_t end = DIV_ROUND_UP(offset + length, PAGE_SIZE); in page_cache_seek_hole_data()
79 loff_t lastoff = offset; in page_cache_seek_hole_data()
83 return -ENOENT; in page_cache_seek_hole_data()
90 nr_pages = pagevec_lookup_range(&pvec, inode->i_mapping, &index, in page_cache_seek_hole_data()
91 end - 1); in page_cache_seek_hole_data()
96 struct page *page = pvec.pages[i]; in page_cache_seek_hole_data() local
98 if (page_seek_hole_data(inode, page, &lastoff, whence)) in page_cache_seek_hole_data()
100 lastoff = page_offset(page) + PAGE_SIZE; in page_cache_seek_hole_data()
105 /* When no page at lastoff and we are not done, we found a hole. */ in page_cache_seek_hole_data()
110 if (lastoff < offset + length) in page_cache_seek_hole_data()
113 lastoff = -ENOENT; in page_cache_seek_hole_data()
121 iomap_seek_hole_actor(struct inode *inode, loff_t offset, loff_t length, in iomap_seek_hole_actor() argument
124 switch (iomap->type) { in iomap_seek_hole_actor()
126 offset = page_cache_seek_hole_data(inode, offset, length, in iomap_seek_hole_actor()
128 if (offset < 0) in iomap_seek_hole_actor()
132 *(loff_t *)data = offset; in iomap_seek_hole_actor()
140 iomap_seek_hole(struct inode *inode, loff_t offset, const struct iomap_ops *ops) in iomap_seek_hole() argument
146 if (offset < 0 || offset >= size) in iomap_seek_hole()
147 return -ENXIO; in iomap_seek_hole()
149 while (offset < size) { in iomap_seek_hole()
150 ret = iomap_apply(inode, offset, size - offset, IOMAP_REPORT, in iomap_seek_hole()
151 ops, &offset, iomap_seek_hole_actor); in iomap_seek_hole()
156 offset += ret; in iomap_seek_hole()
159 return offset; in iomap_seek_hole()
164 iomap_seek_data_actor(struct inode *inode, loff_t offset, loff_t length, in iomap_seek_data_actor() argument
167 switch (iomap->type) { in iomap_seek_data_actor()
171 offset = page_cache_seek_hole_data(inode, offset, length, in iomap_seek_data_actor()
173 if (offset < 0) in iomap_seek_data_actor()
177 *(loff_t *)data = offset; in iomap_seek_data_actor()
183 iomap_seek_data(struct inode *inode, loff_t offset, const struct iomap_ops *ops) in iomap_seek_data() argument
189 if (offset < 0 || offset >= size) in iomap_seek_data()
190 return -ENXIO; in iomap_seek_data()
192 while (offset < size) { in iomap_seek_data()
193 ret = iomap_apply(inode, offset, size - offset, IOMAP_REPORT, in iomap_seek_data()
194 ops, &offset, iomap_seek_data_actor); in iomap_seek_data()
198 return offset; in iomap_seek_data()
199 offset += ret; in iomap_seek_data()
203 return -ENXIO; in iomap_seek_data()