Patch "writeback: account the number of pages written back" has been added to the 6.4-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

    writeback: account the number of pages written back

to the 6.4-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:
     writeback-account-the-number-of-pages-written-back.patch
and it can be found in the queue-6.4 subdirectory.

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



commit 878deaa007290b73ff069bb3cd493ace626df12c
Author: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
Date:   Wed Jun 28 19:55:48 2023 +0100

    writeback: account the number of pages written back
    
    [ Upstream commit 8344a3d44be3d18671e18c4ba23bb03dd21e14ad ]
    
    nr_to_write is a count of pages, so we need to decrease it by the number
    of pages in the folio we just wrote, not by 1.  Most callers specify
    either LONG_MAX or 1, so are unaffected, but writeback_sb_inodes() might
    end up writing 512x as many pages as it asked for.
    
    Dave added:
    
    : XFS is the only filesystem this would affect, right?  AFAIA, nothing
    : else enables large folios and uses writeback through
    : write_cache_pages() at this point...
    :
    : In which case, I'd be surprised if much difference, if any, gets
    : noticed by anyone.
    
    Link: https://lkml.kernel.org/r/20230628185548.981888-1-willy@xxxxxxxxxxxxx
    Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
    Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Cc: Jan Kara <jack@xxxxxxx>
    Cc: Dave Chinner <david@xxxxxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index db79439990073..6faa09f1783b3 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2434,6 +2434,7 @@ int write_cache_pages(struct address_space *mapping,
 
 		for (i = 0; i < nr_folios; i++) {
 			struct folio *folio = fbatch.folios[i];
+			unsigned long nr;
 
 			done_index = folio->index;
 
@@ -2471,6 +2472,7 @@ int write_cache_pages(struct address_space *mapping,
 
 			trace_wbc_writepage(wbc, inode_to_bdi(mapping->host));
 			error = writepage(folio, wbc, data);
+			nr = folio_nr_pages(folio);
 			if (unlikely(error)) {
 				/*
 				 * Handle errors according to the type of
@@ -2489,8 +2491,7 @@ int write_cache_pages(struct address_space *mapping,
 					error = 0;
 				} else if (wbc->sync_mode != WB_SYNC_ALL) {
 					ret = error;
-					done_index = folio->index +
-						folio_nr_pages(folio);
+					done_index = folio->index + nr;
 					done = 1;
 					break;
 				}
@@ -2504,7 +2505,8 @@ int write_cache_pages(struct address_space *mapping,
 			 * keep going until we have written all the pages
 			 * we tagged for writeback prior to entering this loop.
 			 */
-			if (--wbc->nr_to_write <= 0 &&
+			wbc->nr_to_write -= nr;
+			if (wbc->nr_to_write <= 0 &&
 			    wbc->sync_mode == WB_SYNC_NONE) {
 				done = 1;
 				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