Skip to content

RFC fs: fully sync all fsese even for an emergency sync

Qu Wenruo linux-btrfs linux-fsdevel 1 version Applied

Status from this message: Applied to the vfs-6.19.misc branch of the vfs/vfs.git tree.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 15 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2fs: do not pass a parameter for sync_inodes_one_sb()fs/sync.c+2 -23 replies
2/2fs: fully sync all fses even for an emergency syncfs/sync.c+2 -110 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH RFC 0/2] fs: fully sync all fsese even for an emergency sync

The first patch is a cleanup related to sync_inodes_one_sb() callback. Since it always wait for the writeback, there is no need to pass any parameter for it.

The second patch is a fix mostly affecting btrfs, as btrfs requires a explicit sync_fc() call with wait == 1, to commit its super blocks, and sync_bdevs() won't cut it at all.

However the current emergency sync never passes wait == 1, it means btrfs will writeback all dirty data and metadata, but still no super block update, resulting everything still pointing back to the old data/metadata.

This lead to a problem where btrfs doesn't seem to do anything during emergency sync.

The second patch fixes the problem by passing wait == 1 for the second iteration of sync_fs_one_sb().

[REASON FOR RFC]
I am not sure which way should I fix the bug.

I can definitely put btrfs to ignore the @wait parameter and always do transaction commit, that will definitely fix the bug, but btrfs will do two transaction commits for emergency sync.
Which may or may not be a problem for emergency sync itself, but will definitely cause a lot of unnessary small transactions during regular sync_fs() calls and degrade the peroformance.

On the other hand, I also didn't see why we can not follow the common pattern inside emergency_sync(), all other call sites are syncing the fs first with nowait, then wait.
(E.g. sync_filesyastem() and ksys_sync()).

I know it's an emergency sync thus we don't want to wait, but please also remember that sync_inodes_one_sb() is always waiting, and I'm pretty sure we spend most of the time inside sync_inodes_one_sb(), thus it looks more sane to fix the only exception inside fs/sync.c.

Qu Wenruo (2):
fs: do not pass a parameter for sync_inodes_one_sb()
fs: fully sync all fses even for an emergency sync

 fs/sync.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.51.2