LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Duane Griffin" <duaneg@dghda.com>
To: linux-ext4@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Theodore Tso <tytso@mit.edu>,
sct@redhat.com, akpm@linux-foundation.org, adilger@clusterfs.com,
Duane Griffin <duaneg@dghda.com>
Subject: [PATCH] jbd2: tidy up revoke cache initialisation and destruction
Date: Sat, 8 Mar 2008 18:37:37 +0000 [thread overview]
Message-ID: <1205001459-5291-5-git-send-email-duaneg@dghda.com> (raw)
In-Reply-To: <1205001459-5291-4-git-send-email-duaneg@dghda.com>
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 <duaneg@dghda.com>
---
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
next prev parent reply other threads:[~2008-03-08 18:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-08 18:37 jbd/2: eliminate code duplication and gracefully handle cache initialisation failure Duane Griffin
2008-03-08 18:37 ` [PATCH] jbd: eliminate duplicated code in revocation table init/destroy functions Duane Griffin
2008-03-08 18:37 ` [PATCH] jbd2: " Duane Griffin
2008-03-08 18:37 ` [PATCH] jbd: tidy up revoke cache initialisation and destruction Duane Griffin
2008-03-08 18:37 ` Duane Griffin [this message]
2008-03-08 18:37 ` [PATCH] jbd: handle cache initialisation failure gracefully when statically compiled in Duane Griffin
2008-03-08 18:37 ` [PATCH] jbd2: " Duane Griffin
2008-03-10 19:46 ` jbd/2: eliminate code duplication and gracefully handle cache initialisation failure Andrew Morton
2008-03-12 2:46 ` Duane Griffin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1205001459-5291-5-git-send-email-duaneg@dghda.com \
--to=duaneg@dghda.com \
--cc=adilger@clusterfs.com \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sct@redhat.com \
--cc=tytso@mit.edu \
--subject='Re: [PATCH] jbd2: tidy up revoke cache initialisation and destruction' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).