aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Fasheh <mark.fasheh@oracle.com>2006-10-09 20:26:22 -0400
committerMark Fasheh <mark.fasheh@oracle.com>2006-12-01 21:28:23 -0500
commit65eff9ccf86d63eb5c3e9071450a36e4e4fa9564 (patch)
tree3610e008294ce4e5cfbc9abff3c98153f35ed2d4
parentdae85832ffe2879b57b23aea319a0ec17667898d (diff)
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 <mark.fasheh@oracle.com>
-rw-r--r--fs/ocfs2/alloc.c7
-rw-r--r--fs/ocfs2/aops.c2
-rw-r--r--fs/ocfs2/dir.c2
-rw-r--r--fs/ocfs2/file.c11
-rw-r--r--fs/ocfs2/inode.c4
-rw-r--r--fs/ocfs2/ioctl.c2
-rw-r--r--fs/ocfs2/journal.c29
-rw-r--r--fs/ocfs2/journal.h1
-rw-r--r--fs/ocfs2/localalloc.c6
-rw-r--r--fs/ocfs2/namei.c10
-rw-r--r--fs/ocfs2/suballoc.c2
11 files changed, 30 insertions, 46 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index f3dbd31a85a1..354817acf8b3 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -1158,7 +1158,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1158 goto out_mutex; 1158 goto out_mutex;
1159 } 1159 }
1160 1160
1161 handle = ocfs2_start_trans(osb, NULL, OCFS2_TRUNCATE_LOG_UPDATE); 1161 handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE);
1162 if (IS_ERR(handle)) { 1162 if (IS_ERR(handle)) {
1163 status = PTR_ERR(handle); 1163 status = PTR_ERR(handle);
1164 mlog_errno(status); 1164 mlog_errno(status);
@@ -1365,8 +1365,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1365 } 1365 }
1366 } 1366 }
1367 1367
1368 handle = ocfs2_start_trans(osb, NULL, 1368 handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE);
1369 OCFS2_TRUNCATE_LOG_UPDATE);
1370 if (IS_ERR(handle)) { 1369 if (IS_ERR(handle)) {
1371 status = PTR_ERR(handle); 1370 status = PTR_ERR(handle);
1372 mlog_errno(status); 1371 mlog_errno(status);
@@ -1860,7 +1859,7 @@ start:
1860 1859
1861 credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del, 1860 credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del,
1862 fe, el); 1861 fe, el);
1863 handle = ocfs2_start_trans(osb, NULL, credits); 1862 handle = ocfs2_start_trans(osb, credits);
1864 if (IS_ERR(handle)) { 1863 if (IS_ERR(handle)) {
1865 status = PTR_ERR(handle); 1864 status = PTR_ERR(handle);
1866 handle = NULL; 1865 handle = NULL;
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index c36939996946..fcdcdf6aa352 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -364,7 +364,7 @@ struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode,
364 struct ocfs2_journal_handle *handle = NULL; 364 struct ocfs2_journal_handle *handle = NULL;
365 int ret = 0; 365 int ret = 0;
366 366
367 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); 367 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
368 if (!handle) { 368 if (!handle) {
369 ret = -ENOMEM; 369 ret = -ENOMEM;
370 mlog_errno(ret); 370 mlog_errno(ret);
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 2bda5f345216..036c891c1e17 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -442,7 +442,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
442 credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS; 442 credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS;
443 } 443 }
444 444
445 handle = ocfs2_start_trans(osb, NULL, credits); 445 handle = ocfs2_start_trans(osb, credits);
446 if (IS_ERR(handle)) { 446 if (IS_ERR(handle)) {
447 status = PTR_ERR(handle); 447 status = PTR_ERR(handle);
448 handle = NULL; 448 handle = NULL;
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 9eb60f21968d..100754de16b8 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -165,8 +165,7 @@ static int ocfs2_simple_size_update(struct inode *inode,
165 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 165 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
166 struct ocfs2_journal_handle *handle = NULL; 166 struct ocfs2_journal_handle *handle = NULL;
167 167
168 handle = ocfs2_start_trans(osb, NULL, 168 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
169 OCFS2_INODE_UPDATE_CREDITS);
170 if (handle == NULL) { 169 if (handle == NULL) {
171 ret = -ENOMEM; 170 ret = -ENOMEM;
172 mlog_errno(ret); 171 mlog_errno(ret);
@@ -196,7 +195,7 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
196 /* TODO: This needs to actually orphan the inode in this 195 /* TODO: This needs to actually orphan the inode in this
197 * transaction. */ 196 * transaction. */
198 197
199 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); 198 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
200 if (IS_ERR(handle)) { 199 if (IS_ERR(handle)) {
201 status = PTR_ERR(handle); 200 status = PTR_ERR(handle);
202 mlog_errno(status); 201 mlog_errno(status);
@@ -496,7 +495,7 @@ restart_all:
496 drop_alloc_sem = 1; 495 drop_alloc_sem = 1;
497 496
498 credits = ocfs2_calc_extend_credits(osb->sb, fe, clusters_to_add); 497 credits = ocfs2_calc_extend_credits(osb->sb, fe, clusters_to_add);
499 handle = ocfs2_start_trans(osb, NULL, credits); 498 handle = ocfs2_start_trans(osb, credits);
500 if (IS_ERR(handle)) { 499 if (IS_ERR(handle)) {
501 status = PTR_ERR(handle); 500 status = PTR_ERR(handle);
502 handle = NULL; 501 handle = NULL;
@@ -832,7 +831,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
832 } 831 }
833 } 832 }
834 833
835 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); 834 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
836 if (IS_ERR(handle)) { 835 if (IS_ERR(handle)) {
837 status = PTR_ERR(handle); 836 status = PTR_ERR(handle);
838 mlog_errno(status); 837 mlog_errno(status);
@@ -905,7 +904,7 @@ static int ocfs2_write_remove_suid(struct inode *inode)
905 mlog_entry("(Inode %llu, mode 0%o)\n", 904 mlog_entry("(Inode %llu, mode 0%o)\n",
906 (unsigned long long)oi->ip_blkno, inode->i_mode); 905 (unsigned long long)oi->ip_blkno, inode->i_mode);
907 906
908 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); 907 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
909 if (handle == NULL) { 908 if (handle == NULL) {
910 ret = -ENOMEM; 909 ret = -ENOMEM;
911 mlog_errno(ret); 910 mlog_errno(ret);
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 7708c63a3554..ac78877ba14d 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -524,7 +524,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
524 if (!fe->i_clusters) 524 if (!fe->i_clusters)
525 goto bail; 525 goto bail;
526 526
527 handle = ocfs2_start_trans(osb, handle, OCFS2_INODE_UPDATE_CREDITS); 527 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
528 if (IS_ERR(handle)) { 528 if (IS_ERR(handle)) {
529 status = PTR_ERR(handle); 529 status = PTR_ERR(handle);
530 handle = NULL; 530 handle = NULL;
@@ -590,7 +590,7 @@ static int ocfs2_remove_inode(struct inode *inode,
590 goto bail; 590 goto bail;
591 } 591 }
592 592
593 handle = ocfs2_start_trans(osb, NULL, OCFS2_DELETE_INODE_CREDITS); 593 handle = ocfs2_start_trans(osb, OCFS2_DELETE_INODE_CREDITS);
594 if (IS_ERR(handle)) { 594 if (IS_ERR(handle)) {
595 status = PTR_ERR(handle); 595 status = PTR_ERR(handle);
596 mlog_errno(status); 596 mlog_errno(status);
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index e927758e8cd3..752735842b1d 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -67,7 +67,7 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
67 if (!S_ISDIR(inode->i_mode)) 67 if (!S_ISDIR(inode->i_mode))
68 flags &= ~OCFS2_DIRSYNC_FL; 68 flags &= ~OCFS2_DIRSYNC_FL;
69 69
70 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); 70 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
71 if (IS_ERR(handle)) { 71 if (IS_ERR(handle)) {
72 status = PTR_ERR(handle); 72 status = PTR_ERR(handle);
73 mlog_errno(status); 73 mlog_errno(status);
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)
129 * you pass it a handle however, it may still return error, in which 129 * you pass it a handle however, it may still return error, in which
130 * case it has free'd the passed handle for you. */ 130 * case it has free'd the passed handle for you. */
131struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, 131struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb,
132 struct ocfs2_journal_handle *handle,
133 int max_buffs) 132 int max_buffs)
134{ 133{
135 int ret; 134 int ret;
136 journal_t *journal = osb->journal->j_journal; 135 journal_t *journal = osb->journal->j_journal;
137 136 struct ocfs2_journal_handle *handle;
138 mlog_entry("(max_buffs = %d)\n", max_buffs);
139 137
140 BUG_ON(!osb || !osb->journal->j_journal); 138 BUG_ON(!osb || !osb->journal->j_journal);
141 139
142 if (ocfs2_is_hard_readonly(osb)) { 140 if (ocfs2_is_hard_readonly(osb))
143 ret = -EROFS; 141 return ERR_PTR(-EROFS);
144 goto done_free;
145 }
146 142
147 BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE); 143 BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE);
148 BUG_ON(max_buffs <= 0); 144 BUG_ON(max_buffs <= 0);
@@ -153,13 +149,11 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb,
153 BUG(); 149 BUG();
154 } 150 }
155 151
156 if (!handle) 152 handle = ocfs2_alloc_handle(osb);
157 handle = ocfs2_alloc_handle(osb);
158 if (!handle) { 153 if (!handle) {
159 ret = -ENOMEM; 154 ret = -ENOMEM;
160 mlog(ML_ERROR, "Failed to allocate memory for journal " 155 mlog_errno(ret);
161 "handle!\n"); 156 return ERR_PTR(ret);
162 goto done_free;
163 } 157 }
164 158
165 down_read(&osb->journal->j_trans_barrier); 159 down_read(&osb->journal->j_trans_barrier);
@@ -168,6 +162,7 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb,
168 handle->k_handle = journal_start(journal, max_buffs); 162 handle->k_handle = journal_start(journal, max_buffs);
169 if (IS_ERR(handle->k_handle)) { 163 if (IS_ERR(handle->k_handle)) {
170 up_read(&osb->journal->j_trans_barrier); 164 up_read(&osb->journal->j_trans_barrier);
165 kfree(handle);
171 166
172 ret = PTR_ERR(handle->k_handle); 167 ret = PTR_ERR(handle->k_handle);
173 handle->k_handle = NULL; 168 handle->k_handle = NULL;
@@ -177,20 +172,12 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb,
177 ocfs2_abort(osb->sb, "Detected aborted journal"); 172 ocfs2_abort(osb->sb, "Detected aborted journal");
178 ret = -EROFS; 173 ret = -EROFS;
179 } 174 }
180 goto done_free; 175 return ERR_PTR(ret);
181 } 176 }
182 177
183 atomic_inc(&(osb->journal->j_num_trans)); 178 atomic_inc(&(osb->journal->j_num_trans));
184 179
185 mlog_exit_ptr(handle);
186 return handle; 180 return handle;
187
188done_free:
189 if (handle)
190 kfree(handle);
191
192 mlog_exit(ret);
193 return ERR_PTR(ret);
194} 181}
195 182
196void ocfs2_commit_trans(struct ocfs2_super *osb, 183void ocfs2_commit_trans(struct ocfs2_super *osb,
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index d96f61abd668..3c0d15c5e49c 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -216,7 +216,6 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode)
216 * perfectly legal to go through an entire transaction without having 216 * perfectly legal to go through an entire transaction without having
217 * dirtied any buffers. */ 217 * dirtied any buffers. */
218struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, 218struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb,
219 struct ocfs2_journal_handle *handle,
220 int max_buffs); 219 int max_buffs);
221void ocfs2_commit_trans(struct ocfs2_super *osb, 220void ocfs2_commit_trans(struct ocfs2_super *osb,
222 struct ocfs2_journal_handle *handle); 221 struct ocfs2_journal_handle *handle);
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 9dd208dc5d7a..2ae567a7042b 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -238,7 +238,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
238 } 238 }
239 239
240 /* WINDOW_MOVE_CREDITS is a bit heavy... */ 240 /* WINDOW_MOVE_CREDITS is a bit heavy... */
241 handle = ocfs2_start_trans(osb, NULL, OCFS2_WINDOW_MOVE_CREDITS); 241 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS);
242 if (IS_ERR(handle)) { 242 if (IS_ERR(handle)) {
243 mlog_errno(PTR_ERR(handle)); 243 mlog_errno(PTR_ERR(handle));
244 handle = NULL; 244 handle = NULL;
@@ -405,7 +405,7 @@ int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb,
405 goto out_mutex; 405 goto out_mutex;
406 } 406 }
407 407
408 handle = ocfs2_start_trans(osb, NULL, OCFS2_WINDOW_MOVE_CREDITS); 408 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS);
409 if (IS_ERR(handle)) { 409 if (IS_ERR(handle)) {
410 status = PTR_ERR(handle); 410 status = PTR_ERR(handle);
411 handle = NULL; 411 handle = NULL;
@@ -896,7 +896,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
896 goto bail; 896 goto bail;
897 } 897 }
898 898
899 handle = ocfs2_start_trans(osb, NULL, OCFS2_WINDOW_MOVE_CREDITS); 899 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS);
900 if (IS_ERR(handle)) { 900 if (IS_ERR(handle)) {
901 status = PTR_ERR(handle); 901 status = PTR_ERR(handle);
902 handle = NULL; 902 handle = NULL;
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 9a56bfdf45c6..d63ab7be89a5 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -379,7 +379,7 @@ static int ocfs2_mknod(struct inode *dir,
379 } 379 }
380 } 380 }
381 381
382 handle = ocfs2_start_trans(osb, NULL, OCFS2_MKNOD_CREDITS); 382 handle = ocfs2_start_trans(osb, OCFS2_MKNOD_CREDITS);
383 if (IS_ERR(handle)) { 383 if (IS_ERR(handle)) {
384 status = PTR_ERR(handle); 384 status = PTR_ERR(handle);
385 handle = NULL; 385 handle = NULL;
@@ -696,7 +696,7 @@ static int ocfs2_link(struct dentry *old_dentry,
696 goto out_unlock_inode; 696 goto out_unlock_inode;
697 } 697 }
698 698
699 handle = ocfs2_start_trans(osb, NULL, OCFS2_LINK_CREDITS); 699 handle = ocfs2_start_trans(osb, OCFS2_LINK_CREDITS);
700 if (IS_ERR(handle)) { 700 if (IS_ERR(handle)) {
701 err = PTR_ERR(handle); 701 err = PTR_ERR(handle);
702 handle = NULL; 702 handle = NULL;
@@ -886,7 +886,7 @@ static int ocfs2_unlink(struct inode *dir,
886 } 886 }
887 } 887 }
888 888
889 handle = ocfs2_start_trans(osb, NULL, OCFS2_UNLINK_CREDITS); 889 handle = ocfs2_start_trans(osb, OCFS2_UNLINK_CREDITS);
890 if (IS_ERR(handle)) { 890 if (IS_ERR(handle)) {
891 status = PTR_ERR(handle); 891 status = PTR_ERR(handle);
892 handle = NULL; 892 handle = NULL;
@@ -1284,7 +1284,7 @@ static int ocfs2_rename(struct inode *old_dir,
1284 } 1284 }
1285 } 1285 }
1286 1286
1287 handle = ocfs2_start_trans(osb, NULL, OCFS2_RENAME_CREDITS); 1287 handle = ocfs2_start_trans(osb, OCFS2_RENAME_CREDITS);
1288 if (IS_ERR(handle)) { 1288 if (IS_ERR(handle)) {
1289 status = PTR_ERR(handle); 1289 status = PTR_ERR(handle);
1290 handle = NULL; 1290 handle = NULL;
@@ -1652,7 +1652,7 @@ static int ocfs2_symlink(struct inode *dir,
1652 } 1652 }
1653 } 1653 }
1654 1654
1655 handle = ocfs2_start_trans(osb, NULL, credits); 1655 handle = ocfs2_start_trans(osb, credits);
1656 if (IS_ERR(handle)) { 1656 if (IS_ERR(handle)) {
1657 status = PTR_ERR(handle); 1657 status = PTR_ERR(handle);
1658 handle = NULL; 1658 handle = NULL;
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index ea63a519167d..186d2c3d524d 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -302,7 +302,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
302 302
303 credits = ocfs2_calc_group_alloc_credits(osb->sb, 303 credits = ocfs2_calc_group_alloc_credits(osb->sb,
304 le16_to_cpu(cl->cl_cpg)); 304 le16_to_cpu(cl->cl_cpg));
305 handle = ocfs2_start_trans(osb, handle, credits); 305 handle = ocfs2_start_trans(osb, credits);
306 if (IS_ERR(handle)) { 306 if (IS_ERR(handle)) {
307 status = PTR_ERR(handle); 307 status = PTR_ERR(handle);
308 handle = NULL; 308 handle = NULL;