Btrfs: make sure we wait on logged extents when fsycning two subvols
PATCH 1/1 Btrfs: make sure we wait on logged extents when fsycning two subvols
If we have two fsync()'s race on different subvols one will do all of its work to get into the log_tree, wait on it's outstanding IO, and then allow the log_tree to finish it's commit. The problem is we were just free'ing that subvols logged extents instead of waiting on them, so whoever lost the race wouldn't really have their data on disk. Fix this by waiting properly instead of freeing the logged extents. Thanks,
--- fs/btrfs/tree-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-log.c +1 -1
@@ -2600,9 +2600,9 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,if (atomic_read (&log_root_tree->log_commit[index2])) {blk_finish_plug (&plug);btrfs_wait_marked_extents (log, &log->dirty_log_pages, mark); +btrfs_wait_logged_extents (log, log_transid);wait_log_commit (trans, log_root_tree, root_log_ctx.log_transid); -btrfs_free_logged_extents (log, log_transid);mutex_unlock (&log_root_tree->log_mutex); ret = root_log_ctx.log_ret; goto out;
Signature · 1 line
1.8.3.1
Quoted 18 lines · Josef Bacik
If we have two fsync()'s race on different subvols one will do all of its work to get into the
log_tree, wait on it's outstanding IO, and then allow thelog_treeto finish it's commit. The problem is we were just free'ing that subvols logged extents instead of waiting on them, so whoever lost the race wouldn't really have their data on disk. Fix this by waiting properly instead of freeing the logged extents. Thanks,Signed-off-by Josef Bacik <[email protected]>--- fs/btrfs/tree-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/tree-log.c +0
-0
fs/btrfs/tree-log.c int btrfs_sync_log(struct btrfs_trans_handle *trans, · line 2603
Quoted 4 lines
fs/btrfs/tree-log.c +1
-0@@ -2600,9 +2600,9 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,if (atomic_read (&log_root_tree->log_commit[index2])) {blk_finish_plug (&plug);btrfs_wait_marked_extents (log, &log->dirty_log_pages, mark); +btrfs_wait_logged_extents (log, log_transid);
Why not add this log root into a list of log root tree, and then the committer wait all ordered extents in each log root which is added in that list? By this way, we can let the committer do some work during the data of ordered extents is being transferred to the disk.
Thanks
Miao
Quoted 7 lines
fs/btrfs/tree-log.c +0
-1wait_log_commit (trans, log_root_tree, root_log_ctx.log_transid); -btrfs_free_logged_extents (log, log_transid);mutex_unlock (&log_root_tree->log_mutex); ret = root_log_ctx.log_ret; goto out;