Message ID | 20221207112722.22220-10-jack@suse.cz |
---|---|
State | Accepted |
Headers | show |
Series | ext4: Stop using ext4_writepage() for writeout of ordered data | expand |
On 22/12/07 12:27PM, Jan Kara wrote: > Instead of using generic_writepages(), let's use write_cache_pages() for > writeout of journalled data. It will allow us to stop providing > .writepage callback. Ok. Just one quick query. I didn't look too deep for this and thought will directly check it here. What about marking an error via mapping_set_error() which earlier the __writepage() call was handling in case of any error during writeback? > Our data=journal writeback path would benefit from > a larger cleanup and refactoring but that's for a separate cleanup > series. > > Reviewed-by: Christoph Hellwig <hch@lst.de> > Signed-off-by: Jan Kara <jack@suse.cz> > --- > fs/ext4/inode.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index b93a436bf5bc..f3b3792c1c96 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -2705,6 +2705,12 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) > return err; > } > > +static int ext4_writepage_cb(struct page *page, struct writeback_control *wbc, > + void *data) > +{ > + return ext4_writepage(page, wbc); > +} > + > static int ext4_do_writepages(struct mpage_da_data *mpd) > { > struct writeback_control *wbc = mpd->wbc; > @@ -2731,7 +2737,9 @@ static int ext4_do_writepages(struct mpage_da_data *mpd) > goto out_writepages; > > if (ext4_should_journal_data(inode)) { > - ret = generic_writepages(mapping, wbc); > + blk_start_plug(&plug); > + ret = write_cache_pages(mapping, wbc, ext4_writepage_cb, NULL); > + blk_finish_plug(&plug); > goto out_writepages; > } > > -- > 2.35.3 >
On Thu 08-12-22 21:10:46, Ritesh Harjani (IBM) wrote: > On 22/12/07 12:27PM, Jan Kara wrote: > > Instead of using generic_writepages(), let's use write_cache_pages() for > > writeout of journalled data. It will allow us to stop providing > > .writepage callback. > > Ok. Just one quick query. I didn't look too deep for this and thought will > directly check it here. > What about marking an error via mapping_set_error() which earlier the > __writepage() call was handling in case of any error during writeback? So yes, I have noticed we loose that call and decided we'll stay compatible (arguably bug-to-bug) with what we do for data=ordered mode. If error happens in ext4_writepage() (i.e., during adding buffers to transaction) we will propagate it back up to the ->writepages() caller. I agree we should probably tweak ext4_writepages() to also do mapping_set_error() just in case this is writeback from flush worker so that application can learn about the problem. I'll add this to the larger cleanup of our writepages path. Thanks for the comment. Honza
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index b93a436bf5bc..f3b3792c1c96 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2705,6 +2705,12 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) return err; } +static int ext4_writepage_cb(struct page *page, struct writeback_control *wbc, + void *data) +{ + return ext4_writepage(page, wbc); +} + static int ext4_do_writepages(struct mpage_da_data *mpd) { struct writeback_control *wbc = mpd->wbc; @@ -2731,7 +2737,9 @@ static int ext4_do_writepages(struct mpage_da_data *mpd) goto out_writepages; if (ext4_should_journal_data(inode)) { - ret = generic_writepages(mapping, wbc); + blk_start_plug(&plug); + ret = write_cache_pages(mapping, wbc, ext4_writepage_cb, NULL); + blk_finish_plug(&plug); goto out_writepages; }