ocfs2: remove unused ocfs2_handle_add_lock()

This gets us rid of a slab we no longer need, as well as removing the
majority of what's left on ocfs2_journal_handle.

ocfs2_commit_unstarted_handle() has no more real work to do, so remove that
function too.

Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
This commit is contained in:
Mark Fasheh 2006-10-06 19:05:31 -07:00
parent 02928a71ae
commit daf29e9cda
4 changed files with 2 additions and 117 deletions

View File

@ -1668,12 +1668,6 @@ int ocfs2_meta_lock_full(struct inode *inode,
} }
} }
if (handle) {
status = ocfs2_handle_add_lock(handle, inode);
if (status < 0)
mlog_errno(status);
}
bail: bail:
if (status < 0) { if (status < 0) {
if (ret_bh && (*ret_bh)) { if (ret_bh && (*ret_bh)) {

View File

@ -57,9 +57,6 @@ static int ocfs2_recover_node(struct ocfs2_super *osb,
static int __ocfs2_recovery_thread(void *arg); static int __ocfs2_recovery_thread(void *arg);
static int ocfs2_commit_cache(struct ocfs2_super *osb); static int ocfs2_commit_cache(struct ocfs2_super *osb);
static int ocfs2_wait_on_mount(struct ocfs2_super *osb); static int ocfs2_wait_on_mount(struct ocfs2_super *osb);
static void ocfs2_handle_cleanup_locks(struct ocfs2_journal *journal,
struct ocfs2_journal_handle *handle);
static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle);
static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb, static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
int dirty); int dirty);
static int ocfs2_trylock_journal(struct ocfs2_super *osb, static int ocfs2_trylock_journal(struct ocfs2_super *osb,
@ -123,11 +120,8 @@ struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb)
"handle!\n"); "handle!\n");
return NULL; return NULL;
} }
retval->num_locks = 0;
retval->k_handle = NULL; retval->k_handle = NULL;
INIT_LIST_HEAD(&retval->locks);
retval->journal = osb->journal; retval->journal = osb->journal;
return retval; return retval;
@ -195,27 +189,12 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb,
done_free: done_free:
if (handle) if (handle)
ocfs2_commit_unstarted_handle(handle); /* will kfree handle */ kfree(handle);
mlog_exit(ret); mlog_exit(ret);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
/* This is trivial so we do it out of the main commit
* paths. Beware, it can be called from start_trans too! */
static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle)
{
mlog_entry_void();
/* You are allowed to add journal locks before the transaction
* has started. */
ocfs2_handle_cleanup_locks(handle->journal, handle);
kfree(handle);
mlog_exit_void();
}
void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) void ocfs2_commit_trans(struct ocfs2_journal_handle *handle)
{ {
handle_t *jbd_handle; handle_t *jbd_handle;
@ -227,7 +206,7 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle)
BUG_ON(!handle); BUG_ON(!handle);
if (!handle->k_handle) { if (!handle->k_handle) {
ocfs2_commit_unstarted_handle(handle); kfree(handle);
mlog_exit_void(); mlog_exit_void();
return; return;
} }
@ -251,8 +230,6 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle)
handle->k_handle = NULL; /* it's been free'd in journal_stop */ handle->k_handle = NULL; /* it's been free'd in journal_stop */
} }
ocfs2_handle_cleanup_locks(journal, handle);
up_read(&journal->j_trans_barrier); up_read(&journal->j_trans_barrier);
kfree(handle); kfree(handle);
@ -394,59 +371,6 @@ int ocfs2_journal_dirty_data(handle_t *handle,
return err; return err;
} }
/* We always assume you're adding a metadata lock at level 'ex' */
int ocfs2_handle_add_lock(struct ocfs2_journal_handle *handle,
struct inode *inode)
{
int status;
struct ocfs2_journal_lock *lock;
BUG_ON(!inode);
lock = kmem_cache_alloc(ocfs2_lock_cache, GFP_NOFS);
if (!lock) {
status = -ENOMEM;
mlog_errno(-ENOMEM);
goto bail;
}
if (!igrab(inode))
BUG();
lock->jl_inode = inode;
list_add_tail(&(lock->jl_lock_list), &(handle->locks));
handle->num_locks++;
status = 0;
bail:
mlog_exit(status);
return status;
}
static void ocfs2_handle_cleanup_locks(struct ocfs2_journal *journal,
struct ocfs2_journal_handle *handle)
{
struct list_head *p, *n;
struct ocfs2_journal_lock *lock;
struct inode *inode;
list_for_each_safe(p, n, &(handle->locks)) {
lock = list_entry(p, struct ocfs2_journal_lock,
jl_lock_list);
list_del(&lock->jl_lock_list);
handle->num_locks--;
inode = lock->jl_inode;
ocfs2_meta_unlock(inode, 1);
if (atomic_read(&inode->i_count) == 1)
mlog(ML_ERROR,
"Inode %llu, I'm doing a last iput for!",
(unsigned long long)OCFS2_I(inode)->ip_blkno);
iput(inode);
kmem_cache_free(ocfs2_lock_cache, lock);
}
}
#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5) #define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5)
void ocfs2_set_journal_params(struct ocfs2_super *osb) void ocfs2_set_journal_params(struct ocfs2_super *osb)

View File

@ -133,22 +133,9 @@ static inline void ocfs2_inode_set_new(struct ocfs2_super *osb,
spin_unlock(&trans_inc_lock); spin_unlock(&trans_inc_lock);
} }
extern kmem_cache_t *ocfs2_lock_cache;
struct ocfs2_journal_lock {
struct inode *jl_inode;
struct list_head jl_lock_list;
};
struct ocfs2_journal_handle { struct ocfs2_journal_handle {
handle_t *k_handle; /* kernel handle. */ handle_t *k_handle; /* kernel handle. */
struct ocfs2_journal *journal; struct ocfs2_journal *journal;
/* The following two fields are for ocfs2_handle_add_lock */
int num_locks;
struct list_head locks; /* A bunch of locks to
* release on commit. This
* should be a list_head */
}; };
/* Exported only for the journal struct init code in super.c. Do not call. */ /* Exported only for the journal struct init code in super.c. Do not call. */
@ -229,11 +216,6 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode)
* ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data.
* ocfs2_journal_dirty_data - Indicate that a data buffer should go out before * ocfs2_journal_dirty_data - Indicate that a data buffer should go out before
* the current handle commits. * the current handle commits.
* ocfs2_handle_add_lock - Sometimes we need to delay lock release
* until after a transaction has been completed. Use
* ocfs2_handle_add_lock to indicate that a lock needs
* to be released at the end of that handle. Locks
* will be released in the order that they are added.
*/ */
/* You must always start_trans with a number of buffs > 0, but it's /* You must always start_trans with a number of buffs > 0, but it's
@ -288,8 +270,6 @@ int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle,
struct buffer_head *bh); struct buffer_head *bh);
int ocfs2_journal_dirty_data(handle_t *handle, int ocfs2_journal_dirty_data(handle_t *handle,
struct buffer_head *bh); struct buffer_head *bh);
int ocfs2_handle_add_lock(struct ocfs2_journal_handle *handle,
struct inode *inode);
/* /*
* Credit Macros: * Credit Macros:

View File

@ -70,8 +70,6 @@
static kmem_cache_t *ocfs2_inode_cachep = NULL; static kmem_cache_t *ocfs2_inode_cachep = NULL;
kmem_cache_t *ocfs2_lock_cache = NULL;
/* OCFS2 needs to schedule several differnt types of work which /* OCFS2 needs to schedule several differnt types of work which
* require cluster locking, disk I/O, recovery waits, etc. Since these * require cluster locking, disk I/O, recovery waits, etc. Since these
* types of work tend to be heavy we avoid using the kernel events * types of work tend to be heavy we avoid using the kernel events
@ -946,14 +944,6 @@ static int ocfs2_initialize_mem_caches(void)
if (!ocfs2_inode_cachep) if (!ocfs2_inode_cachep)
return -ENOMEM; return -ENOMEM;
ocfs2_lock_cache = kmem_cache_create("ocfs2_lock",
sizeof(struct ocfs2_journal_lock),
0,
SLAB_HWCACHE_ALIGN,
NULL, NULL);
if (!ocfs2_lock_cache)
return -ENOMEM;
return 0; return 0;
} }
@ -961,11 +951,8 @@ static void ocfs2_free_mem_caches(void)
{ {
if (ocfs2_inode_cachep) if (ocfs2_inode_cachep)
kmem_cache_destroy(ocfs2_inode_cachep); kmem_cache_destroy(ocfs2_inode_cachep);
if (ocfs2_lock_cache)
kmem_cache_destroy(ocfs2_lock_cache);
ocfs2_inode_cachep = NULL; ocfs2_inode_cachep = NULL;
ocfs2_lock_cache = NULL;
} }
static int ocfs2_get_sector(struct super_block *sb, static int ocfs2_get_sector(struct super_block *sb,