aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaojun <piaojun@huawei.com>2018-04-05 19:18:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-06 00:36:22 -0400
commita17b485aae3effe2f35345dc7af4ed2070a2d949 (patch)
tree4824c4d25b12e7d3affab699f82cc74c5677b457
parentbb34f24c7d2c98d0c81838a7700e6068325b17a0 (diff)
ocfs2: remove unnecessary null pointer check before kmem_cache_destroy()
As kmem_cache_destroy() already handles null pointers, so we can remove the conditional test entirely. Link: http://lkml.kernel.org/r/5A9EB21D.3000209@huawei.com Signed-off-by: Jun Piao <piaojun@huawei.com> Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Joseph Qi <jiangqi903@gmail.com> Cc: Changwei Ge <ge.changwei@h3c.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/ocfs2/dlm/dlmlock.c3
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c15
-rw-r--r--fs/ocfs2/super.c18
-rw-r--r--fs/ocfs2/uptodate.c3
4 files changed, 13 insertions, 26 deletions
diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c
index 66c2a491f68d..74962315794e 100644
--- a/fs/ocfs2/dlm/dlmlock.c
+++ b/fs/ocfs2/dlm/dlmlock.c
@@ -77,8 +77,7 @@ int dlm_init_lock_cache(void)
77 77
78void dlm_destroy_lock_cache(void) 78void dlm_destroy_lock_cache(void)
79{ 79{
80 if (dlm_lock_cache) 80 kmem_cache_destroy(dlm_lock_cache);
81 kmem_cache_destroy(dlm_lock_cache);
82} 81}
83 82
84/* Tell us whether we can grant a new lock request. 83/* Tell us whether we can grant a new lock request.
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index a7df226f9449..03766fb41dbe 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -414,8 +414,7 @@ int dlm_init_mle_cache(void)
414 414
415void dlm_destroy_mle_cache(void) 415void dlm_destroy_mle_cache(void)
416{ 416{
417 if (dlm_mle_cache) 417 kmem_cache_destroy(dlm_mle_cache);
418 kmem_cache_destroy(dlm_mle_cache);
419} 418}
420 419
421static void dlm_mle_release(struct kref *kref) 420static void dlm_mle_release(struct kref *kref)
@@ -472,15 +471,11 @@ bail:
472 471
473void dlm_destroy_master_caches(void) 472void dlm_destroy_master_caches(void)
474{ 473{
475 if (dlm_lockname_cache) { 474 kmem_cache_destroy(dlm_lockname_cache);
476 kmem_cache_destroy(dlm_lockname_cache); 475 dlm_lockname_cache = NULL;
477 dlm_lockname_cache = NULL;
478 }
479 476
480 if (dlm_lockres_cache) { 477 kmem_cache_destroy(dlm_lockres_cache);
481 kmem_cache_destroy(dlm_lockres_cache); 478 dlm_lockres_cache = NULL;
482 dlm_lockres_cache = NULL;
483 }
484} 479}
485 480
486static void dlm_lockres_release(struct kref *kref) 481static void dlm_lockres_release(struct kref *kref)
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index e4d54d2805d6..a49b7c2bde9e 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1768,12 +1768,9 @@ static int ocfs2_initialize_mem_caches(void)
1768 NULL); 1768 NULL);
1769 if (!ocfs2_inode_cachep || !ocfs2_dquot_cachep || 1769 if (!ocfs2_inode_cachep || !ocfs2_dquot_cachep ||
1770 !ocfs2_qf_chunk_cachep) { 1770 !ocfs2_qf_chunk_cachep) {
1771 if (ocfs2_inode_cachep) 1771 kmem_cache_destroy(ocfs2_inode_cachep);
1772 kmem_cache_destroy(ocfs2_inode_cachep); 1772 kmem_cache_destroy(ocfs2_dquot_cachep);
1773 if (ocfs2_dquot_cachep) 1773 kmem_cache_destroy(ocfs2_qf_chunk_cachep);
1774 kmem_cache_destroy(ocfs2_dquot_cachep);
1775 if (ocfs2_qf_chunk_cachep)
1776 kmem_cache_destroy(ocfs2_qf_chunk_cachep);
1777 return -ENOMEM; 1774 return -ENOMEM;
1778 } 1775 }
1779 1776
@@ -1787,16 +1784,13 @@ static void ocfs2_free_mem_caches(void)
1787 * destroy cache. 1784 * destroy cache.
1788 */ 1785 */
1789 rcu_barrier(); 1786 rcu_barrier();
1790 if (ocfs2_inode_cachep) 1787 kmem_cache_destroy(ocfs2_inode_cachep);
1791 kmem_cache_destroy(ocfs2_inode_cachep);
1792 ocfs2_inode_cachep = NULL; 1788 ocfs2_inode_cachep = NULL;
1793 1789
1794 if (ocfs2_dquot_cachep) 1790 kmem_cache_destroy(ocfs2_dquot_cachep);
1795 kmem_cache_destroy(ocfs2_dquot_cachep);
1796 ocfs2_dquot_cachep = NULL; 1791 ocfs2_dquot_cachep = NULL;
1797 1792
1798 if (ocfs2_qf_chunk_cachep) 1793 kmem_cache_destroy(ocfs2_qf_chunk_cachep);
1799 kmem_cache_destroy(ocfs2_qf_chunk_cachep);
1800 ocfs2_qf_chunk_cachep = NULL; 1794 ocfs2_qf_chunk_cachep = NULL;
1801} 1795}
1802 1796
diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c
index 82e17b076ce7..78f09c76ab3c 100644
--- a/fs/ocfs2/uptodate.c
+++ b/fs/ocfs2/uptodate.c
@@ -633,6 +633,5 @@ int __init init_ocfs2_uptodate_cache(void)
633 633
634void exit_ocfs2_uptodate_cache(void) 634void exit_ocfs2_uptodate_cache(void)
635{ 635{
636 if (ocfs2_uptodate_cachep) 636 kmem_cache_destroy(ocfs2_uptodate_cachep);
637 kmem_cache_destroy(ocfs2_uptodate_cachep);
638} 637}