summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-03-18 16:23:09 -0700
committerDarrick J. Wong <djwong@kernel.org>2021-03-25 17:08:55 -0700
commitc55285a74e5daf0b95dda6f3881e54076521d477 (patch)
tree9cf6522a7f68fd3ea69964ea12f2e07f86f6dc37
parent8b1498533cb77f0625f460963cc090d2a7207173 (diff)
xfs: refactor making a filesystem writable
Refactor all the expensive work we do to make a filesystem writable, such as cleaning COW extents and making per-AG reservations. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r--fs/xfs/xfs_fsops.c18
-rw-r--r--fs/xfs/xfs_fsops.h1
-rw-r--r--fs/xfs/xfs_mount.c12
-rw-r--r--fs/xfs/xfs_super.c12
4 files changed, 22 insertions, 21 deletions
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index f6897caef12c..83c8258e468e 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -22,6 +22,7 @@
#include "xfs_inode.h"
#include "xfs_icache.h"
#include "xfs_rtalloc.h"
+#include "xfs_reflink.h"
/*
* growfs operations
@@ -555,6 +556,23 @@ xfs_fs_reserve_ag_blocks(
return error;
}
+/* Do all the work required to make the filesystem writable. */
+int
+xfs_fs_make_writable(
+ struct xfs_mount *mp)
+{
+ int error;
+
+ error = xfs_reflink_recover_cow(mp);
+ if (error)
+ return error;
+
+ error = xfs_fs_reserve_ag_blocks(mp);
+ if (error == -ENOSPC)
+ return 0;
+ return error;
+}
+
/*
* Free space reserved for per-AG metadata.
*/
diff --git a/fs/xfs/xfs_fsops.h b/fs/xfs/xfs_fsops.h
index 2cffe51a31e8..4a90141fbf74 100644
--- a/fs/xfs/xfs_fsops.h
+++ b/fs/xfs/xfs_fsops.h
@@ -15,5 +15,6 @@ extern int xfs_fs_goingdown(xfs_mount_t *mp, uint32_t inflags);
extern int xfs_fs_reserve_ag_blocks(struct xfs_mount *mp);
extern int xfs_fs_unreserve_ag_blocks(struct xfs_mount *mp);
+int xfs_fs_make_writable(struct xfs_mount *mp);
#endif /* __XFS_FSOPS_H__ */
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index b2838f2ad8c8..a711c621f163 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1079,25 +1079,15 @@ xfs_mountfs(
xfs_warn(mp,
"Unable to allocate reserve blocks. Continuing without reserve pool.");
- /* Recover any CoW blocks that never got remapped. */
- error = xfs_reflink_recover_cow(mp);
+ error = xfs_fs_make_writable(mp);
if (error) {
- xfs_err(mp,
- "Error %d recovering leftover CoW allocations.", error);
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
goto out_quota;
}
-
- /* Reserve AG blocks for future btree expansion. */
- error = xfs_fs_reserve_ag_blocks(mp);
- if (error && error != -ENOSPC)
- goto out_agresv;
}
return 0;
- out_agresv:
- xfs_fs_unreserve_ag_blocks(mp);
out_quota:
xfs_qm_unmount_quotas(mp);
out_rtunmount:
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 0ac13183524f..63f57d34f1ed 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1791,21 +1791,13 @@ xfs_remount_rw(
xfs_restore_resvblks(mp);
xfs_log_work_queue(mp);
- /* Recover any CoW blocks that never got remapped. */
- error = xfs_reflink_recover_cow(mp);
+ error = xfs_fs_make_writable(mp);
if (error) {
- xfs_err(mp,
- "Error %d recovering leftover CoW allocations.", error);
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
return error;
}
- xfs_blockgc_start(mp);
-
- /* Create the per-AG metadata reservation pool .*/
- error = xfs_fs_reserve_ag_blocks(mp);
- if (error && error != -ENOSPC)
- return error;
+ xfs_blockgc_start(mp);
return 0;
}