From a885a5755ca84d8f2fda51e67b6c7aba0e2cc18a Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Wed, 16 Jan 2019 10:12:06 -0800 Subject: xfs: free COW staging extents when freezing filesystem When we're freezing the filesystem, free all the COW staging extents before we shut the log down so that we can minimize the amount of recovery work that will be necessary during the next mount. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_super.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'fs/xfs/xfs_super.c') diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index b234e484fad0..919c6f4b0c22 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1116,6 +1116,24 @@ xfs_fs_sync_fs( if (!wait) return 0; + /* + * If we're in the middle of freezing the filesystem, this is our last + * chance to run regular transactions. Clear all the COW staging + * extents so that we can freeze the filesystem with as little recovery + * work to do at the next mount as possible. It's safe to do this + * without locking inodes because the freezer code flushed all the + * dirty data from the page cache and locked out writes and page faults. + */ + if (sb->s_writers.frozen == SB_FREEZE_PAGEFAULT) { + int error; + + error = xfs_icache_free_cowblocks(mp, NULL); + if (error) { + xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); + return error; + } + } + xfs_log_force(mp, XFS_LOG_SYNC); if (laptop_mode) { /* -- cgit v1.2.3