Patch "afs: Fix page leak" has been added to the 5.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    afs: Fix page leak

to the 5.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     afs-fix-page-leak.patch
and it can be found in the queue-5.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d7185ea92614526b1882e73a7d19465cff5fb1c9
Author: David Howells <dhowells@xxxxxxxxxx>
Date:   Wed Sep 1 09:15:21 2021 +0100

    afs: Fix page leak
    
    [ Upstream commit 581b2027af0018944ba301d68e7af45c6d1128b5 ]
    
    There's a loop in afs_extend_writeback() that adds extra pages to a write
    we want to make to improve the efficiency of the writeback by making it
    larger.  This loop stops, however, if we hit a page we can't write back
    from immediately, but it doesn't get rid of the page ref we speculatively
    acquired.
    
    This was caused by the removal of the cleanup loop when the code switched
    from using find_get_pages_contig() to xarray scanning as the latter only
    gets a single page at a time, not a batch.
    
    Fix this by putting the page on a ref on an early break from the loop.
    Unfortunately, we can't just add that page to the pagevec we're employing
    as we'll go through that and add those pages to the RPC call.
    
    This was found by the generic/074 test.  It leaks ~4GiB of RAM each time it
    is run - which can be observed with "top".
    
    Fixes: e87b03f5830e ("afs: Prepare for use of THPs")
    Reported-by: Marc Dionne <marc.dionne@xxxxxxxxxxxx>
    Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
    Reviewed-and-tested-by: Marc Dionne <marc.dionne@xxxxxxxxxxxx>
    cc: linux-afs@xxxxxxxxxxxxxxxxxxx
    Link: https://lore.kernel.org/r/163111666635.283156.177701903478910460.stgit@xxxxxxxxxxxxxxxxxxxxxx/
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/afs/write.c b/fs/afs/write.c
index c0534697268e..66b235266893 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -471,13 +471,18 @@ static void afs_extend_writeback(struct address_space *mapping,
 			}
 
 			/* Has the page moved or been split? */
-			if (unlikely(page != xas_reload(&xas)))
+			if (unlikely(page != xas_reload(&xas))) {
+				put_page(page);
 				break;
+			}
 
-			if (!trylock_page(page))
+			if (!trylock_page(page)) {
+				put_page(page);
 				break;
+			}
 			if (!PageDirty(page) || PageWriteback(page)) {
 				unlock_page(page);
+				put_page(page);
 				break;
 			}
 
@@ -487,6 +492,7 @@ static void afs_extend_writeback(struct address_space *mapping,
 			t = afs_page_dirty_to(page, priv);
 			if (f != 0 && !new_content) {
 				unlock_page(page);
+				put_page(page);
 				break;
 			}
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux