mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
mm/writeback: Add folio_account_redirty()
Account the number of pages in the folio that we're redirtying. Turn account_page_dirty() into a wrapper around it. Also turn the comment on folio_account_redirty() into kernel-doc and edit it slightly so it makes sense to its potential callers. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Howells <dhowells@redhat.com> Acked-by: Vlastimil Babka <vbabka@suse.cz>
This commit is contained in:
@@ -394,7 +394,11 @@ void tag_pages_for_writeback(struct address_space *mapping,
|
|||||||
pgoff_t start, pgoff_t end);
|
pgoff_t start, pgoff_t end);
|
||||||
|
|
||||||
bool filemap_dirty_folio(struct address_space *mapping, struct folio *folio);
|
bool filemap_dirty_folio(struct address_space *mapping, struct folio *folio);
|
||||||
void account_page_redirty(struct page *page);
|
void folio_account_redirty(struct folio *folio);
|
||||||
|
static inline void account_page_redirty(struct page *page)
|
||||||
|
{
|
||||||
|
folio_account_redirty(page_folio(page));
|
||||||
|
}
|
||||||
|
|
||||||
void sb_mark_inode_writeback(struct inode *inode);
|
void sb_mark_inode_writeback(struct inode *inode);
|
||||||
void sb_clear_inode_writeback(struct inode *inode);
|
void sb_clear_inode_writeback(struct inode *inode);
|
||||||
|
@@ -1084,7 +1084,7 @@ static void wb_update_write_bandwidth(struct bdi_writeback *wb,
|
|||||||
* write_bandwidth = ---------------------------------------------------
|
* write_bandwidth = ---------------------------------------------------
|
||||||
* period
|
* period
|
||||||
*
|
*
|
||||||
* @written may have decreased due to account_page_redirty().
|
* @written may have decreased due to folio_account_redirty().
|
||||||
* Avoid underflowing @bw calculation.
|
* Avoid underflowing @bw calculation.
|
||||||
*/
|
*/
|
||||||
bw = written - min(written, wb->written_stamp);
|
bw = written - min(written, wb->written_stamp);
|
||||||
@@ -2544,30 +2544,36 @@ bool filemap_dirty_folio(struct address_space *mapping, struct folio *folio)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(filemap_dirty_folio);
|
EXPORT_SYMBOL(filemap_dirty_folio);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Call this whenever redirtying a page, to de-account the dirty counters
|
* folio_account_redirty - Manually account for redirtying a page.
|
||||||
* (NR_DIRTIED, WB_DIRTIED, tsk->nr_dirtied), so that they match the written
|
* @folio: The folio which is being redirtied.
|
||||||
* counters (NR_WRITTEN, WB_WRITTEN) in long term. The mismatches will lead to
|
*
|
||||||
* systematic errors in balanced_dirty_ratelimit and the dirty pages position
|
* Most filesystems should call folio_redirty_for_writepage() instead
|
||||||
* control.
|
* of this fuction. If your filesystem is doing writeback outside the
|
||||||
|
* context of a writeback_control(), it can call this when redirtying
|
||||||
|
* a folio, to de-account the dirty counters (NR_DIRTIED, WB_DIRTIED,
|
||||||
|
* tsk->nr_dirtied), so that they match the written counters (NR_WRITTEN,
|
||||||
|
* WB_WRITTEN) in long term. The mismatches will lead to systematic errors
|
||||||
|
* in balanced_dirty_ratelimit and the dirty pages position control.
|
||||||
*/
|
*/
|
||||||
void account_page_redirty(struct page *page)
|
void folio_account_redirty(struct folio *folio)
|
||||||
{
|
{
|
||||||
struct address_space *mapping = page->mapping;
|
struct address_space *mapping = folio->mapping;
|
||||||
|
|
||||||
if (mapping && mapping_can_writeback(mapping)) {
|
if (mapping && mapping_can_writeback(mapping)) {
|
||||||
struct inode *inode = mapping->host;
|
struct inode *inode = mapping->host;
|
||||||
struct bdi_writeback *wb;
|
struct bdi_writeback *wb;
|
||||||
struct wb_lock_cookie cookie = {};
|
struct wb_lock_cookie cookie = {};
|
||||||
|
long nr = folio_nr_pages(folio);
|
||||||
|
|
||||||
wb = unlocked_inode_to_wb_begin(inode, &cookie);
|
wb = unlocked_inode_to_wb_begin(inode, &cookie);
|
||||||
current->nr_dirtied--;
|
current->nr_dirtied -= nr;
|
||||||
dec_node_page_state(page, NR_DIRTIED);
|
node_stat_mod_folio(folio, NR_DIRTIED, -nr);
|
||||||
dec_wb_stat(wb, WB_DIRTIED);
|
wb_stat_mod(wb, WB_DIRTIED, -nr);
|
||||||
unlocked_inode_to_wb_end(inode, &cookie);
|
unlocked_inode_to_wb_end(inode, &cookie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(account_page_redirty);
|
EXPORT_SYMBOL(folio_account_redirty);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When a writepage implementation decides that it doesn't want to write this
|
* When a writepage implementation decides that it doesn't want to write this
|
||||||
|
Reference in New Issue
Block a user