add patch mbcache-remove-unnecessary-module_get_put
[ext4-patch-queue.git] / mbcache-remove-unnecessary-module_get_put
blob187f8cfe0242675deb5f5f21a94eec85952a2bae
1 mbcache: remove unnecessary module_get/module_put
3 From: Eric Biggers <ebiggers@google.com>
5 When mbcache is built as a module, any modules that use it (ext2 and/or
6 ext4) will depend on its symbols directly, incrementing its reference
7 count.  Therefore, there is no need to do module_get/module_put.
9 Also note that since the module_get/module_put were in the mbcache
10 module itself, executing those lines of code was already dependent on
11 another reference to the mbcache module being held.
13 Signed-off-by: Eric Biggers <ebiggers@google.com>
14 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
15 Reviewed-by: Jan Kara <jack@suse.cz>
16 ---
17  fs/mbcache.c | 5 -----
18  1 file changed, 5 deletions(-)
20 diff --git a/fs/mbcache.c b/fs/mbcache.c
21 index c56ab21..07c5d7d 100644
22 --- a/fs/mbcache.c
23 +++ b/fs/mbcache.c
24 @@ -344,9 +344,6 @@ struct mb_cache *mb_cache_create(int bucket_bits)
25         int bucket_count = 1 << bucket_bits;
26         int i;
28 -       if (!try_module_get(THIS_MODULE))
29 -               return NULL;
31         cache = kzalloc(sizeof(struct mb_cache), GFP_KERNEL);
32         if (!cache)
33                 goto err_out;
34 @@ -377,7 +374,6 @@ struct mb_cache *mb_cache_create(int bucket_bits)
35         return cache;
37  err_out:
38 -       module_put(THIS_MODULE);
39         return NULL;
40  }
41  EXPORT_SYMBOL(mb_cache_create);
42 @@ -411,7 +407,6 @@ void mb_cache_destroy(struct mb_cache *cache)
43         }
44         kfree(cache->c_hash);
45         kfree(cache);
46 -       module_put(THIS_MODULE);
47  }
48  EXPORT_SYMBOL(mb_cache_destroy);
50 -- 
51 2.8.0.rc3.226.g39d4020
54 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
55 the body of a message to majordomo@vger.kernel.org
56 More majordomo info at  http://vger.kernel.org/majordomo-info.html