Lines Matching full:page

3  * page.c - buffer/page management specific to NILFS
14 #include <linux/page-flags.h>
20 #include "page.h"
29 __nilfs_get_page_block(struct page *page, unsigned long block, pgoff_t index, in __nilfs_get_page_block() argument
36 if (!page_has_buffers(page)) in __nilfs_get_page_block()
37 create_empty_buffers(page, 1 << blkbits, b_state); in __nilfs_get_page_block()
40 bh = nilfs_page_get_nth_block(page, block - first_block); in __nilfs_get_page_block()
54 struct page *page; in nilfs_grab_buffer() local
57 page = grab_cache_page(mapping, index); in nilfs_grab_buffer()
58 if (unlikely(!page)) in nilfs_grab_buffer()
61 bh = __nilfs_get_page_block(page, blkoff, index, blkbits, b_state); in nilfs_grab_buffer()
63 unlock_page(page); in nilfs_grab_buffer()
64 put_page(page); in nilfs_grab_buffer()
76 struct page *page = bh->b_page; in nilfs_forget_buffer() local
84 if (nilfs_page_buffers_clean(page)) in nilfs_forget_buffer()
85 __nilfs_clear_page_dirty(page); in nilfs_forget_buffer()
88 ClearPageUptodate(page); in nilfs_forget_buffer()
89 ClearPageMappedToDisk(page); in nilfs_forget_buffer()
103 struct page *spage = sbh->b_page, *dpage = dbh->b_page; in nilfs_copy_buffer()
134 * nilfs_page_buffers_clean - check if a page has dirty buffers or not.
135 * @page: page to be checked
137 * nilfs_page_buffers_clean() returns zero if the page has dirty buffers.
140 int nilfs_page_buffers_clean(struct page *page) in nilfs_page_buffers_clean() argument
144 bh = head = page_buffers(page); in nilfs_page_buffers_clean()
153 void nilfs_page_bug(struct page *page) in nilfs_page_bug() argument
158 if (unlikely(!page)) { in nilfs_page_bug()
163 m = page->mapping; in nilfs_page_bug()
168 page, page_ref_count(page), in nilfs_page_bug()
169 (unsigned long long)page->index, page->flags, m, ino); in nilfs_page_bug()
171 if (page_has_buffers(page)) { in nilfs_page_bug()
175 bh = head = page_buffers(page); in nilfs_page_bug()
187 * nilfs_copy_page -- copy the page with buffers
188 * @dst: destination page
189 * @src: source page
190 * @copy_dirty: flag whether to copy dirty states on the page's buffer heads.
193 * should be treated by caller. The page must not be under i/o.
194 * Both src and dst page must be locked
196 static void nilfs_copy_page(struct page *dst, struct page *src, int copy_dirty) in nilfs_copy_page()
254 struct page *page = pvec.pages[i], *dpage; in nilfs_copy_dirty_pages() local
256 lock_page(page); in nilfs_copy_dirty_pages()
257 if (unlikely(!PageDirty(page))) in nilfs_copy_dirty_pages()
258 NILFS_PAGE_BUG(page, "inconsistent dirty state"); in nilfs_copy_dirty_pages()
260 dpage = grab_cache_page(dmap, page->index); in nilfs_copy_dirty_pages()
262 /* No empty page is added to the page cache */ in nilfs_copy_dirty_pages()
264 unlock_page(page); in nilfs_copy_dirty_pages()
267 if (unlikely(!page_has_buffers(page))) in nilfs_copy_dirty_pages()
268 NILFS_PAGE_BUG(page, in nilfs_copy_dirty_pages()
269 "found empty page in dat page cache"); in nilfs_copy_dirty_pages()
271 nilfs_copy_page(dpage, page, 1); in nilfs_copy_dirty_pages()
276 unlock_page(page); in nilfs_copy_dirty_pages()
288 * @dmap: destination page cache
289 * @smap: source page cache
308 struct page *page = pvec.pages[i], *dpage; in nilfs_copy_back_pages() local
309 pgoff_t offset = page->index; in nilfs_copy_back_pages()
311 lock_page(page); in nilfs_copy_back_pages()
314 /* overwrite existing page in the destination cache */ in nilfs_copy_back_pages()
316 nilfs_copy_page(dpage, page, 0); in nilfs_copy_back_pages()
319 /* Do we not need to remove page from smap here? */ in nilfs_copy_back_pages()
321 struct page *p; in nilfs_copy_back_pages()
323 /* move the page to the destination cache */ in nilfs_copy_back_pages()
326 WARN_ON(page != p); in nilfs_copy_back_pages()
331 p = __xa_store(&dmap->i_pages, offset, page, GFP_NOFS); in nilfs_copy_back_pages()
334 page->mapping = NULL; in nilfs_copy_back_pages()
335 put_page(page); in nilfs_copy_back_pages()
337 page->mapping = dmap; in nilfs_copy_back_pages()
339 if (PageDirty(page)) in nilfs_copy_back_pages()
345 unlock_page(page); in nilfs_copy_back_pages()
369 struct page *page = pvec.pages[i]; in nilfs_clear_dirty_pages() local
371 lock_page(page); in nilfs_clear_dirty_pages()
372 nilfs_clear_dirty_page(page, silent); in nilfs_clear_dirty_pages()
373 unlock_page(page); in nilfs_clear_dirty_pages()
381 * nilfs_clear_dirty_page - discard dirty page
382 * @page: dirty page that will be discarded
385 void nilfs_clear_dirty_page(struct page *page, bool silent) in nilfs_clear_dirty_page() argument
387 struct inode *inode = page->mapping->host; in nilfs_clear_dirty_page()
390 BUG_ON(!PageLocked(page)); in nilfs_clear_dirty_page()
393 nilfs_warn(sb, "discard dirty page: offset=%lld, ino=%lu", in nilfs_clear_dirty_page()
394 page_offset(page), inode->i_ino); in nilfs_clear_dirty_page()
396 ClearPageUptodate(page); in nilfs_clear_dirty_page()
397 ClearPageMappedToDisk(page); in nilfs_clear_dirty_page()
399 if (page_has_buffers(page)) { in nilfs_clear_dirty_page()
406 bh = head = page_buffers(page); in nilfs_clear_dirty_page()
419 __nilfs_clear_page_dirty(page); in nilfs_clear_dirty_page()
422 unsigned int nilfs_page_count_clean_buffers(struct page *page, in nilfs_page_count_clean_buffers() argument
429 for (bh = head = page_buffers(page), block_start = 0; in nilfs_page_count_clean_buffers()
452 * page dirty flags when it copies back pages from the shadow cache
459 int __nilfs_clear_page_dirty(struct page *page) in __nilfs_clear_page_dirty() argument
461 struct address_space *mapping = page->mapping; in __nilfs_clear_page_dirty()
465 if (test_bit(PG_dirty, &page->flags)) { in __nilfs_clear_page_dirty()
466 __xa_clear_mark(&mapping->i_pages, page_index(page), in __nilfs_clear_page_dirty()
469 return clear_page_dirty_for_io(page); in __nilfs_clear_page_dirty()
474 return TestClearPageDirty(page); in __nilfs_clear_page_dirty()
499 struct page *page; in nilfs_find_uncommitted_extent() local
521 page = pvec.pages[i]; in nilfs_find_uncommitted_extent()
523 lock_page(page); in nilfs_find_uncommitted_extent()
524 if (page_has_buffers(page)) { in nilfs_find_uncommitted_extent()
527 bh = head = page_buffers(page); in nilfs_find_uncommitted_extent()
545 unlock_page(page); in nilfs_find_uncommitted_extent()
549 index = page->index + 1; in nilfs_find_uncommitted_extent()
555 unlock_page(page); in nilfs_find_uncommitted_extent()