summaryrefslogtreecommitdiff
path: root/mm/filemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index e9c636f57777..523d9e15b3b0 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1593,9 +1593,15 @@ EXPORT_SYMBOL(folio_wait_private_2_killable);
/**
* folio_end_writeback - End writeback against a folio.
* @folio: The folio.
+ *
+ * The folio must actually be under writeback.
+ *
+ * Context: May be called from process or interrupt context.
*/
void folio_end_writeback(struct folio *folio)
{
+ VM_BUG_ON_FOLIO(!folio_test_writeback(folio), folio);
+
/*
* folio_test_clear_reclaim() could be used here but it is an
* atomic operation and overkill in this particular case. Failing
@@ -1615,8 +1621,7 @@ void folio_end_writeback(struct folio *folio)
* reused before the folio_wake().
*/
folio_get(folio);
- if (!__folio_end_writeback(folio))
- BUG();
+ __folio_end_writeback(folio);
smp_mb__after_atomic();
folio_wake(folio, PG_writeback);