From 01ddf1e186b3b12b38c9e44912e0fd6a1cbc882b Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Thu, 5 Oct 2006 13:54:39 -0700 Subject: ocfs2: remove unused ocfs2_journal_handle field max_buffs was just being set and not actually used. Signed-off-by: Mark Fasheh --- fs/ocfs2/journal.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'fs/ocfs2/journal.c') diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index fd9734def551..e26cd0ca5176 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -124,7 +124,6 @@ struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb) return NULL; } - retval->max_buffs = 0; retval->num_locks = 0; retval->k_handle = NULL; @@ -172,8 +171,6 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, goto done_free; } - handle->max_buffs = max_buffs; - down_read(&osb->journal->j_trans_barrier); /* actually start the transaction now */ @@ -353,9 +350,7 @@ int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, mlog_errno(status); goto bail; } - handle->max_buffs = nblocks; - } else - handle->max_buffs += nblocks; + } status = 0; bail: -- cgit v1.2.2 From 1fc581467e52546195c7ee8233a34d63c1cc1322 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Thu, 5 Oct 2006 14:15:36 -0700 Subject: ocfs2: have ocfs2_extend_trans() take handle_t No reason to use our wrapper struct in this function, so take the handle_t directly. Also fixes a bug where we were incorrectly setting the handle to NULL in case of a failure from journal_restart() Signed-off-by: Mark Fasheh --- fs/ocfs2/journal.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'fs/ocfs2/journal.c') diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index e26cd0ca5176..7c0c57ad517b 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -323,20 +323,18 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) * good because transaction ids haven't yet been recorded on the * cluster locks associated with this handle. */ -int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, - int nblocks) +int ocfs2_extend_trans(handle_t *handle, int nblocks) { int status; BUG_ON(!handle); - BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); BUG_ON(!nblocks); mlog_entry_void(); mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); - status = journal_extend(handle->k_handle, nblocks); + status = journal_extend(handle, nblocks); if (status < 0) { mlog_errno(status); goto bail; @@ -344,9 +342,8 @@ int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, if (status > 0) { mlog(0, "journal_extend failed, trying journal_restart\n"); - status = journal_restart(handle->k_handle, nblocks); + status = journal_restart(handle, nblocks); if (status < 0) { - handle->k_handle = NULL; mlog_errno(status); goto bail; } -- cgit v1.2.2 From c161f89be7d57af863e434e9b15afaa863343a7a Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Thu, 5 Oct 2006 15:11:36 -0700 Subject: ocfs2: remove ocfs2_journal_handle flags field Callers can set h_sync directly on the handle_t, whether a transaction has been started or not can be determined via the existence of the handle_t on the struct ocfs2_journal_handle. Signed-off-by: Mark Fasheh --- fs/ocfs2/journal.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'fs/ocfs2/journal.c') diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 7c0c57ad517b..ca6f2094b006 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -190,7 +190,6 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, } atomic_inc(&(osb->journal->j_num_trans)); - handle->flags |= OCFS2_HANDLE_STARTED; mlog_exit_ptr(handle); return handle; @@ -247,8 +246,6 @@ static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle) { mlog_entry_void(); - BUG_ON(handle->flags & OCFS2_HANDLE_STARTED); - ocfs2_handle_unlock_inodes(handle); /* You are allowed to add journal locks before the transaction * has started. */ @@ -269,7 +266,7 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) BUG_ON(!handle); - if (!(handle->flags & OCFS2_HANDLE_STARTED)) { + if (!handle->k_handle) { ocfs2_commit_unstarted_handle(handle); mlog_exit_void(); return; @@ -285,11 +282,6 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) if (handle->k_handle) { jbd_handle = handle->k_handle; - if (handle->flags & OCFS2_HANDLE_SYNC) - jbd_handle->h_sync = 1; - else - jbd_handle->h_sync = 0; - /* actually stop the transaction. if we've set h_sync, * it'll have been committed when we return */ retval = journal_stop(jbd_handle); @@ -366,7 +358,6 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle, BUG_ON(!inode); BUG_ON(!handle); BUG_ON(!bh); - BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); mlog_entry("bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %zu\n", (unsigned long long)bh->b_blocknr, type, @@ -421,8 +412,6 @@ int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle, { int status; - BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); - mlog_entry("(bh->b_blocknr=%llu)\n", (unsigned long long)bh->b_blocknr); -- cgit v1.2.2 From 02928a71ae6da6e3e205d99e1fa1a1f598ddb62d Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Fri, 6 Oct 2006 18:51:46 -0700 Subject: ocfs2: remove unused ocfs2_handle_add_inode() We can also delete the unused infrastructure which was once in place to support this functionality. ocfs2_inode_private loses ip_handle and ip_handle_list. ocfs2_journal_handle loses handle_list. Signed-off-by: Mark Fasheh --- fs/ocfs2/journal.c | 43 ------------------------------------------- 1 file changed, 43 deletions(-) (limited to 'fs/ocfs2/journal.c') diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index ca6f2094b006..f02af63e5fae 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -128,7 +128,6 @@ struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb) retval->k_handle = NULL; INIT_LIST_HEAD(&retval->locks); - INIT_LIST_HEAD(&retval->inode_list); retval->journal = osb->journal; return retval; @@ -202,51 +201,12 @@ done_free: return ERR_PTR(ret); } -void ocfs2_handle_add_inode(struct ocfs2_journal_handle *handle, - struct inode *inode) -{ - BUG_ON(!handle); - BUG_ON(!inode); - - atomic_inc(&inode->i_count); - - /* we're obviously changing it... */ - mutex_lock(&inode->i_mutex); - - /* sanity check */ - BUG_ON(OCFS2_I(inode)->ip_handle); - BUG_ON(!list_empty(&OCFS2_I(inode)->ip_handle_list)); - - OCFS2_I(inode)->ip_handle = handle; - list_move_tail(&(OCFS2_I(inode)->ip_handle_list), &(handle->inode_list)); -} - -static void ocfs2_handle_unlock_inodes(struct ocfs2_journal_handle *handle) -{ - struct list_head *p, *n; - struct inode *inode; - struct ocfs2_inode_info *oi; - - list_for_each_safe(p, n, &handle->inode_list) { - oi = list_entry(p, struct ocfs2_inode_info, - ip_handle_list); - inode = &oi->vfs_inode; - - OCFS2_I(inode)->ip_handle = NULL; - list_del_init(&OCFS2_I(inode)->ip_handle_list); - - mutex_unlock(&inode->i_mutex); - iput(inode); - } -} - /* 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(); - ocfs2_handle_unlock_inodes(handle); /* You are allowed to add journal locks before the transaction * has started. */ ocfs2_handle_cleanup_locks(handle->journal, handle); @@ -272,9 +232,6 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) return; } - /* release inode semaphores we took during this transaction */ - ocfs2_handle_unlock_inodes(handle); - /* ocfs2_extend_trans may have had to call journal_restart * which will always commit the transaction, but may return * error for any number of reasons. If this is the case, we -- cgit v1.2.2 From daf29e9cdab7219838c6b6e82380aec3466cf379 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Fri, 6 Oct 2006 19:05:31 -0700 Subject: 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 --- fs/ocfs2/journal.c | 80 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 78 deletions(-) (limited to 'fs/ocfs2/journal.c') diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index f02af63e5fae..3ef1678c893a 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -57,9 +57,6 @@ static int ocfs2_recover_node(struct ocfs2_super *osb, static int __ocfs2_recovery_thread(void *arg); static int ocfs2_commit_cache(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, int dirty); 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"); return NULL; } - - retval->num_locks = 0; retval->k_handle = NULL; - INIT_LIST_HEAD(&retval->locks); retval->journal = osb->journal; return retval; @@ -195,27 +189,12 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, done_free: if (handle) - ocfs2_commit_unstarted_handle(handle); /* will kfree handle */ + kfree(handle); mlog_exit(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) { handle_t *jbd_handle; @@ -227,7 +206,7 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) BUG_ON(!handle); if (!handle->k_handle) { - ocfs2_commit_unstarted_handle(handle); + kfree(handle); mlog_exit_void(); 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 */ } - ocfs2_handle_cleanup_locks(journal, handle); - up_read(&journal->j_trans_barrier); kfree(handle); @@ -394,59 +371,6 @@ int ocfs2_journal_dirty_data(handle_t *handle, 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) void ocfs2_set_journal_params(struct ocfs2_super *osb) -- cgit v1.2.2 From a301a27d715276a71827004549bcbb2b64776c11 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Fri, 6 Oct 2006 19:07:43 -0700 Subject: ocfs2: make ocfs2_alloc_handle() static This is no longer used outside of journal.c Signed-off-by: Mark Fasheh --- fs/ocfs2/journal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/ocfs2/journal.c') diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 3ef1678c893a..f070487a0551 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -110,7 +110,7 @@ finally: return status; } -struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb) +static struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb) { struct ocfs2_journal_handle *retval = NULL; -- cgit v1.2.2 From 4bcec1847ac4f75c2ee6d091b495f34d8d822e6a Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Mon, 9 Oct 2006 16:02:40 -0700 Subject: ocfs2: remove unused handle argument from ocfs2_meta_lock_full() Now that this is unused and all callers pass NULL, we can safely remove it. Signed-off-by: Mark Fasheh --- fs/ocfs2/journal.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'fs/ocfs2/journal.c') diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index f070487a0551..61db8e7fffa5 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -424,8 +424,7 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty) /* Skip recovery waits here - journal inode metadata never * changes in a live cluster so it can be considered an * exception to the rule. */ - status = ocfs2_meta_lock_full(inode, NULL, &bh, 1, - OCFS2_META_LOCK_RECOVERY); + status = ocfs2_meta_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY); if (status < 0) { if (status != -ERESTARTSYS) mlog(ML_ERROR, "Could not get lock on journal!\n"); @@ -1022,8 +1021,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb, } SET_INODE_JOURNAL(inode); - status = ocfs2_meta_lock_full(inode, NULL, &bh, 1, - OCFS2_META_LOCK_RECOVERY); + status = ocfs2_meta_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY); if (status < 0) { mlog(0, "status returned from ocfs2_meta_lock=%d\n", status); if (status != -ERESTARTSYS) @@ -1212,7 +1210,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb, SET_INODE_JOURNAL(inode); flags = OCFS2_META_LOCK_RECOVERY | OCFS2_META_LOCK_NOQUEUE; - status = ocfs2_meta_lock_full(inode, NULL, NULL, 1, flags); + status = ocfs2_meta_lock_full(inode, NULL, 1, flags); if (status < 0) { if (status != -EAGAIN) mlog_errno(status); @@ -1295,7 +1293,7 @@ static int ocfs2_queue_orphans(struct ocfs2_super *osb, } mutex_lock(&orphan_dir_inode->i_mutex); - status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0); + status = ocfs2_meta_lock(orphan_dir_inode, NULL, 0); if (status < 0) { mlog_errno(status); goto out; -- cgit v1.2.2 From 02dc1af44e9fa4b8801169891b3a1ba4047537ad Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Mon, 9 Oct 2006 16:48:10 -0700 Subject: ocfs2: pass ocfs2_super * into ocfs2_commit_trans() This sets us up to remove handle->journal. Signed-off-by: Mark Fasheh --- fs/ocfs2/journal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'fs/ocfs2/journal.c') diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 61db8e7fffa5..00402e749fc6 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -195,11 +195,12 @@ done_free: return ERR_PTR(ret); } -void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) +void ocfs2_commit_trans(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle) { handle_t *jbd_handle; int retval; - struct ocfs2_journal *journal = handle->journal; + struct ocfs2_journal *journal = osb->journal; mlog_entry_void(); -- cgit v1.2.2 From dae85832ffe2879b57b23aea319a0ec17667898d Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Mon, 9 Oct 2006 16:50:32 -0700 Subject: ocfs2: remove ocfs2_journal_handle journal field It is no longer used. Signed-off-by: Mark Fasheh --- fs/ocfs2/journal.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'fs/ocfs2/journal.c') diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 00402e749fc6..81fb917475fd 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -122,8 +122,6 @@ static struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb) } retval->k_handle = NULL; - retval->journal = osb->journal; - return retval; } -- cgit v1.2.2 From 65eff9ccf86d63eb5c3e9071450a36e4e4fa9564 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Mon, 9 Oct 2006 17:26:22 -0700 Subject: ocfs2: remove handle argument to ocfs2_start_trans() All callers either pass in NULL directly, or a local variable that is already set to NULL. The internals of ocfs2_start_trans() get a nice cleanup as a result. Signed-off-by: Mark Fasheh --- fs/ocfs2/journal.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'fs/ocfs2/journal.c') diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 81fb917475fd..6d9658b0c5db 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -129,20 +129,16 @@ static struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb) * you pass it a handle however, it may still return error, in which * case it has free'd the passed handle for you. */ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, - struct ocfs2_journal_handle *handle, int max_buffs) { int ret; journal_t *journal = osb->journal->j_journal; - - mlog_entry("(max_buffs = %d)\n", max_buffs); + struct ocfs2_journal_handle *handle; BUG_ON(!osb || !osb->journal->j_journal); - if (ocfs2_is_hard_readonly(osb)) { - ret = -EROFS; - goto done_free; - } + if (ocfs2_is_hard_readonly(osb)) + return ERR_PTR(-EROFS); BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE); BUG_ON(max_buffs <= 0); @@ -153,13 +149,11 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, BUG(); } - if (!handle) - handle = ocfs2_alloc_handle(osb); + handle = ocfs2_alloc_handle(osb); if (!handle) { ret = -ENOMEM; - mlog(ML_ERROR, "Failed to allocate memory for journal " - "handle!\n"); - goto done_free; + mlog_errno(ret); + return ERR_PTR(ret); } down_read(&osb->journal->j_trans_barrier); @@ -168,6 +162,7 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, handle->k_handle = journal_start(journal, max_buffs); if (IS_ERR(handle->k_handle)) { up_read(&osb->journal->j_trans_barrier); + kfree(handle); ret = PTR_ERR(handle->k_handle); handle->k_handle = NULL; @@ -177,20 +172,12 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, ocfs2_abort(osb->sb, "Detected aborted journal"); ret = -EROFS; } - goto done_free; + return ERR_PTR(ret); } atomic_inc(&(osb->journal->j_num_trans)); - mlog_exit_ptr(handle); return handle; - -done_free: - if (handle) - kfree(handle); - - mlog_exit(ret); - return ERR_PTR(ret); } void ocfs2_commit_trans(struct ocfs2_super *osb, -- cgit v1.2.2 From 1fabe1481fac9e01bf8bffa60a2307ef379aa5de Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Mon, 9 Oct 2006 18:11:45 -0700 Subject: ocfs2: Remove struct ocfs2_journal_handle in favor of handle_t This is mostly a search and replace as ocfs2_journal_handle is now no more than a container for a handle_t pointer. ocfs2_commit_trans() becomes very straight forward, and we remove some out of date comments / code. Signed-off-by: Mark Fasheh --- fs/ocfs2/journal.c | 95 ++++++++++++------------------------------------------ 1 file changed, 20 insertions(+), 75 deletions(-) (limited to 'fs/ocfs2/journal.c') diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 6d9658b0c5db..c0ad7cb59521 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -110,30 +110,13 @@ finally: return status; } -static struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb) -{ - struct ocfs2_journal_handle *retval = NULL; - - retval = kcalloc(1, sizeof(*retval), GFP_NOFS); - if (!retval) { - mlog(ML_ERROR, "Failed to allocate memory for journal " - "handle!\n"); - return NULL; - } - retval->k_handle = NULL; - - return retval; -} - /* pass it NULL and it will allocate a new handle object for you. If * you pass it a handle however, it may still return error, in which * case it has free'd the passed handle for you. */ -struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, - int max_buffs) +handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs) { - int ret; journal_t *journal = osb->journal->j_journal; - struct ocfs2_journal_handle *handle; + handle_t *handle; BUG_ON(!osb || !osb->journal->j_journal); @@ -149,77 +132,39 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, BUG(); } - handle = ocfs2_alloc_handle(osb); - if (!handle) { - ret = -ENOMEM; - mlog_errno(ret); - return ERR_PTR(ret); - } - down_read(&osb->journal->j_trans_barrier); - /* actually start the transaction now */ - handle->k_handle = journal_start(journal, max_buffs); - if (IS_ERR(handle->k_handle)) { + handle = journal_start(journal, max_buffs); + if (IS_ERR(handle)) { up_read(&osb->journal->j_trans_barrier); - kfree(handle); - ret = PTR_ERR(handle->k_handle); - handle->k_handle = NULL; - mlog_errno(ret); + mlog_errno(PTR_ERR(handle)); if (is_journal_aborted(journal)) { ocfs2_abort(osb->sb, "Detected aborted journal"); - ret = -EROFS; + handle = ERR_PTR(-EROFS); } - return ERR_PTR(ret); - } - - atomic_inc(&(osb->journal->j_num_trans)); + } else + atomic_inc(&(osb->journal->j_num_trans)); return handle; } -void ocfs2_commit_trans(struct ocfs2_super *osb, - struct ocfs2_journal_handle *handle) +int ocfs2_commit_trans(struct ocfs2_super *osb, + handle_t *handle) { - handle_t *jbd_handle; - int retval; + int ret; struct ocfs2_journal *journal = osb->journal; - mlog_entry_void(); - BUG_ON(!handle); - if (!handle->k_handle) { - kfree(handle); - mlog_exit_void(); - return; - } - - /* ocfs2_extend_trans may have had to call journal_restart - * which will always commit the transaction, but may return - * error for any number of reasons. If this is the case, we - * clear k_handle as it's not valid any more. */ - if (handle->k_handle) { - jbd_handle = handle->k_handle; - - /* actually stop the transaction. if we've set h_sync, - * it'll have been committed when we return */ - retval = journal_stop(jbd_handle); - if (retval < 0) { - mlog_errno(retval); - mlog(ML_ERROR, "Could not commit transaction\n"); - BUG(); - } - - handle->k_handle = NULL; /* it's been free'd in journal_stop */ - } + ret = journal_stop(handle); + if (ret < 0) + mlog_errno(ret); up_read(&journal->j_trans_barrier); - kfree(handle); - mlog_exit_void(); + return ret; } /* @@ -268,7 +213,7 @@ bail: return status; } -int ocfs2_journal_access(struct ocfs2_journal_handle *handle, +int ocfs2_journal_access(handle_t *handle, struct inode *inode, struct buffer_head *bh, int type) @@ -306,11 +251,11 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle, switch (type) { case OCFS2_JOURNAL_ACCESS_CREATE: case OCFS2_JOURNAL_ACCESS_WRITE: - status = journal_get_write_access(handle->k_handle, bh); + status = journal_get_write_access(handle, bh); break; case OCFS2_JOURNAL_ACCESS_UNDO: - status = journal_get_undo_access(handle->k_handle, bh); + status = journal_get_undo_access(handle, bh); break; default: @@ -327,7 +272,7 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle, return status; } -int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle, +int ocfs2_journal_dirty(handle_t *handle, struct buffer_head *bh) { int status; @@ -335,7 +280,7 @@ int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle, mlog_entry("(bh->b_blocknr=%llu)\n", (unsigned long long)bh->b_blocknr); - status = journal_dirty_metadata(handle->k_handle, bh); + status = journal_dirty_metadata(handle, bh); if (status < 0) mlog(ML_ERROR, "Could not dirty metadata buffer. " "(bh->b_blocknr=%llu)\n", -- cgit v1.2.2