Commit 3814ec89 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Andrew Morton

buffer: add kernel-doc for block_dirty_folio()

Turn the excellent documentation for this function into kernel-doc. 
Replace 'page' with 'folio' and make a few other minor updates.

Link: https://lkml.kernel.org/r/20240416031754.4076917-3-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarPankaj Raghav <p.raghav@samsung.com>
Tested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 3d84d897
...@@ -687,30 +687,37 @@ void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode) ...@@ -687,30 +687,37 @@ void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode)
} }
EXPORT_SYMBOL(mark_buffer_dirty_inode); EXPORT_SYMBOL(mark_buffer_dirty_inode);
/* /**
* Add a page to the dirty page list. * block_dirty_folio - Mark a folio as dirty.
* * @mapping: The address space containing this folio.
* It is a sad fact of life that this function is called from several places * @folio: The folio to mark dirty.
* deeply under spinlocking. It may not sleep. *
* * Filesystems which use buffer_heads can use this function as their
* If the page has buffers, the uptodate buffers are set dirty, to preserve * ->dirty_folio implementation. Some filesystems need to do a little
* dirty-state coherency between the page and the buffers. It the page does * work before calling this function. Filesystems which do not use
* not have buffers then when they are later attached they will all be set * buffer_heads should call filemap_dirty_folio() instead.
* dirty. *
* * If the folio has buffers, the uptodate buffers are set dirty, to
* The buffers are dirtied before the page is dirtied. There's a small race * preserve dirty-state coherency between the folio and the buffers.
* window in which a writepage caller may see the page cleanness but not the * Buffers added to a dirty folio are created dirty.
* buffer dirtiness. That's fine. If this code were to set the page dirty *
* before the buffers, a concurrent writepage caller could clear the page dirty * The buffers are dirtied before the folio is dirtied. There's a small
* bit, see a bunch of clean buffers and we'd end up with dirty buffers/clean * race window in which writeback may see the folio cleanness but not the
* page on the dirty page list. * buffer dirtiness. That's fine. If this code were to set the folio
* * dirty before the buffers, writeback could clear the folio dirty flag,
* We use i_private_lock to lock against try_to_free_buffers while using the * see a bunch of clean buffers and we'd end up with dirty buffers/clean
* page's buffer list. Also use this to protect against clean buffers being * folio on the dirty folio list.
* added to the page after it was set dirty. *
* * We use i_private_lock to lock against try_to_free_buffers() while
* FIXME: may need to call ->reservepage here as well. That's rather up to the * using the folio's buffer list. This also prevents clean buffers
* address_space though. * being added to the folio after it was set dirty.
*
* Context: May only be called from process context. Does not sleep.
* Caller must ensure that @folio cannot be truncated during this call,
* typically by holding the folio lock or having a page in the folio
* mapped and holding the page table lock.
*
* Return: True if the folio was dirtied; false if it was already dirtied.
*/ */
bool block_dirty_folio(struct address_space *mapping, struct folio *folio) bool block_dirty_folio(struct address_space *mapping, struct folio *folio)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment