aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/dlmglue.c6
-rw-r--r--fs/ocfs2/journal.c80
-rw-r--r--fs/ocfs2/journal.h20
-rw-r--r--fs/ocfs2/super.c13
4 files changed, 2 insertions, 117 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index ff8d3dbdeb31..1c29b96b99e7 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -1668,12 +1668,6 @@ int ocfs2_meta_lock_full(struct inode *inode,
1668 } 1668 }
1669 } 1669 }
1670 1670
1671 if (handle) {
1672 status = ocfs2_handle_add_lock(handle, inode);
1673 if (status < 0)
1674 mlog_errno(status);
1675 }
1676
1677bail: 1671bail:
1678 if (status < 0) { 1672 if (status < 0) {
1679 if (ret_bh && (*ret_bh)) { 1673 if (ret_bh && (*ret_bh)) {
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,
57static int __ocfs2_recovery_thread(void *arg); 57static int __ocfs2_recovery_thread(void *arg);
58static int ocfs2_commit_cache(struct ocfs2_super *osb); 58static int ocfs2_commit_cache(struct ocfs2_super *osb);
59static int ocfs2_wait_on_mount(struct ocfs2_super *osb); 59static int ocfs2_wait_on_mount(struct ocfs2_super *osb);
60static void ocfs2_handle_cleanup_locks(struct ocfs2_journal *journal,
61 struct ocfs2_journal_handle *handle);
62static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle);
63static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb, 60static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
64 int dirty); 61 int dirty);
65static int ocfs2_trylock_journal(struct ocfs2_super *osb, 62static int ocfs2_trylock_journal(struct ocfs2_super *osb,
@@ -123,11 +120,8 @@ struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb)
123 "handle!\n"); 120 "handle!\n");
124 return NULL; 121 return NULL;
125 } 122 }
126
127 retval->num_locks = 0;
128 retval->k_handle = NULL; 123 retval->k_handle = NULL;
129 124
130 INIT_LIST_HEAD(&retval->locks);
131 retval->journal = osb->journal; 125 retval->journal = osb->journal;
132 126
133 return retval; 127 return retval;
@@ -195,27 +189,12 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb,
195 189
196done_free: 190done_free:
197 if (handle) 191 if (handle)
198 ocfs2_commit_unstarted_handle(handle); /* will kfree handle */ 192 kfree(handle);
199 193
200 mlog_exit(ret); 194 mlog_exit(ret);
201 return ERR_PTR(ret); 195 return ERR_PTR(ret);
202} 196}
203 197
204/* This is trivial so we do it out of the main commit
205 * paths. Beware, it can be called from start_trans too! */
206static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle)
207{
208 mlog_entry_void();
209
210 /* You are allowed to add journal locks before the transaction
211 * has started. */
212 ocfs2_handle_cleanup_locks(handle->journal, handle);
213
214 kfree(handle);
215
216 mlog_exit_void();
217}
218
219void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) 198void ocfs2_commit_trans(struct ocfs2_journal_handle *handle)
220{ 199{
221 handle_t *jbd_handle; 200 handle_t *jbd_handle;
@@ -227,7 +206,7 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle)
227 BUG_ON(!handle); 206 BUG_ON(!handle);
228 207
229 if (!handle->k_handle) { 208 if (!handle->k_handle) {
230 ocfs2_commit_unstarted_handle(handle); 209 kfree(handle);
231 mlog_exit_void(); 210 mlog_exit_void();
232 return; 211 return;
233 } 212 }
@@ -251,8 +230,6 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle)
251 handle->k_handle = NULL; /* it's been free'd in journal_stop */ 230 handle->k_handle = NULL; /* it's been free'd in journal_stop */
252 } 231 }
253 232
254 ocfs2_handle_cleanup_locks(journal, handle);
255
256 up_read(&journal->j_trans_barrier); 233 up_read(&journal->j_trans_barrier);
257 234
258 kfree(handle); 235 kfree(handle);
@@ -394,59 +371,6 @@ int ocfs2_journal_dirty_data(handle_t *handle,
394 return err; 371 return err;
395} 372}
396 373
397/* We always assume you're adding a metadata lock at level 'ex' */
398int ocfs2_handle_add_lock(struct ocfs2_journal_handle *handle,
399 struct inode *inode)
400{
401 int status;
402 struct ocfs2_journal_lock *lock;
403
404 BUG_ON(!inode);
405
406 lock = kmem_cache_alloc(ocfs2_lock_cache, GFP_NOFS);
407 if (!lock) {
408 status = -ENOMEM;
409 mlog_errno(-ENOMEM);
410 goto bail;
411 }
412
413 if (!igrab(inode))
414 BUG();
415 lock->jl_inode = inode;
416
417 list_add_tail(&(lock->jl_lock_list), &(handle->locks));
418 handle->num_locks++;
419
420 status = 0;
421bail:
422 mlog_exit(status);
423 return status;
424}
425
426static void ocfs2_handle_cleanup_locks(struct ocfs2_journal *journal,
427 struct ocfs2_journal_handle *handle)
428{
429 struct list_head *p, *n;
430 struct ocfs2_journal_lock *lock;
431 struct inode *inode;
432
433 list_for_each_safe(p, n, &(handle->locks)) {
434 lock = list_entry(p, struct ocfs2_journal_lock,
435 jl_lock_list);
436 list_del(&lock->jl_lock_list);
437 handle->num_locks--;
438
439 inode = lock->jl_inode;
440 ocfs2_meta_unlock(inode, 1);
441 if (atomic_read(&inode->i_count) == 1)
442 mlog(ML_ERROR,
443 "Inode %llu, I'm doing a last iput for!",
444 (unsigned long long)OCFS2_I(inode)->ip_blkno);
445 iput(inode);
446 kmem_cache_free(ocfs2_lock_cache, lock);
447 }
448}
449
450#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5) 374#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5)
451 375
452void ocfs2_set_journal_params(struct ocfs2_super *osb) 376void ocfs2_set_journal_params(struct ocfs2_super *osb)
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index 3a16d7d88e1c..7e9c1303d633 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -133,22 +133,9 @@ static inline void ocfs2_inode_set_new(struct ocfs2_super *osb,
133 spin_unlock(&trans_inc_lock); 133 spin_unlock(&trans_inc_lock);
134} 134}
135 135
136extern kmem_cache_t *ocfs2_lock_cache;
137
138struct ocfs2_journal_lock {
139 struct inode *jl_inode;
140 struct list_head jl_lock_list;
141};
142
143struct ocfs2_journal_handle { 136struct ocfs2_journal_handle {
144 handle_t *k_handle; /* kernel handle. */ 137 handle_t *k_handle; /* kernel handle. */
145 struct ocfs2_journal *journal; 138 struct ocfs2_journal *journal;
146
147 /* The following two fields are for ocfs2_handle_add_lock */
148 int num_locks;
149 struct list_head locks; /* A bunch of locks to
150 * release on commit. This
151 * should be a list_head */
152}; 139};
153 140
154/* Exported only for the journal struct init code in super.c. Do not call. */ 141/* 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)
229 * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. 216 * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data.
230 * ocfs2_journal_dirty_data - Indicate that a data buffer should go out before 217 * ocfs2_journal_dirty_data - Indicate that a data buffer should go out before
231 * the current handle commits. 218 * the current handle commits.
232 * ocfs2_handle_add_lock - Sometimes we need to delay lock release
233 * until after a transaction has been completed. Use
234 * ocfs2_handle_add_lock to indicate that a lock needs
235 * to be released at the end of that handle. Locks
236 * will be released in the order that they are added.
237 */ 219 */
238 220
239/* You must always start_trans with a number of buffs > 0, but it's 221/* 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,
288 struct buffer_head *bh); 270 struct buffer_head *bh);
289int ocfs2_journal_dirty_data(handle_t *handle, 271int ocfs2_journal_dirty_data(handle_t *handle,
290 struct buffer_head *bh); 272 struct buffer_head *bh);
291int ocfs2_handle_add_lock(struct ocfs2_journal_handle *handle,
292 struct inode *inode);
293 273
294/* 274/*
295 * Credit Macros: 275 * Credit Macros:
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index f3027c2fe2b6..290d531bed61 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -70,8 +70,6 @@
70 70
71static kmem_cache_t *ocfs2_inode_cachep = NULL; 71static kmem_cache_t *ocfs2_inode_cachep = NULL;
72 72
73kmem_cache_t *ocfs2_lock_cache = NULL;
74
75/* OCFS2 needs to schedule several differnt types of work which 73/* OCFS2 needs to schedule several differnt types of work which
76 * require cluster locking, disk I/O, recovery waits, etc. Since these 74 * require cluster locking, disk I/O, recovery waits, etc. Since these
77 * types of work tend to be heavy we avoid using the kernel events 75 * types of work tend to be heavy we avoid using the kernel events
@@ -946,14 +944,6 @@ static int ocfs2_initialize_mem_caches(void)
946 if (!ocfs2_inode_cachep) 944 if (!ocfs2_inode_cachep)
947 return -ENOMEM; 945 return -ENOMEM;
948 946
949 ocfs2_lock_cache = kmem_cache_create("ocfs2_lock",
950 sizeof(struct ocfs2_journal_lock),
951 0,
952 SLAB_HWCACHE_ALIGN,
953 NULL, NULL);
954 if (!ocfs2_lock_cache)
955 return -ENOMEM;
956
957 return 0; 947 return 0;
958} 948}
959 949
@@ -961,11 +951,8 @@ static void ocfs2_free_mem_caches(void)
961{ 951{
962 if (ocfs2_inode_cachep) 952 if (ocfs2_inode_cachep)
963 kmem_cache_destroy(ocfs2_inode_cachep); 953 kmem_cache_destroy(ocfs2_inode_cachep);
964 if (ocfs2_lock_cache)
965 kmem_cache_destroy(ocfs2_lock_cache);
966 954
967 ocfs2_inode_cachep = NULL; 955 ocfs2_inode_cachep = NULL;
968 ocfs2_lock_cache = NULL;
969} 956}
970 957
971static int ocfs2_get_sector(struct super_block *sb, 958static int ocfs2_get_sector(struct super_block *sb,