Skip to content

Commit e761be2

Browse files
naotakdave
authored andcommitted
btrfs: fix clear_dirty and writeback ordering in submit_one_sector()
This commit is a replay of commit 6252690 ("btrfs: fix invalid mapping of extent xarray state"). We need to call btrfs_folio_clear_dirty() before btrfs_set_range_writeback(), so that xarray DIRTY tag is cleared. With a refactoring commit 8189197 ("btrfs: refactor __extent_writepage_io() to do sector-by-sector submission"), it screwed up and the order is reversed and causing the same hang. Fix the ordering now in submit_one_sector(). Fixes: 8189197 ("btrfs: refactor __extent_writepage_io() to do sector-by-sector submission") Reviewed-by: Qu Wenruo <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent fe4cd7e commit e761be2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

fs/btrfs/extent_io.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,13 @@ static int submit_one_sector(struct btrfs_inode *inode,
13061306
free_extent_map(em);
13071307
em = NULL;
13081308

1309+
/*
1310+
* Although the PageDirty bit is cleared before entering this
1311+
* function, subpage dirty bit is not cleared.
1312+
* So clear subpage dirty bit here so next time we won't submit
1313+
* a folio for a range already written to disk.
1314+
*/
1315+
btrfs_folio_clear_dirty(fs_info, folio, filepos, sectorsize);
13091316
btrfs_set_range_writeback(inode, filepos, filepos + sectorsize - 1);
13101317
/*
13111318
* Above call should set the whole folio with writeback flag, even
@@ -1315,13 +1322,6 @@ static int submit_one_sector(struct btrfs_inode *inode,
13151322
*/
13161323
ASSERT(folio_test_writeback(folio));
13171324

1318-
/*
1319-
* Although the PageDirty bit is cleared before entering this
1320-
* function, subpage dirty bit is not cleared.
1321-
* So clear subpage dirty bit here so next time we won't submit
1322-
* folio for range already written to disk.
1323-
*/
1324-
btrfs_folio_clear_dirty(fs_info, folio, filepos, sectorsize);
13251325
submit_extent_folio(bio_ctrl, disk_bytenr, folio,
13261326
sectorsize, filepos - folio_pos(folio));
13271327
return 0;

0 commit comments

Comments
 (0)