Lines Matching refs:page
15 * UBIFS uses 2 page flags: @PG_private and @PG_checked. @PG_private is set if
16 * the page is dirty and is used for optimization purposes - dirty pages are
18 * the budget for this page. The @PG_checked flag is set if full budgeting is
19 * required for the page e.g., when it corresponds to a file hole or it is
23 * information about how the page was budgeted, to make it possible to release
32 * 'ubifs_writepage()' we are only guaranteed that the page is locked.
99 static int do_readpage(struct page *page)
105 struct inode *inode = page->mapping->host;
110 inode->i_ino, page->index, i_size, page->flags);
111 ubifs_assert(c, !PageChecked(page));
112 ubifs_assert(c, !PagePrivate(page));
114 addr = kmap(page);
116 block = page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT;
120 SetPageChecked(page);
162 SetPageChecked(page);
166 ubifs_err(c, "cannot read page %lu of inode %lu, error %d",
167 page->index, inode->i_ino, err);
174 SetPageUptodate(page);
175 ClearPageError(page);
176 flush_dcache_page(page);
177 kunmap(page);
182 ClearPageUptodate(page);
183 SetPageError(page);
184 flush_dcache_page(page);
185 kunmap(page);
190 * release_new_page_budget - release budget of a new page.
194 * of one new page of data.
204 * release_existing_page_budget - release budget of an existing page.
208 * of changing one page of data which already exists on the flash media.
218 loff_t pos, unsigned len, struct page **pagep)
225 struct page *page;
231 * At the slow path we have to budget before locking the page, because
233 * deadlock if we had the page locked. At this point we do not know
234 * anything about the page, so assume that this is a new page which is
246 page = grab_cache_page_write_begin(mapping, index);
247 if (unlikely(!page)) {
252 if (!PageUptodate(page)) {
254 SetPageChecked(page);
256 err = do_readpage(page);
258 unlock_page(page);
259 put_page(page);
266 if (PagePrivate(page))
268 * The page is dirty, which means it was budgeted twice:
270 * made the page dirty and set the PG_private flag;
274 * So what we have to do is to release the page budget we
278 else if (!PageChecked(page))
280 * We are changing a page which already exists on the media.
281 * This means that changing the page does not make the amount
304 *pagep = page;
311 * @page: page to allocate budget for
312 * @ui: UBIFS inode object the page belongs to
313 * @appending: non-zero if the page is appended
317 * this is appending, whether the page is dirty or not, and so on. This
321 static int allocate_budget(struct ubifs_info *c, struct page *page,
326 if (PagePrivate(page)) {
329 * The page is dirty and we are not appending, which
337 * The page is dirty and we are appending, so the inode
348 * The page is dirty, we are appending, the inode is clean, so
353 if (PageChecked(page))
355 * The page corresponds to a hole and does not
359 * page.
365 * indexing information, budget for page
386 * This function is called when a page of data is going to be written. Since
387 * the page of data will not necessarily go to the flash straight away, UBIFS
395 * o a new page is appended - we have to budget for a new page and for
398 * o an existing clean page is changed - we have budget for it; if the page
400 * page; otherwise, we may budget for changing an existing page; the
401 * difference between these cases is that changing an existing page does
404 * o an existing dirty page is changed - no need to budget at all, because
405 * the page budget has been acquired by earlier, when the page has been
419 struct page **pagep, void **fsdata)
427 struct page *page;
436 page = grab_cache_page_write_begin(mapping, index);
437 if (unlikely(!page))
440 if (!PageUptodate(page)) {
441 /* The page is not loaded from the flash */
444 * We change whole page so no need to load it. But we
445 * do not know whether this page exists on the media or
448 * to budget a bit more than to read the page from the
452 SetPageChecked(page);
455 err = do_readpage(page);
457 unlock_page(page);
458 put_page(page);
464 err = allocate_budget(c, page, ui, appending);
468 * If we skipped reading the page because we were going to
472 ClearPageChecked(page);
477 * page locked, because it would deadlock. Unlock and free
484 unlock_page(page);
485 put_page(page);
496 *pagep = page;
504 * @page: page to cancel budget for
505 * @ui: UBIFS inode object the page belongs to
506 * @appending: non-zero if the page is appended
508 * This is a helper function for a page write operation. It unlocks the
511 static void cancel_budget(struct ubifs_info *c, struct page *page,
519 if (!PagePrivate(page)) {
520 if (PageChecked(page))
529 struct page *page, void *fsdata)
538 inode->i_ino, pos, page->index, len, copied, inode->i_size);
542 * VFS copied less data to the page that it intended and
544 * argument. If the page was not up-to-date, and @len was
547 * means that part of the page contains garbage. So read the
548 * page now.
550 dbg_gen("copied %d instead of %d, read page and repeat",
552 cancel_budget(c, page, ui, appending);
553 ClearPageChecked(page);
559 copied = do_readpage(page);
564 SetPageUptodate(page);
566 if (!PagePrivate(page)) {
567 attach_page_private(page, (void *)1);
569 __set_page_dirty_nobuffers(page);
586 unlock_page(page);
587 put_page(page);
592 * populate_page - copy data nodes into a page for bulk-read.
594 * @page: page
600 static int populate_page(struct ubifs_info *c, struct page *page,
604 struct inode *inode = page->mapping->host;
611 inode->i_ino, page->index, i_size, page->flags);
613 addr = zaddr = kmap(page);
616 if (!i_size || page->index > end_index) {
622 page_block = page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT;
673 if (end_index == page->index) {
682 SetPageChecked(page);
686 SetPageUptodate(page);
687 ClearPageError(page);
688 flush_dcache_page(page);
689 kunmap(page);
694 ClearPageUptodate(page);
695 SetPageError(page);
696 flush_dcache_page(page);
697 kunmap(page);
707 * @page1: first page to read
712 struct page *page1)
736 * This happens when there are multiple blocks per page and the
737 * blocks for the first page we are looking for, are not
779 struct page *page;
783 page = pagecache_get_page(mapping, page_offset,
786 if (!page)
788 if (!PageUptodate(page))
789 err = populate_page(c, page, bu, &n);
790 unlock_page(page);
791 put_page(page);
814 * @page: page from which to start bulk-read.
821 static int ubifs_bulk_read(struct page *page)
823 struct inode *inode = page->mapping->host;
826 pgoff_t index = page->index, last_page_read = ui->last_page_read;
874 page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT);
875 err = ubifs_do_bulk_read(c, bu, page);
889 struct page *page = &folio->page;
891 if (ubifs_bulk_read(page))
893 do_readpage(page);
898 static int do_writepage(struct page *page, int len)
904 struct inode *inode = page->mapping->host;
910 ubifs_assert(c, page->index <= ui->synced_i_size >> PAGE_SHIFT);
915 set_page_writeback(page);
917 addr = kmap(page);
918 block = page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT;
933 SetPageError(page);
934 ubifs_err(c, "cannot write page %lu of inode %lu, error %d",
935 page->index, inode->i_ino, err);
939 ubifs_assert(c, PagePrivate(page));
940 if (PageChecked(page))
946 detach_page_private(page);
947 ClearPageChecked(page);
949 kunmap(page);
950 unlock_page(page);
951 end_page_writeback(page);
975 * the page locked, and it locks @ui_mutex. However, write-back does take inode
980 * page lock. This means that 'do_truncation()' cannot call 'truncate_setsize()'
998 * on the page lock and it would not write the truncated inode node to the
1001 static int ubifs_writepage(struct page *page, struct writeback_control *wbc)
1003 struct inode *inode = page->mapping->host;
1012 inode->i_ino, page->index, page->flags);
1013 ubifs_assert(c, PagePrivate(page));
1015 /* Is the page fully outside @i_size? (truncate in progress) */
1016 if (page->index > end_index || (page->index == end_index && !len)) {
1025 /* Is the page fully inside @i_size? */
1026 if (page->index < end_index) {
1027 if (page->index >= synced_i_size >> PAGE_SHIFT) {
1040 return do_writepage(page, PAGE_SIZE);
1044 * The page straddles @i_size. It must be zeroed out on each and every
1046 * in multiples of the page size. For a file that is not a multiple of
1047 * the page size, the remaining memory is zeroed when mapped, and
1050 kaddr = kmap_atomic(page);
1052 flush_dcache_page(page);
1061 return do_writepage(page, len);
1068 redirty_page_for_writepage(wbc, page);
1070 unlock_page(page);
1148 struct page *page;
1150 page = find_lock_page(inode->i_mapping, index);
1151 if (page) {
1152 if (PageDirty(page)) {
1156 * out-of-date data because the page is dirty.
1157 * Write the page now, so that
1161 ubifs_assert(c, PagePrivate(page));
1163 clear_page_dirty_for_io(page);
1167 err = do_writepage(page, offset);
1168 put_page(page);
1177 * We could 'kmap()' the page and pass the data
1181 unlock_page(page);
1182 put_page(page);
1455 * An attempt to dirty a page without budgeting for it - should not
1472 * making it happened. ubifs_writepage skipped the page because
1473 * page index beyonds isize (for example. truncated by other
1474 * process named A), then the page is invalidated by fadvise64
1491 * UBIFS must ensure page is budgeted for.
1495 struct page *page = vmf->page;
1502 dbg_gen("ino %lu, pg %lu, i_size %lld", inode->i_ino, page->index,
1510 * We have not locked @page so far so we may budget for changing the
1511 * page. Note, we cannot do this after we locked the page, because
1514 * At the moment we do not know whether the page is dirty or not, so we
1515 * assume that it is not and budget for a new page. We could look at
1517 * back and the page state may change by the time we lock it, so this
1520 * budget for a new page and amend it later on if the page was in fact
1543 lock_page(page);
1544 if (unlikely(page->mapping != inode->i_mapping ||
1545 page_offset(page) > i_size_read(inode))) {
1550 if (PagePrivate(page))
1553 if (!PageChecked(page))
1555 attach_page_private(page, (void *)1);
1557 __set_page_dirty_nobuffers(page);
1573 wait_for_stable_page(page);
1577 unlock_page(page);