]> git.hungrycats.org Git - linux/commitdiff
btrfs: Fix slab accounting flags
authorNikolay Borisov <n.borisov.lkml@gmail.com>
Thu, 23 Jun 2016 18:17:08 +0000 (21:17 +0300)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Wed, 17 Aug 2016 02:33:56 +0000 (22:33 -0400)
BTRFS is using a variety of slab caches to satisfy internal needs.
Those slab caches are always allocated with the SLAB_RECLAIM_ACCOUNT,
meaning allocations from the caches are going to be accounted as
SReclaimable. At the same time btrfs is not registering any shrinkers
whatsoever, thus preventing memory from the slabs to be shrunk. This
means those caches are not in fact reclaimable.

To fix this remove the SLAB_RECLAIM_ACCOUNT on all caches apart from the
inode cache, since this one is being freed by the generic VFS super_block
shrinker. Also set the transaction related caches as SLAB_TEMPORARY,
to better document the lifetime of the objects (it just translates
to SLAB_RECLAIM_ACCOUNT).

Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit fba4b697710eb2a4bee456b9d39e9239c66f8bee)

fs/btrfs/backref.c
fs/btrfs/delayed-inode.c
fs/btrfs/delayed-ref.c
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c
fs/btrfs/extent_map.c
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ordered-data.c

index eb90c6c20e3c6a46fb1e63fd29c7c5471dc565b5..a74efcf47c882f8948add6b34ba49a5a8156415c 100644 (file)
@@ -399,7 +399,7 @@ int __init btrfs_prelim_ref_init(void)
        btrfs_prelim_ref_cache = kmem_cache_create("btrfs_prelim_ref",
                                        sizeof(struct __prelim_ref),
                                        0,
-                                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
+                                       SLAB_MEM_SPREAD,
                                        NULL);
        if (!btrfs_prelim_ref_cache)
                return -ENOMEM;
index b57daa895cea8340fd7b3ed491bb730196b6b5e6..dd36400ef8f89a97adfe1926b1eabaa4936ecbcd 100644 (file)
@@ -34,7 +34,7 @@ int __init btrfs_delayed_inode_init(void)
        delayed_node_cache = kmem_cache_create("btrfs_delayed_node",
                                        sizeof(struct btrfs_delayed_node),
                                        0,
-                                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
+                                       SLAB_MEM_SPREAD,
                                        NULL);
        if (!delayed_node_cache)
                return -ENOMEM;
index 914ac13bd92f2e34fd973d2e6da02708a7daa5d8..14cea30e2d5ce4aae38f008dff6377f8f031c6a5 100644 (file)
@@ -944,28 +944,28 @@ int btrfs_delayed_ref_init(void)
        btrfs_delayed_ref_head_cachep = kmem_cache_create(
                                "btrfs_delayed_ref_head",
                                sizeof(struct btrfs_delayed_ref_head), 0,
-                               SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+                               SLAB_MEM_SPREAD, NULL);
        if (!btrfs_delayed_ref_head_cachep)
                goto fail;
 
        btrfs_delayed_tree_ref_cachep = kmem_cache_create(
                                "btrfs_delayed_tree_ref",
                                sizeof(struct btrfs_delayed_tree_ref), 0,
-                               SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+                               SLAB_MEM_SPREAD, NULL);
        if (!btrfs_delayed_tree_ref_cachep)
                goto fail;
 
        btrfs_delayed_data_ref_cachep = kmem_cache_create(
                                "btrfs_delayed_data_ref",
                                sizeof(struct btrfs_delayed_data_ref), 0,
-                               SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+                               SLAB_MEM_SPREAD, NULL);
        if (!btrfs_delayed_data_ref_cachep)
                goto fail;
 
        btrfs_delayed_extent_op_cachep = kmem_cache_create(
                                "btrfs_delayed_extent_op",
                                sizeof(struct btrfs_delayed_extent_op), 0,
-                               SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+                               SLAB_MEM_SPREAD, NULL);
        if (!btrfs_delayed_extent_op_cachep)
                goto fail;
 
index 40d6e8861b80111a3f2e24881120a03c8693b232..93189c2a5d72d9d4a9b54682f3d74b812e625577 100644 (file)
@@ -101,7 +101,7 @@ int __init btrfs_end_io_wq_init(void)
        btrfs_end_io_wq_cache = kmem_cache_create("btrfs_end_io_wq",
                                        sizeof(struct btrfs_end_io_wq),
                                        0,
-                                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
+                                       SLAB_MEM_SPREAD,
                                        NULL);
        if (!btrfs_end_io_wq_cache)
                return -ENOMEM;
index f07a5db2c66c5b8e210ea33a5458b683a0744ce3..0f4a11a2280bf95a86fd7d590fd7ebb51f4844bb 100644 (file)
@@ -164,13 +164,13 @@ int __init extent_io_init(void)
 {
        extent_state_cache = kmem_cache_create("btrfs_extent_state",
                        sizeof(struct extent_state), 0,
-                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+                       SLAB_MEM_SPREAD, NULL);
        if (!extent_state_cache)
                return -ENOMEM;
 
        extent_buffer_cache = kmem_cache_create("btrfs_extent_buffer",
                        sizeof(struct extent_buffer), 0,
-                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+                       SLAB_MEM_SPREAD, NULL);
        if (!extent_buffer_cache)
                goto free_state_cache;
 
index 84fb56d5c018dbfea2a4b1970e4275ada5daa0fb..1539d47dc8a928d3930e612014a2ed9da5c85d97 100644 (file)
@@ -12,7 +12,7 @@ int __init extent_map_init(void)
 {
        extent_map_cache = kmem_cache_create("btrfs_extent_map",
                        sizeof(struct extent_map), 0,
-                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+                       SLAB_MEM_SPREAD, NULL);
        if (!extent_map_cache)
                return -ENOMEM;
        return 0;
index d0aadefa2afd1b3f8bca83844718eff0e6e9026d..b8d9d3f5a7a80335ba9d917a920637027a3943ba 100644 (file)
@@ -2956,7 +2956,7 @@ int btrfs_auto_defrag_init(void)
 {
        btrfs_inode_defrag_cachep = kmem_cache_create("btrfs_inode_defrag",
                                        sizeof(struct inode_defrag), 0,
-                                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
+                                       SLAB_MEM_SPREAD,
                                        NULL);
        if (!btrfs_inode_defrag_cachep)
                return -ENOMEM;
index 606bb25679e6f5ce0866bce97f88ee7c42de1d1e..a39eaa894ddd2ac2de07819355615be8813b30ac 100644 (file)
@@ -9306,25 +9306,25 @@ int btrfs_init_cachep(void)
 
        btrfs_trans_handle_cachep = kmem_cache_create("btrfs_trans_handle",
                        sizeof(struct btrfs_trans_handle), 0,
-                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+                       SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL);
        if (!btrfs_trans_handle_cachep)
                goto fail;
 
        btrfs_transaction_cachep = kmem_cache_create("btrfs_transaction",
                        sizeof(struct btrfs_transaction), 0,
-                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+                       SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL);
        if (!btrfs_transaction_cachep)
                goto fail;
 
        btrfs_path_cachep = kmem_cache_create("btrfs_path",
                        sizeof(struct btrfs_path), 0,
-                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+                       SLAB_MEM_SPREAD, NULL);
        if (!btrfs_path_cachep)
                goto fail;
 
        btrfs_free_space_cachep = kmem_cache_create("btrfs_free_space",
                        sizeof(struct btrfs_free_space), 0,
-                       SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+                       SLAB_MEM_SPREAD, NULL);
        if (!btrfs_free_space_cachep)
                goto fail;
 
index 6ec79cebf357e2a9d7c65034a926da565479d8be..794d4bb43e0f018c5c49f3a596b1c75374892112 100644 (file)
@@ -1105,7 +1105,7 @@ int __init ordered_data_init(void)
 {
        btrfs_ordered_extent_cache = kmem_cache_create("btrfs_ordered_extent",
                                     sizeof(struct btrfs_ordered_extent), 0,
-                                    SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD,
+                                    SLAB_MEM_SPREAD,
                                     NULL);
        if (!btrfs_ordered_extent_cache)
                return -ENOMEM;