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);
361 * ntfs_readpage - fill a @page of a @file with data from the device
362 * @file: open file to which the page @page belongs or NULL
363 * @page: page cache page to fill with data
365 * For non-resident attributes, ntfs_readpage() fills the @page of the open
368 * associated with the page asynchronously.
370 * For resident attributes, OTOH, ntfs_readpage() fills @page by copying the
378 static int ntfs_readpage(struct file *file, struct page *page)
391 BUG_ON(!PageLocked(page));
392 vi = page->mapping->host;
394 /* Is the page fully outside i_size? (truncate in progress) */
395 if (unlikely(page->index >= (i_size + PAGE_SIZE - 1) >>
397 zero_user(page, 0, PAGE_SIZE);
405 if (PageUptodate(page)) {
406 unlock_page(page);
429 return ntfs_read_compressed_block(page);
435 return ntfs_read_block(page);
440 * hence smaller than a page, so can simply zero out any pages with
445 if (unlikely(page->index > 0)) {
446 zero_user(page, 0, PAGE_SIZE);
486 addr = kmap_atomic(page);
487 /* Copy the data to the page. */
491 /* Zero the remainder of the page. */
493 flush_dcache_page(page);
500 SetPageUptodate(page);
502 unlock_page(page);
509 * ntfs_write_block - write a @page to the backing store
510 * @page: page cache page to write out
516 * For a page with buffers, map and write the dirty buffers asynchronously
517 * under page writeback. For a page without buffers, create buffers for the
518 * page, then proceed as above.
520 * If a page doesn't have buffers the page dirty state is definitive. If a page
521 * does have buffers, the page dirty state is just a hint, and the buffer dirty
523 * page is illegal. Other combinations are legal and need to be handled. In
524 * particular a dirty page containing clean buffers for example.)
530 static int ntfs_write_block(struct page *page, struct writeback_control *wbc)
548 vi = page->mapping->host;
552 ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index "
553 "0x%lx.", ni->mft_no, ni->type, page->index);
559 if (!page_has_buffers(page)) {
560 BUG_ON(!PageUptodate(page));
561 create_empty_buffers(page, blocksize,
563 if (unlikely(!page_has_buffers(page))) {
564 ntfs_warning(vol->sb, "Error allocating page "
565 "buffers. Redirtying page so we try "
568 * Put the page back on mapping->dirty_pages, but leave
571 redirty_page_for_writepage(wbc, page);
572 unlock_page(page);
576 bh = head = page_buffers(page);
581 /* The first block in the page. */
582 block = (s64)page->index << (PAGE_SHIFT - blocksize_bits);
599 * then we just miss that fact, and the page stays dirty.
606 * Loop through all the buffers in the page, mapping all the dirty
618 * this page can be outside i_size when there is a
624 * the page was within i_size but before we get here,
640 * If this page is fully outside initialized size, zero
642 * and the current page. Just use ntfs_readpage() to do
647 // For each page do:
649 // Again for each page do:
651 // - Check (PageUptodate(page) &&
652 // !PageError(page))
655 // Again, for each page do:
662 * The current page straddles initialized size. Zero
665 * if the page is uptodate.
666 * FIXME: For an uptodate page, the buffers may need to
670 if (!PageUptodate(page)) {
728 kaddr = kmap_atomic(page);
775 zero_user(page, bh_offset(bh), blocksize);
802 if (unlikely(!PageUptodate(page))) {
812 SetPageUptodate(page);
827 * dirty during attachment to a dirty page.
840 "Redirtying page so we try again "
843 * Put the page back on mapping->dirty_pages, but
846 redirty_page_for_writepage(wbc, page);
849 SetPageError(page);
852 BUG_ON(PageWriteback(page));
853 set_page_writeback(page); /* Keeps try_to_free_buffers() away. */
865 unlock_page(page);
869 end_page_writeback(page);
876 * ntfs_write_mst_block - write a @page to the backing store
877 * @page: page cache page to write out
885 * The page must remain locked for the duration of the write because we apply
887 * page before undoing the fixups, any other user of the page will see the
888 * page contents as corrupt.
890 * We clear the page uptodate flag for the duration of the function to ensure
899 static int ntfs_write_mst_block(struct page *page,
903 struct inode *vi = page->mapping->host;
920 ntfs_debug("Entering for inode 0x%lx, attribute type 0x%x, page index "
921 "0x%lx.", vi->i_ino, ni->type, page->index);
926 * NOTE: ntfs_write_mst_block() would be called for $MFTMirr if a page
927 * in its page cache were to be marked dirty. However this should
943 bh = head = page_buffers(page);
951 /* The first block in the page. */
952 rec_block = block = (sector_t)page->index <<
1101 /* Map the page so we can access its contents. */
1102 kaddr = kmap(page);
1103 /* Clear the page uptodate flag whilst the mst fixups are applied. */
1104 BUG_ON(!PageUptodate(page));
1105 ClearPageUptodate(page);
1119 mft_no = (((s64)page->index << PAGE_SHIFT) + ofs)
1127 * means we need to redirty the page before
1156 "page index 0x%lx, page offset 0x%x)!"
1158 ni->type, page->index, ofs);
1174 flush_dcache_page(page);
1203 "attribute type 0x%x, page index "
1204 "0x%lx, page offset 0x%lx)! Unmount "
1206 page->index, bh_offset(tbh));
1210 * Set the buffer uptodate so the page and buffer
1235 mft_no = (((s64)page->index << PAGE_SHIFT) + ofs)
1255 flush_dcache_page(page);
1278 SetPageUptodate(page);
1279 kunmap(page);
1283 * Set page error if there is only one ntfs record in the page.
1287 SetPageError(page);
1292 "records. Redirtying the page starting at "
1293 "record 0x%lx.", page->index <<
1295 redirty_page_for_writepage(wbc, page);
1296 unlock_page(page);
1301 * the page is clean.
1303 BUG_ON(PageWriteback(page));
1304 set_page_writeback(page);
1305 unlock_page(page);
1306 end_page_writeback(page);
1314 * ntfs_writepage - write a @page to the backing store
1315 * @page: page cache page to write out
1318 * This is called from the VM when it wants to have a dirty ntfs page cache
1319 * page cleaned. The VM has already locked the page and marked it clean.
1321 * For non-resident attributes, ntfs_writepage() writes the @page by calling
1324 * buffers associated with the page asynchronously.
1326 * For resident attributes, OTOH, ntfs_writepage() writes the @page by copying
1330 * vm page dirty code path for the page the mft record is in.
1336 static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
1339 struct inode *vi = page->mapping->host;
1348 BUG_ON(!PageLocked(page));
1350 /* Is the page fully outside i_size? (truncate in progress) */
1351 if (unlikely(page->index >= (i_size + PAGE_SIZE - 1) >>
1354 * The page may have dirty, unmapped buffers. Make them
1355 * freeable here, so the page does not leak.
1357 block_invalidatepage(page, 0, PAGE_SIZE);
1358 unlock_page(page);
1373 unlock_page(page);
1383 // return ntfs_write_compressed_block(page);
1384 unlock_page(page);
1391 unlock_page(page);
1400 if (page->index >= (i_size >> PAGE_SHIFT)) {
1401 /* The page straddles i_size. */
1403 zero_user_segment(page, ofs, PAGE_SIZE);
1407 return ntfs_write_mst_block(page, wbc);
1409 return ntfs_write_block(page, wbc);
1414 * record and hence smaller than a page, so can simply return error on
1419 BUG_ON(page_has_buffers(page));
1420 BUG_ON(!PageUptodate(page));
1421 if (unlikely(page->index > 0)) {
1422 ntfs_error(vi->i_sb, "BUG()! page->index (0x%lx) > 0. "
1423 "Aborting write.", page->index);
1424 BUG_ON(PageWriteback(page));
1425 set_page_writeback(page);
1426 unlock_page(page);
1427 end_page_writeback(page);
1461 * PAGECACHE_TAG_DIRTY remains set even though the page is clean.
1463 BUG_ON(PageWriteback(page));
1464 set_page_writeback(page);
1465 unlock_page(page);
1480 addr = kmap_atomic(page);
1481 /* Copy the data from the page to the mft record. */
1485 /* Zero out of bounds area in the page cache page. */
1488 flush_dcache_page(page);
1490 /* We are done with the page. */
1491 end_page_writeback(page);
1500 "page so we try again later.");
1502 * Put the page back on mapping->dirty_pages, but leave its
1505 redirty_page_for_writepage(wbc, page);
1510 SetPageError(page);
1513 unlock_page(page);
1683 .readpage = ntfs_readpage, /* Fill page with data. */
1685 .writepage = ntfs_writepage, /* Write dirty page to disk. */
1686 .set_page_dirty = __set_page_dirty_nobuffers, /* Set the page dirty
1688 belonging to the page. */
1699 * @page: page containing the ntfs record to mark dirty
1700 * @ofs: byte offset within @page at which the ntfs record begins
1702 * Set the buffers and the page in which the ntfs record is located dirty.
1707 * If the page does not have buffers, we create them and set them uptodate.
1708 * The page may not be locked which is why we need to handle the buffers under
1712 void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs) {
1713 struct address_space *mapping = page->mapping;
1718 BUG_ON(!PageUptodate(page));
1722 if (unlikely(!page_has_buffers(page))) {
1724 bh = head = alloc_page_buffers(page, bh_size, true);
1726 if (likely(!page_has_buffers(page))) {
1735 attach_page_private(page, head);
1739 bh = head = page_buffers(page);
1750 __set_page_dirty_nobuffers(page);