login
Header Space

 
 

Re: [PATCH 1/3] jbd2: eliminate duplicated code in revocation table init/destroy functions

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Duane Griffin <duaneg@...>
Cc: <linux-ext4@...>, <linux-kernel@...>, Theodore Tso <tytso@...>, <sct@...>, <akpm@...>, <adilger@...>
Date: Friday, March 7, 2008 - 5:52 pm

On Mar 07, 2008  01:31 +0000, Duane Griffin wrote:

Duane, thanks for doing the cleanup.  Comments inline.


(minor) calling this "hash_size" would be a bit clearer, and more consistent
with the old code.  Not a reason in itself to redo the patch though.


(style) could fit on a single line by removing one space somewhere, or follow
code style and move only "GFP_KERNEL" to the second line...


(style) it is preferred to indent continuation lines to the previous '(' like:

	journal->j_revoke_table[0] = kmem_cache_alloc(jbd2_revoke_table_cache,
						      GFP_KERNEL);

or alternately:

	journal->j_revoke_table[0] =
		kmem_cache_alloc(jbd2_revoke_table_cache, GFP_KERNEL);


(style) wrap at 80 columns.


(minor) It appears we could reduce some more code duplication by doing
the allocation of j_revoke_table[0] and j_revoke_table[1] inside
journal_init_revoke_table(), passing back the table pointer or NULL on
failure (-ENOMEM is really the only possible error return code here)?


Doing the table allocation inside journal_init_revoke_table() also
simplifies cleanup, because we don't need to handle "init" and "alloc"
failures separately here.


(minor) This should be moved above journal_init_revoke_table() and be used
to free the first table if allocation/init of the second table fails.
That is proper encapsulation of functionality, and by moving the table
allocation inside journal_init_revoke_table() as previously suggested,
we never have to handle partially-initialized tables (i.e. alloc, but
list_heads not init.

Sure, it is a bit more overhead than just freeing the arrays, but
performance isn't critical if the mount just failed due to ENOMEM,
and isn't expected to happen very often at all.


(style) empty line here.


(style) I'd probably write this as below, to keep the logic simpler:

	journal->j_revoke = NULL;

	if (journal->j_revoke_table[0])
		jbd2_journal_destroy_revoke_table(journal->j_revoke_table[0]);
	if (journal->j_revoke_table[1])
		jbd2_journal_destroy_revoke_table(journal->j_revoke_table[1]);

Also, we don't really need to set journal->j_revoke = NULL twice.

Same of course applies to both versions of the patch.  Hopefully once ext4
has had some chance to bake in the kernel (when people start using it after
the "dev" moniker is removed) and Fedora we can revert back to a single jbd
code base.  There are no incompatible format changes in jbd2 that would be
forced upon ext3 by consolidating the code base, it was just split during
development to avoid destabilizing ext3.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 1/3] jbd2: eliminate duplicated code in revocatio..., Andreas Dilger, (Fri Mar 7, 5:52 pm)
speck-geostationary