Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 95047
b: refs/heads/master
c: 83c4952
h: refs/heads/master
i:
  95045: bfdf5c9
  95043: 904c5ac
  95039: 60b5564
v: v3
  • Loading branch information
Duane Griffin authored and Theodore Ts'o committed Apr 17, 2008
1 parent 4b10941 commit 4e67b4a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 77 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9fa27c85de57d38ca698f4e34fdd1ab06b6c8e49
refs/heads/master: 83c49523c91fff10493f5b3c102063b02ab76907
127 changes: 51 additions & 76 deletions trunk/fs/jbd2/revoke.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,109 +204,84 @@ int __init jbd2_journal_init_revoke_caches(void)
return -ENOMEM;
}

/* Initialise the revoke table for a given journal to a given size. */

int jbd2_journal_init_revoke(journal_t *journal, int hash_size)
static struct jbd2_revoke_table_s *jbd2_journal_init_revoke_table(int hash_size)
{
int shift, tmp;
int shift = 0;
int tmp = hash_size;
struct jbd2_revoke_table_s *table;

J_ASSERT (journal->j_revoke_table[0] == NULL);
table = kmem_cache_alloc(jbd2_revoke_table_cache, GFP_KERNEL);
if (!table)
goto out;

shift = 0;
tmp = hash_size;
while((tmp >>= 1UL) != 0UL)
shift++;

journal->j_revoke_table[0] = kmem_cache_alloc(jbd2_revoke_table_cache, GFP_KERNEL);
if (!journal->j_revoke_table[0])
return -ENOMEM;
journal->j_revoke = journal->j_revoke_table[0];

/* Check that the hash_size is a power of two */
J_ASSERT(is_power_of_2(hash_size));

journal->j_revoke->hash_size = hash_size;

journal->j_revoke->hash_shift = shift;

journal->j_revoke->hash_table =
table->hash_size = hash_size;
table->hash_shift = shift;
table->hash_table =
kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL);
if (!journal->j_revoke->hash_table) {
kmem_cache_free(jbd2_revoke_table_cache, journal->j_revoke_table[0]);
journal->j_revoke = NULL;
return -ENOMEM;
if (!table->hash_table) {
kmem_cache_free(jbd2_revoke_table_cache, table);
table = NULL;
goto out;
}

for (tmp = 0; tmp < hash_size; tmp++)
INIT_LIST_HEAD(&journal->j_revoke->hash_table[tmp]);
INIT_LIST_HEAD(&table->hash_table[tmp]);

journal->j_revoke_table[1] = kmem_cache_alloc(jbd2_revoke_table_cache, GFP_KERNEL);
if (!journal->j_revoke_table[1]) {
kfree(journal->j_revoke_table[0]->hash_table);
kmem_cache_free(jbd2_revoke_table_cache, journal->j_revoke_table[0]);
return -ENOMEM;
out:
return table;
}

static void jbd2_journal_destroy_revoke_table(struct jbd2_revoke_table_s *table)
{
int i;
struct list_head *hash_list;

for (i = 0; i < table->hash_size; i++) {
hash_list = &table->hash_table[i];
J_ASSERT(list_empty(hash_list));
}

journal->j_revoke = journal->j_revoke_table[1];
kfree(table->hash_table);
kmem_cache_free(jbd2_revoke_table_cache, table);
}

/* Check that the hash_size is a power of two */
/* Initialise the revoke table for a given journal to a given size. */
int jbd2_journal_init_revoke(journal_t *journal, int hash_size)
{
J_ASSERT(journal->j_revoke_table[0] == NULL);
J_ASSERT(is_power_of_2(hash_size));

journal->j_revoke->hash_size = hash_size;
journal->j_revoke_table[0] = jbd2_journal_init_revoke_table(hash_size);
if (!journal->j_revoke_table[0])
goto fail0;

journal->j_revoke->hash_shift = shift;
journal->j_revoke_table[1] = jbd2_journal_init_revoke_table(hash_size);
if (!journal->j_revoke_table[1])
goto fail1;

journal->j_revoke->hash_table =
kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL);
if (!journal->j_revoke->hash_table) {
kfree(journal->j_revoke_table[0]->hash_table);
kmem_cache_free(jbd2_revoke_table_cache, journal->j_revoke_table[0]);
kmem_cache_free(jbd2_revoke_table_cache, journal->j_revoke_table[1]);
journal->j_revoke = NULL;
return -ENOMEM;
}

for (tmp = 0; tmp < hash_size; tmp++)
INIT_LIST_HEAD(&journal->j_revoke->hash_table[tmp]);
journal->j_revoke = journal->j_revoke_table[1];

spin_lock_init(&journal->j_revoke_lock);

return 0;
}

/* Destoy a journal's revoke table. The table must already be empty! */
fail1:
jbd2_journal_destroy_revoke_table(journal->j_revoke_table[0]);
fail0:
return -ENOMEM;
}

/* Destroy a journal's revoke table. The table must already be empty! */
void jbd2_journal_destroy_revoke(journal_t *journal)
{
struct jbd2_revoke_table_s *table;
struct list_head *hash_list;
int i;

table = journal->j_revoke_table[0];
if (!table)
return;

for (i=0; i<table->hash_size; i++) {
hash_list = &table->hash_table[i];
J_ASSERT (list_empty(hash_list));
}

kfree(table->hash_table);
kmem_cache_free(jbd2_revoke_table_cache, table);
journal->j_revoke = NULL;

table = journal->j_revoke_table[1];
if (!table)
return;

for (i=0; i<table->hash_size; i++) {
hash_list = &table->hash_table[i];
J_ASSERT (list_empty(hash_list));
}

kfree(table->hash_table);
kmem_cache_free(jbd2_revoke_table_cache, table);
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]);
}


Expand Down

0 comments on commit 4e67b4a

Please sign in to comment.