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
--
| Amit K. Arora | [RFC] Heads up on sys_fallocate() |
| Jan Engelhardt | Re: Linux 2.6.21-rc4 |
| Alexey Dobriyan | ext2 reservations (Re: -mm merge plans for 2.6.23) |
| Linus Torvalds | Linux 2.6.27 |
git: | |
| Joakim Tjernlund | git-svn set-tree bug |
| Anatoly Yakovenko | GIT_SSL_NO_VERIFY=1 over http doesn't ignore a different ip address for the signed... |
| Benoit Sigoure | Re: Rebase/cherry-picking idea |
| Sam Song | Fwd: [OT] Re: Git via a proxy server? |
| Theo de Raadt | That whole "Linux stealing our code" thing |
| Richard Stallman | Re: Real men don't attack straw men |
| Marcos Laufer | dmesg IBM x3650 OpenBSD 4.3 |
| Richard Stallman | Real men don't attack straw men |
| Marcel Holtmann | Bluetooth fixes for 2.6.27 |
| Linus Torvalds | Re: tcp bw in 2.6 |
| Theodore Tso | Re: [bug?] tg3: Failed to load firmware "tigon/tg3_tso.bin" |
| Johannes Berg | Re: [PATCH] mac80211: rewrite fragmentation code |
| How to make my PCIE ATA storage device running in Linux | 2 hours ago | Linux general |
| sata/ide timeout errors on asus server-mb | 5 hours ago | Linux kernel |
| Shared swap partition | 6 hours ago | Linux general |
| usb mic not detected | 10 hours ago | Applications and Utilities |
| Problem in Inserting a module | 11 hours ago | Linux kernel |
| Treason Uncloaked | 16 hours ago | Linux kernel |
| high memory | 2 days ago | Linux kernel |
| semaphore access speed | 3 days ago | Applications and Utilities |
| the kernel how to power off the machine | 3 days ago | Linux kernel |
| Easter Eggs in windows XP | 3 days ago | Windows |
