Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759061AbYCHSj0 (ORCPT ); Sat, 8 Mar 2008 13:39:26 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757287AbYCHSh5 (ORCPT ); Sat, 8 Mar 2008 13:37:57 -0500 Received: from kumera.dghda.com ([80.68.90.171]:2250 "EHLO kumera.dghda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757218AbYCHShz (ORCPT ); Sat, 8 Mar 2008 13:37:55 -0500 From: "Duane Griffin" To: linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Theodore Tso , sct@redhat.com, akpm@linux-foundation.org, adilger@clusterfs.com, Duane Griffin Subject: [PATCH] jbd2: tidy up revoke cache initialisation and destruction Date: Sat, 8 Mar 2008 18:37:37 +0000 Message-Id: <1205001459-5291-5-git-send-email-duaneg@dghda.com> X-Mailer: git-send-email 1.5.3.7 In-Reply-To: <1205001459-5291-4-git-send-email-duaneg@dghda.com> References: <1205001459-5291-1-git-send-email-duaneg@dghda.com> <1205001459-5291-2-git-send-email-duaneg@dghda.com> <1205001459-5291-3-git-send-email-duaneg@dghda.com> <1205001459-5291-4-git-send-email-duaneg@dghda.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2282 Lines: 75 Make revocation cache destruction safe to call if initialisation fails partially or entirely. This allows it to be used to cleanup in the case of initialisation failure, simplifying that code slightly. Signed-off-by: Duane Griffin --- fs/jbd2/revoke.c | 35 ++++++++++++++++++++--------------- 1 files changed, 20 insertions(+), 15 deletions(-) diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c index 07e4703..5a020f1 100644 --- a/fs/jbd2/revoke.c +++ b/fs/jbd2/revoke.c @@ -167,33 +167,38 @@ static struct jbd2_revoke_record_s *find_revoke_record(journal_t *journal, return NULL; } +void jbd2_journal_destroy_revoke_caches(void) +{ + if (jbd2_revoke_record_cache) { + kmem_cache_destroy(jbd2_revoke_record_cache); + jbd2_revoke_record_cache = NULL; + } + if (jbd2_revoke_table_cache) { + kmem_cache_destroy(jbd2_revoke_table_cache); + jbd2_revoke_table_cache = NULL; + } +} + int __init jbd2_journal_init_revoke_caches(void) { + J_ASSERT(!jbd2_revoke_record_cache); + J_ASSERT(!jbd2_revoke_table_cache); + jbd2_revoke_record_cache = kmem_cache_create("jbd2_revoke_record", sizeof(struct jbd2_revoke_record_s), 0, SLAB_HWCACHE_ALIGN|SLAB_TEMPORARY, NULL); - if (jbd2_revoke_record_cache == 0) - return -ENOMEM; - jbd2_revoke_table_cache = kmem_cache_create("jbd2_revoke_table", sizeof(struct jbd2_revoke_table_s), 0, SLAB_TEMPORARY, NULL); - if (jbd2_revoke_table_cache == 0) { - kmem_cache_destroy(jbd2_revoke_record_cache); - jbd2_revoke_record_cache = NULL; + + if (jbd2_revoke_table_cache && jbd2_revoke_table_cache) { + return 0; + } else { + jbd2_journal_destroy_revoke_caches(); return -ENOMEM; } - return 0; -} - -void jbd2_journal_destroy_revoke_caches(void) -{ - kmem_cache_destroy(jbd2_revoke_record_cache); - jbd2_revoke_record_cache = NULL; - kmem_cache_destroy(jbd2_revoke_table_cache); - jbd2_revoke_table_cache = NULL; } static struct jbd2_revoke_table_s *jbd2_journal_init_revoke_table(int hash_size) -- 1.5.3.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/