aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_mount.c
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@sandeen.net>2010-02-05 17:59:53 -0500
committerAlex Elder <aelder@sgi.com>2010-02-08 18:41:48 -0500
commitd5db0f97fbbeff11c88dec1aaf1536a975afbaeb (patch)
tree3e81db2cb8c5004f3c30ccaa35e54fbf1549897f /fs/xfs/xfs_mount.c
parent388f1f0c346b533b06d8bc792f7204ebc3e4b7da (diff)
xfs: more reserved blocks fixups
This mangles the reserved blocks counts a little more. 1) add a helper function for the default reserved count 2) add helper functions to save/restore counts on ro/rw 3) save/restore reserved blocks on freeze/thaw 4) disallow changing reserved count while readonly V2: changed field name to match Dave's changes Signed-off-by: Eric Sandeen <sandeen@sandeen.net> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_mount.c')
-rw-r--r--fs/xfs/xfs_mount.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 7f81ed72c875..5061149b2cc4 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1091,6 +1091,22 @@ xfs_mount_reset_sbqflags(
1091 return xfs_trans_commit(tp, 0); 1091 return xfs_trans_commit(tp, 0);
1092} 1092}
1093 1093
1094__uint64_t
1095xfs_default_resblks(xfs_mount_t *mp)
1096{
1097 __uint64_t resblks;
1098
1099 /*
1100 * We default to 5% or 1024 fsbs of space reserved, whichever is smaller.
1101 * This may drive us straight to ENOSPC on mount, but that implies
1102 * we were already there on the last unmount. Warn if this occurs.
1103 */
1104 resblks = mp->m_sb.sb_dblocks;
1105 do_div(resblks, 20);
1106 resblks = min_t(__uint64_t, resblks, 1024);
1107 return resblks;
1108}
1109
1094/* 1110/*
1095 * This function does the following on an initial mount of a file system: 1111 * This function does the following on an initial mount of a file system:
1096 * - reads the superblock from disk and init the mount struct 1112 * - reads the superblock from disk and init the mount struct
@@ -1401,18 +1417,14 @@ xfs_mountfs(
1401 * when at ENOSPC. This is needed for operations like create with 1417 * when at ENOSPC. This is needed for operations like create with
1402 * attr, unwritten extent conversion at ENOSPC, etc. Data allocations 1418 * attr, unwritten extent conversion at ENOSPC, etc. Data allocations
1403 * are not allowed to use this reserved space. 1419 * are not allowed to use this reserved space.
1404 *
1405 * We default to 5% or 1024 fsbs of space reserved, whichever is smaller.
1406 * This may drive us straight to ENOSPC on mount, but that implies
1407 * we were already there on the last unmount. Warn if this occurs.
1408 */ 1420 */
1409 resblks = mp->m_sb.sb_dblocks; 1421 if (!(mp->m_flags & XFS_MOUNT_RDONLY)) {
1410 do_div(resblks, 20); 1422 resblks = xfs_default_resblks(mp);
1411 resblks = min_t(__uint64_t, resblks, 1024); 1423 error = xfs_reserve_blocks(mp, &resblks, NULL);
1412 error = xfs_reserve_blocks(mp, &resblks, NULL); 1424 if (error)
1413 if (error) 1425 cmn_err(CE_WARN, "XFS: Unable to allocate reserve "
1414 cmn_err(CE_WARN, "XFS: Unable to allocate reserve blocks. " 1426 "blocks. Continuing without a reserve pool.");
1415 "Continuing without a reserve pool."); 1427 }
1416 1428
1417 return 0; 1429 return 0;
1418 1430