fix up thinko in jbd2 revoke code
Subsystems (2)
PATCH 1/1 fix up thinko in jbd2 revoke code
This commit:
commit e898f3154d78d1520265aade0992981866d827fb
Author: Duane Griffin <[email protected]> Date: Tue Mar 25 19:47:39 2008 -0400
jbd2: tidy up revoke cache initialisation and destruction
Introduced a thinko (it doesn't check whether jbd2_revoke_record cache is null, it checks jbd2_revoke_table_cache twice).
---
fs/jbd2/revoke.c +1 -1
@@ -192,7 +192,7 @@ int __init jbd2_journal_init_revoke_caches(void) 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 && jbd2_revoke_table_cache) { +if (jbd2_revoke_record_cache && jbd2_revoke_table_cache) {return 0 ; }else {jbd2_journal_destroy_revoke_caches ();
Quoted 6 lines · James Bottomley
This commit:
commit
e898f3154d78d1520265aade0992981866d827fbAuthor: Duane Griffin <[email protected]> Date: Tue Mar 25 19:47:39 2008 -0400
Quoted 7 lines
jbd2: tidy up revoke cache initialisation and destruction
Introduced a thinko (it doesn't check whether
jbd2_revoke_recordcache is null, it checksjbd2_revoke_table_cachetwice).Signed-off-by James Bottomley <[email protected]>
Thanks, I picked this up in ext4 patch queue.
Mingming
Quoted 21 lines
---
fs/jbd2/revoke.c +1
-2@@ -192,7 +192,7 @@ int __init jbd2_journal_init_revoke_caches(void) 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 && jbd2_revoke_table_cache) { +if (jbd2_revoke_record_cache && jbd2_revoke_table_cache) {return 0 ; }else {jbd2_journal_destroy_revoke_caches (); --To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Mingming Cao
Quoted 8 lines · James Bottomley
This commit:
commit
e898f3154d78d1520265aade0992981866d827fbAuthor: Duane Griffin <[email protected]> Date: Tue Mar 25 19:47:39 2008 -0400jbd2: tidy up revoke cache initialisation and destruction
Quoted 8 lines
Quoted 5 lines
Introduced a thinko (it doesn't check whether
jbd2_revoke_recordcache is null, it checksjbd2_revoke_table_cachetwice).Signed-off-by James Bottomley <[email protected]>Signed-off-by Mingming Cao <[email protected]>Thanks, I picked this up in ext4 patch queue.
anyone care to convert this function to proper goto-based error unwinding?
Quoted 13 lines · Christoph Hellwig
Quoted 12 lines · Mingming Cao
Quoted 11 lines · James Bottomley
This commit:
commit
e898f3154d78d1520265aade0992981866d827fbAuthor: Duane Griffin <[email protected]> Date: Tue Mar 25 19:47:39 2008 -0400jbd2: tidy up revoke cache initialisation and destruction
Introduced a thinko (it doesn't check whether
jbd2_revoke_recordcache is null, it checksjbd2_revoke_table_cachetwice).
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by James Bottomley <[email protected]>Signed-off-by Mingming Cao <[email protected]>Thanks, I picked this up in ext4 patch queue.
anyone care to convert this function to proper goto-based error unwinding?
Like below. ?
Mingming,
I folded jbd2-tidy-up-revoe-cache-intialisation-and-destruction.patch jbd2-fix-up-thinko-in-jbd2-revoke-code.patch in the patch queue to this.
-aneesh
jbd2: tidy up revoke cache initialisation and destruction
From: Aneesh Kumar K.V <[email protected]>
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 the code slightly.
---
fs/jbd2/revoke.c | 36 ++++++++++++++++++++++-------------- 1 files changed, 22 insertions(+), 14 deletions(-)
fs/jbd2/revoke.c +18 -7
@@ -167,33 +167,41 @@ 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) -return -ENOMEM ; + goto record_cache_failure; 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) { -kmem_cache_destroy (jbd2_revoke_record_cache); - jbd2_revoke_record_cache =NULL ; -return -ENOMEM ; - } +if (!jbd2_revoke_table_cache) + goto table_cache_failure;return 0 ; -}