Lines Matching refs:page
3 * aops.c - NTFS kernel address space operations and page cache handling.
39 * page has been completed and mark the page uptodate or set the error bit on
40 * the page. To determine the size of the records that need fixing up, we
49 struct page *page;
54 page = bh->b_page;
55 vi = page->mapping->host;
64 file_ofs = ((s64)page->index << PAGE_SHIFT) +
82 kaddr = kmap_atomic(page);
85 flush_dcache_page(page);
90 SetPageError(page);
94 first = page_buffers(page);
112 * If none of the buffers had errors then we can set the page uptodate,
117 * rather than per page granularity.
120 if (likely(page_uptodate && !PageError(page)))
121 SetPageUptodate(page);
131 kaddr = kmap_atomic(page);
136 flush_dcache_page(page);
137 if (likely(page_uptodate && !PageError(page)))
138 SetPageUptodate(page);
140 unlock_page(page);
148 * ntfs_read_block - fill a @page of an address space with data
149 * @page: page cache page to fill with data
151 * Fill the page @page of the address space belonging to the @page->host inode.
154 * applies the mst fixups to the page before finally marking it uptodate and
164 static int ntfs_read_block(struct page *page)
181 vi = page->mapping->host;
191 if (!page_has_buffers(page)) {
192 create_empty_buffers(page, blocksize, 0);
193 if (unlikely(!page_has_buffers(page))) {
194 unlock_page(page);
198 bh = head = page_buffers(page);
208 * on due to the runlist being incomplete and if the page is being
212 iblock = (s64)page->index << (PAGE_SHIFT - blocksize_bits);
224 /* Loop through all the buffers in the page. */
302 SetPageError(page);
315 * of the page and set the buffer uptodate.
321 zero_user(page, i * blocksize, blocksize);
352 if (likely(!PageError(page)))
353 SetPageUptodate(page);
356 unlock_page(page);
363 * @folio: page cache folio to fill with data
380 struct page *page = &folio->page;
392 BUG_ON(!PageLocked(page));
393 vi = page->mapping->host;
395 /* Is the page fully outside i_size? (truncate in progress) */
396 if (unlikely(page->index >= (i_size + PAGE_SIZE - 1) >>
398 zero_user(page, 0, PAGE_SIZE);
406 if (PageUptodate(page)) {
407 unlock_page(page);
430 return ntfs_read_compressed_block(page);
436 return ntfs_read_block(page);
441 * hence smaller than a page, so can simply zero out any pages with
446 if (unlikely(page->index > 0)) {
447 zero_user(page, 0, PAGE_SIZE);
487 addr = kmap_atomic(page);
488 /* Copy the data to the page. */
492 /* Zero the remainder of the page. */
494 flush_dcache_page(page);
501 SetPageUptodate(page);
503 unlock_page(page);
510 * ntfs_write_block - write a @page to the backing store
511 * @page: page cache page to write out
517 * For a page with buffers, map and write the dirty buffers asynchronously
518 * under page writeback. For a page without buffers, create buffers for the
519 * page, then proceed as above.
521 * If a page doesn't have buffers the page dirty state is definitive. If a page
522 * does have buffers, the page dirty state is just a hint, and the buffer dirty
524 * page is illegal. Other combinations are legal and need to be handled. In
525 * particular a dirty page containing clean buffers for example.)
531 static int ntfs_write_block(struct page *page, struct writeback_control *wbc)
549 vi = page->mapping->host;
553 ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index "
554 "0x%lx.", ni->mft_no, ni->type, page->index);
560 if (!page_has_buffers(page)) {
561 BUG_ON(!PageUptodate(page));
562 create_empty_buffers(page, blocksize,
564 if (unlikely(!page_has_buffers(page))) {
565 ntfs_warning(vol->sb, "Error allocating page "
566 "buffers. Redirtying page so we try "
569 * Put the page back on mapping->dirty_pages, but leave
572 redirty_page_for_writepage(wbc, page);
573 unlock_page(page);
577 bh = head = page_buffers(page);
582 /* The first block in the page. */
583 block = (s64)page->index << (PAGE_SHIFT - blocksize_bits);
600 * then we just miss that fact, and the page stays dirty.
607 * Loop through all the buffers in the page, mapping all the dirty
619 * this page can be outside i_size when there is a
625 * the page was within i_size but before we get here,
641 * If this page is fully outside initialized
643 * initialized size and the current page. Just
649 // For each page do:
651 // Again for each page do:
653 // - Check (PageUptodate(page) &&
654 // !PageError(page))
657 // Again, for each page do:
664 * The current page straddles initialized size. Zero
667 * if the page is uptodate.
668 * FIXME: For an uptodate page, the buffers may need to
672 if (!PageUptodate(page)) {
730 kaddr = kmap_atomic(page);
777 zero_user(page, bh_offset(bh), blocksize);
804 if (unlikely(!PageUptodate(page))) {
814 SetPageUptodate(page);
829 * dirty during attachment to a dirty page.
842 "Redirtying page so we try again "
845 * Put the page back on mapping->dirty_pages, but
848 redirty_page_for_writepage(wbc, page);
851 SetPageError(page);
854 BUG_ON(PageWriteback(page));
855 set_page_writeback(page); /* Keeps try_to_free_buffers() away. */
867 unlock_page(page);
871 end_page_writeback(page);
878 * ntfs_write_mst_block - write a @page to the backing store
879 * @page: page cache page to write out
887 * The page must remain locked for the duration of the write because we apply
889 * page before undoing the fixups, any other user of the page will see the
890 * page contents as corrupt.
892 * We clear the page uptodate flag for the duration of the function to ensure
901 static int ntfs_write_mst_block(struct page *page,
905 struct inode *vi = page->mapping->host;
922 ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index "
923 "0x%lx.", vi->i_ino, ni->type, page->index);
928 * NOTE: ntfs_write_mst_block() would be called for $MFTMirr if a page
929 * in its page cache were to be marked dirty. However this should
945 bh = head = page_buffers(page);
953 /* The first block in the page. */
954 rec_block = block = (sector_t)page->index <<
1103 /* Map the page so we can access its contents. */
1104 kaddr = kmap(page);
1105 /* Clear the page uptodate flag whilst the mst fixups are applied. */
1106 BUG_ON(!PageUptodate(page));
1107 ClearPageUptodate(page);
1121 mft_no = (((s64)page->index << PAGE_SHIFT) + ofs)
1129 * means we need to redirty the page before
1158 "page index 0x%lx, page offset 0x%x)!"
1160 ni->type, page->index, ofs);
1176 flush_dcache_page(page);
1205 "attribute type 0x%x, page index "
1206 "0x%lx, page offset 0x%lx)! Unmount "
1208 page->index, bh_offset(tbh));
1212 * Set the buffer uptodate so the page and buffer
1237 mft_no = (((s64)page->index << PAGE_SHIFT) + ofs)
1257 flush_dcache_page(page);
1280 SetPageUptodate(page);
1281 kunmap(page);
1285 * Set page error if there is only one ntfs record in the page.
1289 SetPageError(page);
1294 "records. Redirtying the page starting at "
1295 "record 0x%lx.", page->index <<
1297 redirty_page_for_writepage(wbc, page);
1298 unlock_page(page);
1303 * the page is clean.
1305 BUG_ON(PageWriteback(page));
1306 set_page_writeback(page);
1307 unlock_page(page);
1308 end_page_writeback(page);
1316 * ntfs_writepage - write a @page to the backing store
1317 * @page: page cache page to write out
1320 * This is called from the VM when it wants to have a dirty ntfs page cache
1321 * page cleaned. The VM has already locked the page and marked it clean.
1323 * For non-resident attributes, ntfs_writepage() writes the @page by calling
1326 * buffers associated with the page asynchronously.
1328 * For resident attributes, OTOH, ntfs_writepage() writes the @page by copying
1332 * vm page dirty code path for the page the mft record is in.
1338 static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
1341 struct inode *vi = page->mapping->host;
1350 BUG_ON(!PageLocked(page));
1352 /* Is the page fully outside i_size? (truncate in progress) */
1353 if (unlikely(page->index >= (i_size + PAGE_SIZE - 1) >>
1355 struct folio *folio = page_folio(page);
1357 * The page may have dirty, unmapped buffers. Make them
1358 * freeable here, so the page does not leak.
1376 unlock_page(page);
1386 // return ntfs_write_compressed_block(page);
1387 unlock_page(page);
1394 unlock_page(page);
1403 if (page->index >= (i_size >> PAGE_SHIFT)) {
1404 /* The page straddles i_size. */
1406 zero_user_segment(page, ofs, PAGE_SIZE);
1410 return ntfs_write_mst_block(page, wbc);
1412 return ntfs_write_block(page, wbc);
1417 * record and hence smaller than a page, so can simply return error on
1422 BUG_ON(page_has_buffers(page));
1423 BUG_ON(!PageUptodate(page));
1424 if (unlikely(page->index > 0)) {
1425 ntfs_error(vi->i_sb, "BUG()! page->index (0x%lx) > 0. "
1426 "Aborting write.", page->index);
1427 BUG_ON(PageWriteback(page));
1428 set_page_writeback(page);
1429 unlock_page(page);
1430 end_page_writeback(page);
1464 * PAGECACHE_TAG_DIRTY remains set even though the page is clean.
1466 BUG_ON(PageWriteback(page));
1467 set_page_writeback(page);
1468 unlock_page(page);
1483 addr = kmap_atomic(page);
1484 /* Copy the data from the page to the mft record. */
1488 /* Zero out of bounds area in the page cache page. */
1491 flush_dcache_page(page);
1493 /* We are done with the page. */
1494 end_page_writeback(page);
1503 "page so we try again later.");
1505 * Put the page back on mapping->dirty_pages, but leave its
1508 redirty_page_for_writepage(wbc, page);
1513 SetPageError(page);
1516 unlock_page(page);
1686 .read_folio = ntfs_read_folio, /* Fill page with data. */
1688 .writepage = ntfs_writepage, /* Write dirty page to disk. */
1700 * @page: page containing the ntfs record to mark dirty
1701 * @ofs: byte offset within @page at which the ntfs record begins
1703 * Set the buffers and the page in which the ntfs record is located dirty.
1708 * If the page does not have buffers, we create them and set them uptodate.
1709 * The page may not be locked which is why we need to handle the buffers under
1713 void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs) {
1714 struct address_space *mapping = page->mapping;
1719 BUG_ON(!PageUptodate(page));
1723 if (unlikely(!page_has_buffers(page))) {
1725 bh = head = alloc_page_buffers(page, bh_size, true);
1727 if (likely(!page_has_buffers(page))) {
1736 attach_page_private(page, head);
1740 bh = head = page_buffers(page);
1751 filemap_dirty_folio(mapping, page_folio(page));