diff mbox series

mm: Assert the folio is locked in folio_start_writeback()

Message ID 20250226153614.3774896-1-willy@infradead.org (mailing list archive)
State New
Headers show
Series mm: Assert the folio is locked in folio_start_writeback() | expand

Commit Message

Matthew Wilcox (Oracle) Feb. 26, 2025, 3:36 p.m. UTC
The folio must be locked when we start writeback in order to
prevent writeback from being started twice on the same folio.
I don't expect this to catch any problems, but it should be
good documentation.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/page-writeback.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Darrick J. Wong Feb. 26, 2025, 4:21 p.m. UTC | #1
On Wed, Feb 26, 2025 at 03:36:12PM +0000, Matthew Wilcox (Oracle) wrote:
> The folio must be locked when we start writeback in order to
> prevent writeback from being started twice on the same folio.
> I don't expect this to catch any problems, but it should be
> good documentation.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

LGTM
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  mm/page-writeback.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index eb55ece39c56..8b325aa525eb 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -3109,6 +3109,7 @@ void __folio_start_writeback(struct folio *folio, bool keep_write)
>  	int access_ret;
>  
>  	VM_BUG_ON_FOLIO(folio_test_writeback(folio), folio);
> +	VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
>  
>  	if (mapping && mapping_use_writeback_tags(mapping)) {
>  		XA_STATE(xas, &mapping->i_pages, folio_index(folio));
> -- 
> 2.47.2
> 
>
diff mbox series

Patch

diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index eb55ece39c56..8b325aa525eb 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -3109,6 +3109,7 @@  void __folio_start_writeback(struct folio *folio, bool keep_write)
 	int access_ret;
 
 	VM_BUG_ON_FOLIO(folio_test_writeback(folio), folio);
+	VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
 
 	if (mapping && mapping_use_writeback_tags(mapping)) {
 		XA_STATE(xas, &mapping->i_pages, folio_index(folio));