From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
linux-arch@vger.kernel.org, torvalds@linux-foundation.org,
npiggin@gmail.com
Subject: [PATCH v2 03/17] mm: Add folio_end_read()
Date: Wed, 4 Oct 2023 17:53:03 +0100 [thread overview]
Message-ID: <20231004165317.1061855-4-willy@infradead.org> (raw)
In-Reply-To: <20231004165317.1061855-1-willy@infradead.org>
Provide a function for filesystems to call when they have finished
reading an entire folio.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/pagemap.h | 1 +
mm/filemap.c | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 351c3b7f93a1..5bb2f5f802bc 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1129,6 +1129,7 @@ static inline void wait_on_page_locked(struct page *page)
folio_wait_locked(page_folio(page));
}
+void folio_end_read(struct folio *folio, bool success);
void wait_on_page_writeback(struct page *page);
void folio_wait_writeback(struct folio *folio);
int folio_wait_writeback_killable(struct folio *folio);
diff --git a/mm/filemap.c b/mm/filemap.c
index f0a15ce1bd1b..ea317cdf9532 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1527,6 +1527,28 @@ void folio_unlock(struct folio *folio)
}
EXPORT_SYMBOL(folio_unlock);
+/**
+ * folio_end_read - End read on a folio.
+ * @folio: The folio.
+ * @success: True if all reads completed successfully.
+ *
+ * When all reads against a folio have completed, filesystems should
+ * call this function to let the pagecache know that no more reads
+ * are outstanding. This will unlock the folio and wake up any thread
+ * sleeping on the lock. The folio will also be marked uptodate if all
+ * reads succeeded.
+ *
+ * Context: May be called from interrupt or process context. May not be
+ * called from NMI context.
+ */
+void folio_end_read(struct folio *folio, bool success)
+{
+ if (likely(success))
+ folio_mark_uptodate(folio);
+ folio_unlock(folio);
+}
+EXPORT_SYMBOL(folio_end_read);
+
/**
* folio_end_private_2 - Clear PG_private_2 and wake any waiters.
* @folio: The folio.
--
2.40.1
next prev parent reply other threads:[~2023-10-04 16:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-04 16:53 [PATCH v2 00/17] Add folio_end_read Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 01/17] iomap: Hold state_lock over call to ifs_set_range_uptodate() Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 02/17] iomap: Protect read_bytes_pending with the state_lock Matthew Wilcox (Oracle)
2023-10-04 16:53 ` Matthew Wilcox (Oracle) [this message]
2024-02-23 15:26 ` [PATCH v2 03/17] mm: Add folio_end_read() Tetsuo Handa
2024-02-23 15:36 ` Matthew Wilcox
2023-10-04 16:53 ` [PATCH v2 04/17] ext4: Use folio_end_read() Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 05/17] buffer: " Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 06/17] iomap: " Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 07/17] bitops: Add xor_unlock_is_negative_byte() Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 08/17] alpha: Implement xor_unlock_is_negative_byte Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 09/17] m68k: " Matthew Wilcox (Oracle)
2023-10-04 23:49 ` Greg Ungerer
2023-10-05 8:11 ` Geert Uytterhoeven
2023-10-04 16:53 ` [PATCH v2 10/17] mips: " Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 11/17] powerpc: Implement arch_xor_unlock_is_negative_byte on 32-bit Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 12/17] riscv: Implement xor_unlock_is_negative_byte Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 13/17] s390: Implement arch_xor_unlock_is_negative_byte Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 14/17] mm: Delete checks for xor_unlock_is_negative_byte() Matthew Wilcox (Oracle)
2023-10-05 8:12 ` Geert Uytterhoeven
2023-10-04 16:53 ` [PATCH v2 15/17] mm: Add folio_xor_flags_has_waiters() Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 16/17] mm: Make __end_folio_writeback() return void Matthew Wilcox (Oracle)
2023-10-04 16:53 ` [PATCH v2 17/17] mm: Use folio_xor_flags_has_waiters() in folio_end_writeback() 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=20231004165317.1061855-4-willy@infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=npiggin@gmail.com \
--cc=torvalds@linux-foundation.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 read-only IMAP folder(s) and NNTP newsgroup(s).