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 5/8] buffer: Add kernel-doc for brelse() and __brelse()
Date: Tue, 9 Jan 2024 14:33:54 +0000 [thread overview]
Message-ID: <20240109143357.2375046-6-willy@infradead.org> (raw)
In-Reply-To: <20240109143357.2375046-1-willy@infradead.org>
Move the documentation for __brelse() to brelse(), format it as
kernel-doc and update it from talking about pages to folios.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/buffer.c | 17 ++++++++---------
include/linux/buffer_head.h | 16 ++++++++++++++++
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 160bbc1f929c..9a7b3649c872 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1226,17 +1226,16 @@ void mark_buffer_write_io_error(struct buffer_head *bh)
}
EXPORT_SYMBOL(mark_buffer_write_io_error);
-/*
- * Decrement a buffer_head's reference count. If all buffers against a page
- * have zero reference count, are clean and unlocked, and if the page is clean
- * and unlocked then try_to_free_buffers() may strip the buffers from the page
- * in preparation for freeing it (sometimes, rarely, buffers are removed from
- * a page but it ends up not being freed, and buffers may later be reattached).
+/**
+ * __brelse - Release a buffer.
+ * @bh: The buffer to release.
+ *
+ * This variant of brelse() can be called if @bh is guaranteed to not be NULL.
*/
-void __brelse(struct buffer_head * buf)
+void __brelse(struct buffer_head *bh)
{
- if (atomic_read(&buf->b_count)) {
- put_bh(buf);
+ if (atomic_read(&bh->b_count)) {
+ put_bh(bh);
return;
}
WARN(1, KERN_ERR "VFS: brelse: Trying to free free buffer\n");
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 56a1e9c1e71e..3cbc01bbc398 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -303,6 +303,22 @@ static inline void put_bh(struct buffer_head *bh)
atomic_dec(&bh->b_count);
}
+/**
+ * brelse - Release a buffer.
+ * @bh: The buffer to release.
+ *
+ * Decrement a buffer_head's reference count. If @bh is NULL, this
+ * function is a no-op.
+ *
+ * If all buffers on a folio have zero reference count, are clean
+ * and unlocked, and if the folio is clean and unlocked then
+ * try_to_free_buffers() may strip the buffers from the folio in
+ * preparation for freeing it (sometimes, rarely, buffers are removed
+ * from a folio but it ends up not being freed, and buffers may later
+ * be reattached).
+ *
+ * Context: Any context.
+ */
static inline void brelse(struct buffer_head *bh)
{
if (bh)
--
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 ` [PATCH v2 3/8] buffer: Add kernel-doc for try_to_free_buffers() Matthew Wilcox (Oracle)
2024-01-10 14:21 ` 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 ` Matthew Wilcox (Oracle) [this message]
2024-01-10 14:30 ` [PATCH v2 5/8] buffer: Add kernel-doc for brelse() and __brelse() 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-6-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).