Re: [PATCH] fs: use writeback_iter directly in mpage_writepages

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

 



On Wed 07-05-25 08:21:24, Christoph Hellwig wrote:
> Stop using write_cache_pages and use writeback_iter directly.  This
> removes an indirect call per written folio and makes the code easier
> to follow.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

								Honza

> ---
>  fs/mpage.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/mpage.c b/fs/mpage.c
> index ad7844de87c3..c5fd821fd30e 100644
> --- a/fs/mpage.c
> +++ b/fs/mpage.c
> @@ -445,10 +445,9 @@ static void clean_buffers(struct folio *folio, unsigned first_unmapped)
>  		try_to_free_buffers(folio);
>  }
>  
> -static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc,
> -		      void *data)
> +static int mpage_write_folio(struct writeback_control *wbc, struct folio *folio,
> +		struct mpage_data *mpd)
>  {
> -	struct mpage_data *mpd = data;
>  	struct bio *bio = mpd->bio;
>  	struct address_space *mapping = folio->mapping;
>  	struct inode *inode = mapping->host;
> @@ -656,14 +655,16 @@ mpage_writepages(struct address_space *mapping,
>  	struct mpage_data mpd = {
>  		.get_block	= get_block,
>  	};
> +	struct folio *folio = NULL;
>  	struct blk_plug plug;
> -	int ret;
> +	int error;
>  
>  	blk_start_plug(&plug);
> -	ret = write_cache_pages(mapping, wbc, __mpage_writepage, &mpd);
> +	while ((folio = writeback_iter(mapping, wbc, folio, &error)))
> +		error = mpage_write_folio(wbc, folio, &mpd);
>  	if (mpd.bio)
>  		mpage_bio_submit_write(mpd.bio);
>  	blk_finish_plug(&plug);
> -	return ret;
> +	return error;
>  }
>  EXPORT_SYMBOL(mpage_writepages);
> -- 
> 2.47.2
> 
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux