• Christoph Hellwig's avatar
    writeback: add a writeback iterator · cdc150b5
    Christoph Hellwig authored
    Refactor the code left in write_cache_pages into an iterator that the file
    system can call to get the next folio for a writeback operation:
    
    	struct folio *folio = NULL;
    
    	while ((folio = writeback_iter(mapping, wbc, folio, &error))) {
    		error = <do per-folio writeback>;
    	}
    
    The twist here is that the error value is passed by reference, so that the
    iterator can restore it when breaking out of the loop.
    
    Handling of the magic AOP_WRITEPAGE_ACTIVATE value stays outside the
    iterator and needs is just kept in the write_cache_pages legacy wrapper. 
    in preparation for eventually killing it off.
    
    Heavily based on a for_each* based iterator from Matthew Wilcox.
    
    Link: https://lkml.kernel.org/r/20240215063649.2164017-14-hch@lst.deSigned-off-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarJan Kara <jack@suse.cz>
    Cc: Christian Brauner <brauner@kernel.org>
    Cc: Dave Chinner <dchinner@redhat.com>
    Cc: David Howells <dhowells@redhat.com>
    Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    cdc150b5
writeback.h 12.5 KB