Commit 65eff9ccf86d63eb5c3e9071450a36e4e4fa9564
1 parent
dae85832ff
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>
Showing 11 changed files with 30 additions and 46 deletions Side-by-side Diff
fs/ocfs2/alloc.c
... | ... | @@ -1158,7 +1158,7 @@ |
1158 | 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 | 1162 | if (IS_ERR(handle)) { |
1163 | 1163 | status = PTR_ERR(handle); |
1164 | 1164 | mlog_errno(status); |
... | ... | @@ -1365,8 +1365,7 @@ |
1365 | 1365 | } |
1366 | 1366 | } |
1367 | 1367 | |
1368 | - handle = ocfs2_start_trans(osb, NULL, | |
1369 | - OCFS2_TRUNCATE_LOG_UPDATE); | |
1368 | + handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE); | |
1370 | 1369 | if (IS_ERR(handle)) { |
1371 | 1370 | status = PTR_ERR(handle); |
1372 | 1371 | mlog_errno(status); |
... | ... | @@ -1860,7 +1859,7 @@ |
1860 | 1859 | |
1861 | 1860 | credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del, |
1862 | 1861 | fe, el); |
1863 | - handle = ocfs2_start_trans(osb, NULL, credits); | |
1862 | + handle = ocfs2_start_trans(osb, credits); | |
1864 | 1863 | if (IS_ERR(handle)) { |
1865 | 1864 | status = PTR_ERR(handle); |
1866 | 1865 | handle = NULL; |
fs/ocfs2/aops.c
... | ... | @@ -364,7 +364,7 @@ |
364 | 364 | struct ocfs2_journal_handle *handle = NULL; |
365 | 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 | 368 | if (!handle) { |
369 | 369 | ret = -ENOMEM; |
370 | 370 | mlog_errno(ret); |
fs/ocfs2/dir.c
fs/ocfs2/file.c
... | ... | @@ -165,8 +165,7 @@ |
165 | 165 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
166 | 166 | struct ocfs2_journal_handle *handle = NULL; |
167 | 167 | |
168 | - handle = ocfs2_start_trans(osb, NULL, | |
169 | - OCFS2_INODE_UPDATE_CREDITS); | |
168 | + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); | |
170 | 169 | if (handle == NULL) { |
171 | 170 | ret = -ENOMEM; |
172 | 171 | mlog_errno(ret); |
... | ... | @@ -196,7 +195,7 @@ |
196 | 195 | /* TODO: This needs to actually orphan the inode in this |
197 | 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 | 199 | if (IS_ERR(handle)) { |
201 | 200 | status = PTR_ERR(handle); |
202 | 201 | mlog_errno(status); |
... | ... | @@ -496,7 +495,7 @@ |
496 | 495 | drop_alloc_sem = 1; |
497 | 496 | |
498 | 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 | 499 | if (IS_ERR(handle)) { |
501 | 500 | status = PTR_ERR(handle); |
502 | 501 | handle = NULL; |
... | ... | @@ -832,7 +831,7 @@ |
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 | 835 | if (IS_ERR(handle)) { |
837 | 836 | status = PTR_ERR(handle); |
838 | 837 | mlog_errno(status); |
... | ... | @@ -905,7 +904,7 @@ |
905 | 904 | mlog_entry("(Inode %llu, mode 0%o)\n", |
906 | 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 | 908 | if (handle == NULL) { |
910 | 909 | ret = -ENOMEM; |
911 | 910 | mlog_errno(ret); |
fs/ocfs2/inode.c
... | ... | @@ -524,7 +524,7 @@ |
524 | 524 | if (!fe->i_clusters) |
525 | 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 | 528 | if (IS_ERR(handle)) { |
529 | 529 | status = PTR_ERR(handle); |
530 | 530 | handle = NULL; |
... | ... | @@ -590,7 +590,7 @@ |
590 | 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 | 594 | if (IS_ERR(handle)) { |
595 | 595 | status = PTR_ERR(handle); |
596 | 596 | mlog_errno(status); |
fs/ocfs2/ioctl.c
... | ... | @@ -67,7 +67,7 @@ |
67 | 67 | if (!S_ISDIR(inode->i_mode)) |
68 | 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 | 71 | if (IS_ERR(handle)) { |
72 | 72 | status = PTR_ERR(handle); |
73 | 73 | mlog_errno(status); |
fs/ocfs2/journal.c
... | ... | @@ -129,20 +129,16 @@ |
129 | 129 | * you pass it a handle however, it may still return error, in which |
130 | 130 | * case it has free'd the passed handle for you. */ |
131 | 131 | struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, |
132 | - struct ocfs2_journal_handle *handle, | |
133 | 132 | int max_buffs) |
134 | 133 | { |
135 | 134 | int ret; |
136 | 135 | journal_t *journal = osb->journal->j_journal; |
136 | + struct ocfs2_journal_handle *handle; | |
137 | 137 | |
138 | - mlog_entry("(max_buffs = %d)\n", max_buffs); | |
139 | - | |
140 | 138 | BUG_ON(!osb || !osb->journal->j_journal); |
141 | 139 | |
142 | - if (ocfs2_is_hard_readonly(osb)) { | |
143 | - ret = -EROFS; | |
144 | - goto done_free; | |
145 | - } | |
140 | + if (ocfs2_is_hard_readonly(osb)) | |
141 | + return ERR_PTR(-EROFS); | |
146 | 142 | |
147 | 143 | BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE); |
148 | 144 | BUG_ON(max_buffs <= 0); |
149 | 145 | |
... | ... | @@ -153,13 +149,11 @@ |
153 | 149 | BUG(); |
154 | 150 | } |
155 | 151 | |
156 | - if (!handle) | |
157 | - handle = ocfs2_alloc_handle(osb); | |
152 | + handle = ocfs2_alloc_handle(osb); | |
158 | 153 | if (!handle) { |
159 | 154 | ret = -ENOMEM; |
160 | - mlog(ML_ERROR, "Failed to allocate memory for journal " | |
161 | - "handle!\n"); | |
162 | - goto done_free; | |
155 | + mlog_errno(ret); | |
156 | + return ERR_PTR(ret); | |
163 | 157 | } |
164 | 158 | |
165 | 159 | down_read(&osb->journal->j_trans_barrier); |
... | ... | @@ -168,6 +162,7 @@ |
168 | 162 | handle->k_handle = journal_start(journal, max_buffs); |
169 | 163 | if (IS_ERR(handle->k_handle)) { |
170 | 164 | up_read(&osb->journal->j_trans_barrier); |
165 | + kfree(handle); | |
171 | 166 | |
172 | 167 | ret = PTR_ERR(handle->k_handle); |
173 | 168 | handle->k_handle = NULL; |
174 | 169 | |
175 | 170 | |
... | ... | @@ -177,20 +172,12 @@ |
177 | 172 | ocfs2_abort(osb->sb, "Detected aborted journal"); |
178 | 173 | ret = -EROFS; |
179 | 174 | } |
180 | - goto done_free; | |
175 | + return ERR_PTR(ret); | |
181 | 176 | } |
182 | 177 | |
183 | 178 | atomic_inc(&(osb->journal->j_num_trans)); |
184 | 179 | |
185 | - mlog_exit_ptr(handle); | |
186 | 180 | return handle; |
187 | - | |
188 | -done_free: | |
189 | - if (handle) | |
190 | - kfree(handle); | |
191 | - | |
192 | - mlog_exit(ret); | |
193 | - return ERR_PTR(ret); | |
194 | 181 | } |
195 | 182 | |
196 | 183 | void ocfs2_commit_trans(struct ocfs2_super *osb, |
fs/ocfs2/journal.h
... | ... | @@ -216,7 +216,6 @@ |
216 | 216 | * perfectly legal to go through an entire transaction without having |
217 | 217 | * dirtied any buffers. */ |
218 | 218 | struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, |
219 | - struct ocfs2_journal_handle *handle, | |
220 | 219 | int max_buffs); |
221 | 220 | void ocfs2_commit_trans(struct ocfs2_super *osb, |
222 | 221 | struct ocfs2_journal_handle *handle); |
fs/ocfs2/localalloc.c
... | ... | @@ -238,7 +238,7 @@ |
238 | 238 | } |
239 | 239 | |
240 | 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 | 242 | if (IS_ERR(handle)) { |
243 | 243 | mlog_errno(PTR_ERR(handle)); |
244 | 244 | handle = NULL; |
... | ... | @@ -405,7 +405,7 @@ |
405 | 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 | 409 | if (IS_ERR(handle)) { |
410 | 410 | status = PTR_ERR(handle); |
411 | 411 | handle = NULL; |
... | ... | @@ -896,7 +896,7 @@ |
896 | 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 | 900 | if (IS_ERR(handle)) { |
901 | 901 | status = PTR_ERR(handle); |
902 | 902 | handle = NULL; |
fs/ocfs2/namei.c
... | ... | @@ -379,7 +379,7 @@ |
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 | 383 | if (IS_ERR(handle)) { |
384 | 384 | status = PTR_ERR(handle); |
385 | 385 | handle = NULL; |
... | ... | @@ -696,7 +696,7 @@ |
696 | 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 | 700 | if (IS_ERR(handle)) { |
701 | 701 | err = PTR_ERR(handle); |
702 | 702 | handle = NULL; |
... | ... | @@ -886,7 +886,7 @@ |
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 | 890 | if (IS_ERR(handle)) { |
891 | 891 | status = PTR_ERR(handle); |
892 | 892 | handle = NULL; |
... | ... | @@ -1284,7 +1284,7 @@ |
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 | 1288 | if (IS_ERR(handle)) { |
1289 | 1289 | status = PTR_ERR(handle); |
1290 | 1290 | handle = NULL; |
... | ... | @@ -1652,7 +1652,7 @@ |
1652 | 1652 | } |
1653 | 1653 | } |
1654 | 1654 | |
1655 | - handle = ocfs2_start_trans(osb, NULL, credits); | |
1655 | + handle = ocfs2_start_trans(osb, credits); | |
1656 | 1656 | if (IS_ERR(handle)) { |
1657 | 1657 | status = PTR_ERR(handle); |
1658 | 1658 | handle = NULL; |
fs/ocfs2/suballoc.c
... | ... | @@ -302,7 +302,7 @@ |
302 | 302 | |
303 | 303 | credits = ocfs2_calc_group_alloc_credits(osb->sb, |
304 | 304 | le16_to_cpu(cl->cl_cpg)); |
305 | - handle = ocfs2_start_trans(osb, handle, credits); | |
305 | + handle = ocfs2_start_trans(osb, credits); | |
306 | 306 | if (IS_ERR(handle)) { |
307 | 307 | status = PTR_ERR(handle); |
308 | 308 | handle = NULL; |