fs: wait for partially frozen filesystems
authorDarrick J. Wong <djwong@kernel.org>
Mon, 17 Jul 2023 16:00:10 +0000 (09:00 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 17 Jul 2023 16:06:37 +0000 (09:06 -0700)
commit59ba4fdd2d1f9dd7af98f5168c846150c9aec56d
tree648585b7901bf0340b1ca1016f117b9db2efd6b7
parent880b9577855edddda1e732748e849c63199d489b
fs: wait for partially frozen filesystems

Jan Kara suggested that when one thread is in the middle of freezing a
filesystem, another thread trying to freeze the same fs but with a
different freeze_holder should wait until the freezer reaches either end
state (UNFROZEN or COMPLETE) instead of returning EBUSY immediately.

Neither caller can do anything sensible with this race other than retry
but they cannot really distinguish EBUSY as in "some other holder of the
same type has the sb already frozen" from "freezing raced with holder of
a different type".

Plumb in the extra code needed to wait for the fs freezer to reach an
end state and try the freeze again.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
fs/super.c