mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-04 04:02:26 +00:00
mm/writeback: move __set_page_dirty() to core mm
Patch series "Further set_page_dirty cleanups". Prompted by Christoph's recent patches, here are some more patches to improve the state of set_page_dirty(). They're all from the folio tree, so they've been tested to a certain extent. This patch (of 6): Nothing in __set_page_dirty() is specific to buffer_head, so move it to mm/page-writeback.c. That removes the only caller of account_page_dirtied() outside of page-writeback.c, so make it static. Link: https://lkml.kernel.org/r/20210615162342.1669332-1-willy@infradead.org Link: https://lkml.kernel.org/r/20210615162342.1669332-2-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jan Kara <jack@suse.cz> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
0af573780b
commit
6e1cae881a
24
fs/buffer.c
24
fs/buffer.c
@ -588,30 +588,6 @@ void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode)
|
||||
}
|
||||
EXPORT_SYMBOL(mark_buffer_dirty_inode);
|
||||
|
||||
/*
|
||||
* Mark the page dirty, and set it dirty in the page cache, and mark the inode
|
||||
* dirty.
|
||||
*
|
||||
* If warn is true, then emit a warning if the page is not uptodate and has
|
||||
* not been truncated.
|
||||
*
|
||||
* The caller must hold lock_page_memcg().
|
||||
*/
|
||||
void __set_page_dirty(struct page *page, struct address_space *mapping,
|
||||
int warn)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
xa_lock_irqsave(&mapping->i_pages, flags);
|
||||
if (page->mapping) { /* Race with truncate? */
|
||||
WARN_ON_ONCE(warn && !PageUptodate(page));
|
||||
account_page_dirtied(page, mapping);
|
||||
__xa_set_mark(&mapping->i_pages, page_index(page),
|
||||
PAGECACHE_TAG_DIRTY);
|
||||
}
|
||||
xa_unlock_irqrestore(&mapping->i_pages, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a page to the dirty page list.
|
||||
*
|
||||
|
@ -1855,7 +1855,6 @@ int __set_page_dirty_nobuffers(struct page *page);
|
||||
int __set_page_dirty_no_writeback(struct page *page);
|
||||
int redirty_page_for_writepage(struct writeback_control *wbc,
|
||||
struct page *page);
|
||||
void account_page_dirtied(struct page *page, struct address_space *mapping);
|
||||
void account_page_cleaned(struct page *page, struct address_space *mapping,
|
||||
struct bdi_writeback *wb);
|
||||
int set_page_dirty(struct page *page);
|
||||
|
@ -2425,7 +2425,8 @@ int __set_page_dirty_no_writeback(struct page *page)
|
||||
*
|
||||
* NOTE: This relies on being atomic wrt interrupts.
|
||||
*/
|
||||
void account_page_dirtied(struct page *page, struct address_space *mapping)
|
||||
static void account_page_dirtied(struct page *page,
|
||||
struct address_space *mapping)
|
||||
{
|
||||
struct inode *inode = mapping->host;
|
||||
|
||||
@ -2466,6 +2467,30 @@ void account_page_cleaned(struct page *page, struct address_space *mapping,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark the page dirty, and set it dirty in the page cache, and mark the inode
|
||||
* dirty.
|
||||
*
|
||||
* If warn is true, then emit a warning if the page is not uptodate and has
|
||||
* not been truncated.
|
||||
*
|
||||
* The caller must hold lock_page_memcg().
|
||||
*/
|
||||
void __set_page_dirty(struct page *page, struct address_space *mapping,
|
||||
int warn)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
xa_lock_irqsave(&mapping->i_pages, flags);
|
||||
if (page->mapping) { /* Race with truncate? */
|
||||
WARN_ON_ONCE(warn && !PageUptodate(page));
|
||||
account_page_dirtied(page, mapping);
|
||||
__xa_set_mark(&mapping->i_pages, page_index(page),
|
||||
PAGECACHE_TAG_DIRTY);
|
||||
}
|
||||
xa_unlock_irqrestore(&mapping->i_pages, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* For address_spaces which do not use buffers. Just tag the page as dirty in
|
||||
* the xarray.
|
||||
|
Loading…
Reference in New Issue
Block a user