]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - fs/xfs/xfs_mount.c
xfs: move mappings from cow fork to data fork after copy-write
[mirror_ubuntu-artful-kernel.git] / fs / xfs / xfs_mount.c
index 970c19ba2f560f62bc077d6797c6713848dcd5ec..a78a1164bab3d553ccfd9c5dfb2bc9edd2f738bf 100644 (file)
@@ -24,6 +24,7 @@
 #include "xfs_bit.h"
 #include "xfs_sb.h"
 #include "xfs_mount.h"
+#include "xfs_defer.h"
 #include "xfs_da_format.h"
 #include "xfs_da_btree.h"
 #include "xfs_inode.h"
@@ -41,6 +42,8 @@
 #include "xfs_trace.h"
 #include "xfs_icache.h"
 #include "xfs_sysfs.h"
+#include "xfs_rmap_btree.h"
+#include "xfs_refcount_btree.h"
 
 
 static DEFINE_MUTEX(xfs_uuid_table_mutex);
@@ -230,6 +233,8 @@ xfs_initialize_perag(
 
        if (maxagi)
                *maxagi = index;
+
+       mp->m_ag_prealloc_blocks = xfs_prealloc_blocks(mp);
        return 0;
 
 out_unwind:
@@ -679,6 +684,8 @@ xfs_mountfs(
        xfs_bmap_compute_maxlevels(mp, XFS_DATA_FORK);
        xfs_bmap_compute_maxlevels(mp, XFS_ATTR_FORK);
        xfs_ialloc_compute_maxlevels(mp);
+       xfs_rmapbt_compute_maxlevels(mp);
+       xfs_refcountbt_compute_maxlevels(mp);
 
        xfs_set_maxicount(mp);
 
@@ -917,6 +924,15 @@ xfs_mountfs(
                }
        }
 
+       /*
+        * During the second phase of log recovery, we need iget and
+        * iput to behave like they do for an active filesystem.
+        * xfs_fs_drop_inode needs to be able to prevent the deletion
+        * of inodes before we're done replaying log items on those
+        * inodes.
+        */
+       mp->m_super->s_flags |= MS_ACTIVE;
+
        /*
         * Finish recovering the file system.  This part needed to be delayed
         * until after the root and real-time bitmap inodes were consistently
@@ -928,6 +944,20 @@ xfs_mountfs(
                goto out_rtunmount;
        }
 
+       /*
+        * Now the log is fully replayed, we can transition to full read-only
+        * mode for read-only mounts. This will sync all the metadata and clean
+        * the log so that the recovery we just performed does not have to be
+        * replayed again on the next mount.
+        *
+        * We use the same quiesce mechanism as the rw->ro remount, as they are
+        * semantically identical operations.
+        */
+       if ((mp->m_flags & (XFS_MOUNT_RDONLY|XFS_MOUNT_NORECOVERY)) ==
+                                                       XFS_MOUNT_RDONLY) {
+               xfs_quiesce_attr(mp);
+       }
+
        /*
         * Complete the quota initialisation, post-log-replay component.
         */
@@ -1216,7 +1246,7 @@ xfs_mod_fdblocks(
                batch = XFS_FDBLOCKS_BATCH;
 
        __percpu_counter_add(&mp->m_fdblocks, delta, batch);
-       if (__percpu_counter_compare(&mp->m_fdblocks, XFS_ALLOC_SET_ASIDE(mp),
+       if (__percpu_counter_compare(&mp->m_fdblocks, mp->m_alloc_set_aside,
                                     XFS_FDBLOCKS_BATCH) >= 0) {
                /* we had space! */
                return 0;