From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Jonathan Corbet <corbet@lwn.net>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/8] buffer: Add kernel-doc for try_to_free_buffers()
Date: Tue, 9 Jan 2024 14:33:52 +0000 [thread overview]
Message-ID: <20240109143357.2375046-4-willy@infradead.org> (raw)
In-Reply-To: <20240109143357.2375046-1-willy@infradead.org>
The documentation for this function has become separated from it over
time; move it to the right place and turn it into kernel-doc. Mild
editing of the content to make it more about what the function does, and
less about how it does it.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/buffer.c | 44 ++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 071f01b28c90..25861241657f 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2864,26 +2864,6 @@ int sync_dirty_buffer(struct buffer_head *bh)
}
EXPORT_SYMBOL(sync_dirty_buffer);
-/*
- * try_to_free_buffers() checks if all the buffers on this particular folio
- * are unused, and releases them if so.
- *
- * Exclusion against try_to_free_buffers may be obtained by either
- * locking the folio or by holding its mapping's i_private_lock.
- *
- * If the folio is dirty but all the buffers are clean then we need to
- * be sure to mark the folio clean as well. This is because the folio
- * may be against a block device, and a later reattachment of buffers
- * to a dirty folio will set *all* buffers dirty. Which would corrupt
- * filesystem data on the same device.
- *
- * The same applies to regular filesystem folios: if all the buffers are
- * clean then we set the folio clean and proceed. To do that, we require
- * total exclusion from block_dirty_folio(). That is obtained with
- * i_private_lock.
- *
- * try_to_free_buffers() is non-blocking.
- */
static inline int buffer_busy(struct buffer_head *bh)
{
return atomic_read(&bh->b_count) |
@@ -2917,6 +2897,30 @@ drop_buffers(struct folio *folio, struct buffer_head **buffers_to_free)
return false;
}
+/**
+ * try_to_free_buffers: Release buffers attached to this folio.
+ * @folio: The folio.
+ *
+ * If any buffers are in use (dirty, under writeback, elevated refcount),
+ * no buffers will be freed.
+ *
+ * If the folio is dirty but all the buffers are clean then we need to
+ * be sure to mark the folio clean as well. This is because the folio
+ * may be against a block device, and a later reattachment of buffers
+ * to a dirty folio will set *all* buffers dirty. Which would corrupt
+ * filesystem data on the same device.
+ *
+ * The same applies to regular filesystem folios: if all the buffers are
+ * clean then we set the folio clean and proceed. To do that, we require
+ * total exclusion from block_dirty_folio(). That is obtained with
+ * i_private_lock.
+ *
+ * Exclusion against try_to_free_buffers may be obtained by either
+ * locking the folio or by holding its mapping's i_private_lock.
+ *
+ * Context: Process context. @folio must be locked. Will not sleep.
+ * Return: true if all buffers attached to this folio were freed.
+ */
bool try_to_free_buffers(struct folio *folio)
{
struct address_space * const mapping = folio->mapping;
--
2.43.0
next prev parent reply other threads:[~2024-01-09 14:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-09 14:33 [PATCH v2 0/8] Improve buffer head documentation Matthew Wilcox (Oracle)
2024-01-09 14:33 ` [PATCH v2 1/8] doc: Improve the description of __folio_mark_dirty Matthew Wilcox (Oracle)
2024-01-09 14:33 ` [PATCH v2 2/8] buffer: Add kernel-doc for block_dirty_folio() Matthew Wilcox (Oracle)
2024-01-10 14:12 ` Pankaj Raghav (Samsung)
2024-01-09 14:33 ` Matthew Wilcox (Oracle) [this message]
2024-01-10 14:21 ` [PATCH v2 3/8] buffer: Add kernel-doc for try_to_free_buffers() Pankaj Raghav (Samsung)
2024-01-11 3:22 ` Randy Dunlap
2024-01-09 14:33 ` [PATCH v2 4/8] buffer: Fix __bread and __bread_gfp kernel-doc Matthew Wilcox (Oracle)
2024-01-09 14:33 ` [PATCH v2 5/8] buffer: Add kernel-doc for brelse() and __brelse() Matthew Wilcox (Oracle)
2024-01-10 14:30 ` Pankaj Raghav (Samsung)
2024-01-10 17:26 ` Matthew Wilcox
2024-01-10 20:10 ` Pankaj Raghav (Samsung)
2024-01-09 14:33 ` [PATCH v2 6/8] buffer: Add kernel-doc for bforget() and __bforget() Matthew Wilcox (Oracle)
2024-01-09 14:33 ` [PATCH v2 7/8] buffer: Improve bdev_getblk documentation Matthew Wilcox (Oracle)
2024-01-09 14:33 ` [PATCH v2 8/8] doc: Split buffer.rst out of api-summary.rst Matthew Wilcox (Oracle)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240109143357.2375046-4-willy@infradead.org \
--to=willy@infradead.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).