Lines Matching refs:folio

2401 int folio_write_one(struct folio *folio)  in folio_write_one()  argument
2403 struct address_space *mapping = folio->mapping; in folio_write_one()
2407 .nr_to_write = folio_nr_pages(folio), in folio_write_one()
2410 BUG_ON(!folio_test_locked(folio)); in folio_write_one()
2412 folio_wait_writeback(folio); in folio_write_one()
2414 if (folio_clear_dirty_for_io(folio)) { in folio_write_one()
2415 folio_get(folio); in folio_write_one()
2416 ret = mapping->a_ops->writepage(&folio->page, &wbc); in folio_write_one()
2418 folio_wait_writeback(folio); in folio_write_one()
2419 folio_put(folio); in folio_write_one()
2421 folio_unlock(folio); in folio_write_one()
2448 static void folio_account_dirtied(struct folio *folio, in folio_account_dirtied() argument
2453 trace_writeback_dirty_folio(folio, mapping); in folio_account_dirtied()
2457 long nr = folio_nr_pages(folio); in folio_account_dirtied()
2459 inode_attach_wb(inode, &folio->page); in folio_account_dirtied()
2462 __lruvec_stat_mod_folio(folio, NR_FILE_DIRTY, nr); in folio_account_dirtied()
2463 __zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, nr); in folio_account_dirtied()
2464 __node_stat_mod_folio(folio, NR_DIRTIED, nr); in folio_account_dirtied()
2471 mem_cgroup_track_foreign_dirty(folio, wb); in folio_account_dirtied()
2480 void folio_account_cleaned(struct folio *folio, struct address_space *mapping, in folio_account_cleaned() argument
2484 long nr = folio_nr_pages(folio); in folio_account_cleaned()
2485 lruvec_stat_mod_folio(folio, NR_FILE_DIRTY, -nr); in folio_account_cleaned()
2486 zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, -nr); in folio_account_cleaned()
2501 void __folio_mark_dirty(struct folio *folio, struct address_space *mapping, in __folio_mark_dirty() argument
2507 if (folio->mapping) { /* Race with truncate? */ in __folio_mark_dirty()
2508 WARN_ON_ONCE(warn && !folio_test_uptodate(folio)); in __folio_mark_dirty()
2509 folio_account_dirtied(folio, mapping); in __folio_mark_dirty()
2510 __xa_set_mark(&mapping->i_pages, folio_index(folio), in __folio_mark_dirty()
2535 bool filemap_dirty_folio(struct address_space *mapping, struct folio *folio) in filemap_dirty_folio() argument
2537 folio_memcg_lock(folio); in filemap_dirty_folio()
2538 if (folio_test_set_dirty(folio)) { in filemap_dirty_folio()
2539 folio_memcg_unlock(folio); in filemap_dirty_folio()
2543 __folio_mark_dirty(folio, mapping, !folio_test_private(folio)); in filemap_dirty_folio()
2544 folio_memcg_unlock(folio); in filemap_dirty_folio()
2566 void folio_account_redirty(struct folio *folio) in folio_account_redirty() argument
2568 struct address_space *mapping = folio->mapping; in folio_account_redirty()
2574 long nr = folio_nr_pages(folio); in folio_account_redirty()
2578 node_stat_mod_folio(folio, NR_DIRTIED, -nr); in folio_account_redirty()
2598 struct folio *folio) in folio_redirty_for_writepage() argument
2601 long nr = folio_nr_pages(folio); in folio_redirty_for_writepage()
2604 ret = filemap_dirty_folio(folio->mapping, folio); in folio_redirty_for_writepage()
2605 folio_account_redirty(folio); in folio_redirty_for_writepage()
2622 bool folio_mark_dirty(struct folio *folio) in folio_mark_dirty() argument
2624 struct address_space *mapping = folio_mapping(folio); in folio_mark_dirty()
2637 if (folio_test_reclaim(folio)) in folio_mark_dirty()
2638 folio_clear_reclaim(folio); in folio_mark_dirty()
2639 return mapping->a_ops->set_page_dirty(&folio->page); in folio_mark_dirty()
2641 if (!folio_test_dirty(folio)) { in folio_mark_dirty()
2642 if (!folio_test_set_dirty(folio)) in folio_mark_dirty()
2683 void __folio_cancel_dirty(struct folio *folio) in __folio_cancel_dirty() argument
2685 struct address_space *mapping = folio_mapping(folio); in __folio_cancel_dirty()
2692 folio_memcg_lock(folio); in __folio_cancel_dirty()
2695 if (folio_test_clear_dirty(folio)) in __folio_cancel_dirty()
2696 folio_account_cleaned(folio, mapping, wb); in __folio_cancel_dirty()
2699 folio_memcg_unlock(folio); in __folio_cancel_dirty()
2701 folio_clear_dirty(folio); in __folio_cancel_dirty()
2720 bool folio_clear_dirty_for_io(struct folio *folio) in folio_clear_dirty_for_io() argument
2722 struct address_space *mapping = folio_mapping(folio); in folio_clear_dirty_for_io()
2725 VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); in folio_clear_dirty_for_io()
2757 if (folio_mkclean(folio)) in folio_clear_dirty_for_io()
2758 folio_mark_dirty(folio); in folio_clear_dirty_for_io()
2768 if (folio_test_clear_dirty(folio)) { in folio_clear_dirty_for_io()
2769 long nr = folio_nr_pages(folio); in folio_clear_dirty_for_io()
2770 lruvec_stat_mod_folio(folio, NR_FILE_DIRTY, -nr); in folio_clear_dirty_for_io()
2771 zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, -nr); in folio_clear_dirty_for_io()
2778 return folio_test_clear_dirty(folio); in folio_clear_dirty_for_io()
2800 bool __folio_end_writeback(struct folio *folio) in __folio_end_writeback() argument
2802 long nr = folio_nr_pages(folio); in __folio_end_writeback()
2803 struct address_space *mapping = folio_mapping(folio); in __folio_end_writeback()
2806 folio_memcg_lock(folio); in __folio_end_writeback()
2813 ret = folio_test_clear_writeback(folio); in __folio_end_writeback()
2815 __xa_clear_mark(&mapping->i_pages, folio_index(folio), in __folio_end_writeback()
2834 ret = folio_test_clear_writeback(folio); in __folio_end_writeback()
2837 lruvec_stat_mod_folio(folio, NR_WRITEBACK, -nr); in __folio_end_writeback()
2838 zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, -nr); in __folio_end_writeback()
2839 node_stat_mod_folio(folio, NR_WRITTEN, nr); in __folio_end_writeback()
2841 folio_memcg_unlock(folio); in __folio_end_writeback()
2845 bool __folio_start_writeback(struct folio *folio, bool keep_write) in __folio_start_writeback() argument
2847 long nr = folio_nr_pages(folio); in __folio_start_writeback()
2848 struct address_space *mapping = folio_mapping(folio); in __folio_start_writeback()
2852 folio_memcg_lock(folio); in __folio_start_writeback()
2854 XA_STATE(xas, &mapping->i_pages, folio_index(folio)); in __folio_start_writeback()
2861 ret = folio_test_set_writeback(folio); in __folio_start_writeback()
2885 if (!folio_test_dirty(folio)) in __folio_start_writeback()
2891 ret = folio_test_set_writeback(folio); in __folio_start_writeback()
2894 lruvec_stat_mod_folio(folio, NR_WRITEBACK, nr); in __folio_start_writeback()
2895 zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, nr); in __folio_start_writeback()
2897 folio_memcg_unlock(folio); in __folio_start_writeback()
2898 access_ret = arch_make_folio_accessible(folio); in __folio_start_writeback()
2903 VM_BUG_ON_FOLIO(access_ret != 0, folio); in __folio_start_writeback()
2921 void folio_wait_writeback(struct folio *folio) in folio_wait_writeback() argument
2923 while (folio_test_writeback(folio)) { in folio_wait_writeback()
2924 trace_folio_wait_writeback(folio, folio_mapping(folio)); in folio_wait_writeback()
2925 folio_wait_bit(folio, PG_writeback); in folio_wait_writeback()
2943 int folio_wait_writeback_killable(struct folio *folio) in folio_wait_writeback_killable() argument
2945 while (folio_test_writeback(folio)) { in folio_wait_writeback_killable()
2946 trace_folio_wait_writeback(folio, folio_mapping(folio)); in folio_wait_writeback_killable()
2947 if (folio_wait_bit_killable(folio, PG_writeback)) in folio_wait_writeback_killable()
2968 void folio_wait_stable(struct folio *folio) in folio_wait_stable() argument
2970 if (folio_inode(folio)->i_sb->s_iflags & SB_I_STABLE_WRITES) in folio_wait_stable()
2971 folio_wait_writeback(folio); in folio_wait_stable()