Merge tag 'xfs-5.19-for-linus-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[sfrench/cifs-2.6.git] / fs / xfs / xfs_super.c
index a276b8111f636b72415dcb8262579c04c8ec8bbe..ed18160e6181cf4a5c1373f9e1ccaa65ee93d07e 100644 (file)
@@ -38,6 +38,8 @@
 #include "xfs_pwork.h"
 #include "xfs_ag.h"
 #include "xfs_defer.h"
+#include "xfs_attr_item.h"
+#include "xfs_xattr.h"
 
 #include <linux/magic.h>
 #include <linux/fs_context.h>
@@ -843,9 +845,11 @@ xfs_fs_statfs(
 
        if (XFS_IS_REALTIME_MOUNT(mp) &&
            (ip->i_diflags & (XFS_DIFLAG_RTINHERIT | XFS_DIFLAG_REALTIME))) {
+               s64     freertx;
+
                statp->f_blocks = sbp->sb_rblocks;
-               statp->f_bavail = statp->f_bfree =
-                       sbp->sb_frextents * sbp->sb_rextsize;
+               freertx = percpu_counter_sum_positive(&mp->m_frextents);
+               statp->f_bavail = statp->f_bfree = freertx * sbp->sb_rextsize;
        }
 
        return 0;
@@ -1015,8 +1019,14 @@ xfs_init_percpu_counters(
        if (error)
                goto free_fdblocks;
 
+       error = percpu_counter_init(&mp->m_frextents, 0, GFP_KERNEL);
+       if (error)
+               goto free_delalloc;
+
        return 0;
 
+free_delalloc:
+       percpu_counter_destroy(&mp->m_delalloc_blks);
 free_fdblocks:
        percpu_counter_destroy(&mp->m_fdblocks);
 free_ifree:
@@ -1033,6 +1043,7 @@ xfs_reinit_percpu_counters(
        percpu_counter_set(&mp->m_icount, mp->m_sb.sb_icount);
        percpu_counter_set(&mp->m_ifree, mp->m_sb.sb_ifree);
        percpu_counter_set(&mp->m_fdblocks, mp->m_sb.sb_fdblocks);
+       percpu_counter_set(&mp->m_frextents, mp->m_sb.sb_frextents);
 }
 
 static void
@@ -1045,6 +1056,7 @@ xfs_destroy_percpu_counters(
        ASSERT(xfs_is_shutdown(mp) ||
               percpu_counter_sum(&mp->m_delalloc_blks) == 0);
        percpu_counter_destroy(&mp->m_delalloc_blks);
+       percpu_counter_destroy(&mp->m_frextents);
 }
 
 static int
@@ -1635,6 +1647,10 @@ xfs_fs_fill_super(
                goto out_filestream_unmount;
        }
 
+       if (xfs_has_large_extent_counts(mp))
+               xfs_warn(mp,
+       "EXPERIMENTAL Large extent counts feature in use. Use at your own risk!");
+
        error = xfs_mountfs(mp);
        if (error)
                goto out_filestream_unmount;
@@ -2065,8 +2081,24 @@ xfs_init_caches(void)
        if (!xfs_bui_cache)
                goto out_destroy_bud_cache;
 
+       xfs_attrd_cache = kmem_cache_create("xfs_attrd_item",
+                                           sizeof(struct xfs_attrd_log_item),
+                                           0, 0, NULL);
+       if (!xfs_attrd_cache)
+               goto out_destroy_bui_cache;
+
+       xfs_attri_cache = kmem_cache_create("xfs_attri_item",
+                                           sizeof(struct xfs_attri_log_item),
+                                           0, 0, NULL);
+       if (!xfs_attri_cache)
+               goto out_destroy_attrd_cache;
+
        return 0;
 
+ out_destroy_attrd_cache:
+       kmem_cache_destroy(xfs_attrd_cache);
+ out_destroy_bui_cache:
+       kmem_cache_destroy(xfs_bui_cache);
  out_destroy_bud_cache:
        kmem_cache_destroy(xfs_bud_cache);
  out_destroy_cui_cache:
@@ -2113,6 +2145,8 @@ xfs_destroy_caches(void)
         * destroy caches.
         */
        rcu_barrier();
+       kmem_cache_destroy(xfs_attri_cache);
+       kmem_cache_destroy(xfs_attrd_cache);
        kmem_cache_destroy(xfs_bui_cache);
        kmem_cache_destroy(xfs_bud_cache);
        kmem_cache_destroy(xfs_cui_cache);