aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/extent_map.c16
-rw-r--r--fs/btrfs/extent_map.h2
-rw-r--r--fs/btrfs/super.c21
3 files changed, 33 insertions, 6 deletions
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index b3ff63c4bf2a..f91f28efdb59 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -42,18 +42,30 @@ struct extent_page_data {
42 struct extent_map_tree *tree; 42 struct extent_map_tree *tree;
43 get_extent_t *get_extent; 43 get_extent_t *get_extent;
44}; 44};
45 45int __init extent_map_init(void)
46void __init extent_map_init(void)
47{ 46{
48 extent_map_cache = btrfs_cache_create("extent_map", 47 extent_map_cache = btrfs_cache_create("extent_map",
49 sizeof(struct extent_map), 0, 48 sizeof(struct extent_map), 0,
50 NULL); 49 NULL);
50 if (!extent_map_cache)
51 return -ENOMEM;
51 extent_state_cache = btrfs_cache_create("extent_state", 52 extent_state_cache = btrfs_cache_create("extent_state",
52 sizeof(struct extent_state), 0, 53 sizeof(struct extent_state), 0,
53 NULL); 54 NULL);
55 if (!extent_state_cache)
56 goto free_map_cache;
54 extent_buffer_cache = btrfs_cache_create("extent_buffers", 57 extent_buffer_cache = btrfs_cache_create("extent_buffers",
55 sizeof(struct extent_buffer), 0, 58 sizeof(struct extent_buffer), 0,
56 NULL); 59 NULL);
60 if (!extent_buffer_cache)
61 goto free_state_cache;
62 return 0;
63
64free_state_cache:
65 kmem_cache_destroy(extent_state_cache);
66free_map_cache:
67 kmem_cache_destroy(extent_map_cache);
68 return -ENOMEM;
57} 69}
58 70
59void __exit extent_map_exit(void) 71void __exit extent_map_exit(void)
diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h
index fbd23a72f53b..24ddc8c93461 100644
--- a/fs/btrfs/extent_map.h
+++ b/fs/btrfs/extent_map.h
@@ -110,7 +110,7 @@ struct extent_map *alloc_extent_map(gfp_t mask);
110void free_extent_map(struct extent_map *em); 110void free_extent_map(struct extent_map *em);
111int extent_read_full_page(struct extent_map_tree *tree, struct page *page, 111int extent_read_full_page(struct extent_map_tree *tree, struct page *page,
112 get_extent_t *get_extent); 112 get_extent_t *get_extent);
113void __init extent_map_init(void); 113int __init extent_map_init(void);
114void __exit extent_map_exit(void); 114void __exit extent_map_exit(void);
115 115
116int test_range_bit(struct extent_map_tree *tree, u64 start, u64 end, 116int test_range_bit(struct extent_map_tree *tree, u64 start, u64 end,
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index c46bc3911798..ffa02872c4d6 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -347,9 +347,24 @@ static int __init init_btrfs_fs(void)
347 btrfs_init_transaction_sys(); 347 btrfs_init_transaction_sys();
348 err = btrfs_init_cachep(); 348 err = btrfs_init_cachep();
349 if (err) 349 if (err)
350 return err; 350 goto free_transaction_sys;
351 extent_map_init(); 351 err = extent_map_init();
352 return register_filesystem(&btrfs_fs_type); 352 if (err)
353 goto free_cachep;
354
355 err = register_filesystem(&btrfs_fs_type);
356 if (err)
357 goto free_extent_map;
358 return 0;
359
360free_extent_map:
361 extent_map_exit();
362free_cachep:
363 btrfs_destroy_cachep();
364free_transaction_sys:
365 btrfs_exit_transaction_sys();
366 btrfs_exit_sysfs();
367 return err;
353} 368}
354 369
355static void __exit exit_btrfs_fs(void) 370static void __exit exit_btrfs_fs(void)