xfs: more reserved blocks fixups
[linux-2.6-block.git] / fs / xfs / linux-2.6 / xfs_super.c
index e9c21454b9e261b6384f489237466558ab54b210..6ce828e0e17b3418799b2c12e94082f0c562f5e6 100644 (file)
@@ -1256,6 +1256,29 @@ xfs_fs_statfs(
        return 0;
 }
 
+STATIC void
+xfs_save_resvblks(struct xfs_mount *mp)
+{
+       __uint64_t resblks = 0;
+
+       mp->m_resblks_save = mp->m_resblks;
+       xfs_reserve_blocks(mp, &resblks, NULL);
+}
+
+STATIC void
+xfs_restore_resvblks(struct xfs_mount *mp)
+{
+       __uint64_t resblks;
+
+       if (mp->m_resblks_save) {
+               resblks = mp->m_resblks_save;
+               mp->m_resblks_save = 0;
+       } else
+               resblks = xfs_default_resblks(mp);
+
+       xfs_reserve_blocks(mp, &resblks, NULL);
+}
+
 STATIC int
 xfs_fs_remount(
        struct super_block      *sb,
@@ -1318,8 +1341,6 @@ xfs_fs_remount(
 
        /* ro -> rw */
        if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
-               __uint64_t resblks;
-
                mp->m_flags &= ~XFS_MOUNT_RDONLY;
                if (mp->m_flags & XFS_MOUNT_BARRIER)
                        xfs_mountfs_check_barriers(mp);
@@ -1342,15 +1363,7 @@ xfs_fs_remount(
                 * Fill out the reserve pool if it is empty. Use the stashed
                 * value if it is non-zero, otherwise go with the default.
                 */
-               if (mp->m_resblks_save) {
-                       resblks = mp->m_resblks_save;
-                       mp->m_resblks_save = 0;
-               } else {
-                       resblks = mp->m_sb.sb_dblocks;
-                       do_div(resblks, 20);
-                       resblks = min_t(__uint64_t, resblks, 1024);
-               }
-               xfs_reserve_blocks(mp, &resblks, NULL);
+               xfs_restore_resvblks(mp);
        }
 
        /* rw -> ro */
@@ -1363,11 +1376,9 @@ xfs_fs_remount(
                 * so that if we get remounted rw, we can return it to the same
                 * size.
                 */
-               __uint64_t resblks = 0;
 
                xfs_quiesce_data(mp);
-               mp->m_resblks_save = mp->m_resblks;
-               xfs_reserve_blocks(mp, &resblks, NULL);
+               xfs_save_resvblks(mp);
                xfs_quiesce_attr(mp);
                mp->m_flags |= XFS_MOUNT_RDONLY;
        }
@@ -1386,10 +1397,21 @@ xfs_fs_freeze(
 {
        struct xfs_mount        *mp = XFS_M(sb);
 
+       xfs_save_resvblks(mp);
        xfs_quiesce_attr(mp);
        return -xfs_fs_log_dummy(mp);
 }
 
+STATIC int
+xfs_fs_unfreeze(
+       struct super_block      *sb)
+{
+       struct xfs_mount        *mp = XFS_M(sb);
+
+       xfs_restore_resvblks(mp);
+       return 0;
+}
+
 STATIC int
 xfs_fs_show_options(
        struct seq_file         *m,
@@ -1612,6 +1634,7 @@ static const struct super_operations xfs_super_operations = {
        .put_super              = xfs_fs_put_super,
        .sync_fs                = xfs_fs_sync_fs,
        .freeze_fs              = xfs_fs_freeze,
+       .unfreeze_fs            = xfs_fs_unfreeze,
        .statfs                 = xfs_fs_statfs,
        .remount_fs             = xfs_fs_remount,
        .show_options           = xfs_fs_show_options,