Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 296538
b: refs/heads/master
c: 0c2022e
h: refs/heads/master
v: v3
  • Loading branch information
Yongqiang Yang authored and Theodore Ts'o committed Feb 20, 2012
1 parent 06b8460 commit 0c7b21d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 6 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: 18aadd47f88464928b5ce57791c2e8f9f2aaece0
refs/heads/master: 0c2022eccb01630c037f2024531e9ff1afbe1564
2 changes: 1 addition & 1 deletion trunk/fs/jbd2/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
transaction->t_tid, stats);

__jbd2_journal_drop_transaction(journal, transaction);
kfree(transaction);
jbd2_journal_free_transaction(transaction);

/* Just in case anybody was waiting for more transactions to be
checkpointed... */
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/jbd2/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
jbd_debug(1, "JBD2: commit %d complete, head %d\n",
journal->j_commit_sequence, journal->j_tail_sequence);
if (to_free)
kfree(commit_transaction);
jbd2_journal_free_transaction(commit_transaction);

wake_up(&journal->j_wait_done_commit);
}
3 changes: 3 additions & 0 deletions trunk/fs/jbd2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,8 @@ static int __init journal_init_caches(void)
ret = journal_init_jbd2_journal_head_cache();
if (ret == 0)
ret = journal_init_handle_cache();
if (ret == 0)
ret = jbd2_journal_init_transaction_cache();
return ret;
}

Expand All @@ -2369,6 +2371,7 @@ static void jbd2_journal_destroy_caches(void)
jbd2_journal_destroy_revoke_caches();
jbd2_journal_destroy_jbd2_journal_head_cache();
jbd2_journal_destroy_handle_cache();
jbd2_journal_destroy_transaction_cache();
jbd2_journal_destroy_slabs();
}

Expand Down
36 changes: 33 additions & 3 deletions trunk/fs/jbd2/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,35 @@
static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh);
static void __jbd2_journal_unfile_buffer(struct journal_head *jh);

static struct kmem_cache *transaction_cache;
int __init jbd2_journal_init_transaction_cache(void)
{
J_ASSERT(!transaction_cache);
transaction_cache = kmem_cache_create("jbd2_transaction_s",
sizeof(transaction_t),
0,
SLAB_HWCACHE_ALIGN|SLAB_TEMPORARY,
NULL);
if (transaction_cache)
return 0;
return -ENOMEM;
}

void jbd2_journal_destroy_transaction_cache(void)
{
if (transaction_cache) {
kmem_cache_destroy(transaction_cache);
transaction_cache = NULL;
}
}

void jbd2_journal_free_transaction(transaction_t *transaction)
{
if (unlikely(ZERO_OR_NULL_PTR(transaction)))
return;
kmem_cache_free(transaction_cache, transaction);
}

/*
* jbd2_get_transaction: obtain a new transaction_t object.
*
Expand Down Expand Up @@ -133,7 +162,8 @@ static int start_this_handle(journal_t *journal, handle_t *handle,

alloc_transaction:
if (!journal->j_running_transaction) {
new_transaction = kzalloc(sizeof(*new_transaction), gfp_mask);
new_transaction = kmem_cache_alloc(transaction_cache,
gfp_mask | __GFP_ZERO);
if (!new_transaction) {
/*
* If __GFP_FS is not present, then we may be
Expand Down Expand Up @@ -162,7 +192,7 @@ static int start_this_handle(journal_t *journal, handle_t *handle,
if (is_journal_aborted(journal) ||
(journal->j_errno != 0 && !(journal->j_flags & JBD2_ACK_ERR))) {
read_unlock(&journal->j_state_lock);
kfree(new_transaction);
jbd2_journal_free_transaction(new_transaction);
return -EROFS;
}

Expand Down Expand Up @@ -284,7 +314,7 @@ static int start_this_handle(journal_t *journal, handle_t *handle,
read_unlock(&journal->j_state_lock);

lock_map_acquire(&handle->h_lockdep_map);
kfree(new_transaction);
jbd2_journal_free_transaction(new_transaction);
return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions trunk/include/linux/jbd2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,11 @@ jbd2_journal_write_metadata_buffer(transaction_t *transaction,
/* Transaction locking */
extern void __wait_on_journal (journal_t *);

/* Transaction cache support */
extern void jbd2_journal_destroy_transaction_cache(void);
extern int jbd2_journal_init_transaction_cache(void);
extern void jbd2_journal_free_transaction(transaction_t *);

/*
* Journal locking.
*
Expand Down

0 comments on commit 0c7b21d

Please sign in to comment.