]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.suse/ocfs2-Don-t-check-for-NULL-before-brelse.patch
Imported linux-2.6.27.39 suse/xen patches.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.suse / ocfs2-Don-t-check-for-NULL-before-brelse.patch
CommitLineData
2cb7cef9
BS
1From: Mark Fasheh <mfasheh@suse.com>
2Subject: ocfs2: Don't check for NULL before brelse()
3Patch-mainline: 2.6.28
4
5This is pointless as brelse() already does the check.
6
7Signed-off-by: Mark Fasheh
8---
9 fs/ocfs2/alloc.c | 33 ++++++-------------
10 fs/ocfs2/aops.c | 3 +-
11 fs/ocfs2/dir.c | 24 +++++---------
12 fs/ocfs2/file.c | 9 ++---
13 fs/ocfs2/inode.c | 7 ++--
14 fs/ocfs2/ioctl.c | 3 +-
15 fs/ocfs2/journal.c | 9 ++---
16 fs/ocfs2/localalloc.c | 15 +++------
17 fs/ocfs2/namei.c | 83 +++++++++++++++---------------------------------
18 fs/ocfs2/suballoc.c | 29 ++++++----------
19 fs/ocfs2/super.c | 3 +-
20 fs/ocfs2/symlink.c | 3 +-
21 12 files changed, 74 insertions(+), 147 deletions(-)
22
23Index: linux-2.6.27/fs/ocfs2/alloc.c
24===================================================================
25--- linux-2.6.27.orig/fs/ocfs2/alloc.c
26+++ linux-2.6.27/fs/ocfs2/alloc.c
27@@ -719,8 +719,7 @@ int ocfs2_num_free_extents(struct ocfs2_
28
29 retval = le16_to_cpu(el->l_count) - le16_to_cpu(el->l_next_free_rec);
30 bail:
31- if (eb_bh)
32- brelse(eb_bh);
33+ brelse(eb_bh);
34
35 mlog_exit(retval);
36 return retval;
37@@ -806,8 +805,7 @@ static int ocfs2_create_new_meta_bhs(str
38 bail:
39 if (status < 0) {
40 for(i = 0; i < wanted; i++) {
41- if (bhs[i])
42- brelse(bhs[i]);
43+ brelse(bhs[i]);
44 bhs[i] = NULL;
45 }
46 }
47@@ -1017,8 +1015,7 @@ static int ocfs2_add_branch(struct ocfs2
48 bail:
49 if (new_eb_bhs) {
50 for (i = 0; i < new_blocks; i++)
51- if (new_eb_bhs[i])
52- brelse(new_eb_bhs[i]);
53+ brelse(new_eb_bhs[i]);
54 kfree(new_eb_bhs);
55 }
56
57@@ -1116,8 +1113,7 @@ static int ocfs2_shift_tree_depth(struct
58 new_eb_bh = NULL;
59 status = 0;
60 bail:
61- if (new_eb_bh)
62- brelse(new_eb_bh);
63+ brelse(new_eb_bh);
64
65 mlog_exit(status);
66 return status;
67@@ -1177,10 +1173,8 @@ static int ocfs2_find_branch_target(stru
68 goto bail;
69 }
70
71- if (bh) {
72- brelse(bh);
73- bh = NULL;
74- }
75+ brelse(bh);
76+ bh = NULL;
77
78 status = ocfs2_read_block(osb, blkno, &bh, OCFS2_BH_CACHED,
79 inode);
80@@ -1199,8 +1193,7 @@ static int ocfs2_find_branch_target(stru
81
82 if (le16_to_cpu(el->l_next_free_rec) <
83 le16_to_cpu(el->l_count)) {
84- if (lowest_bh)
85- brelse(lowest_bh);
86+ brelse(lowest_bh);
87 lowest_bh = bh;
88 get_bh(lowest_bh);
89 }
90@@ -1214,8 +1207,7 @@ static int ocfs2_find_branch_target(stru
91
92 *target_bh = lowest_bh;
93 bail:
94- if (bh)
95- brelse(bh);
96+ brelse(bh);
97
98 mlog_exit(status);
99 return status;
100@@ -4480,8 +4472,7 @@ int ocfs2_insert_extent(struct ocfs2_sup
101 ocfs2_extent_map_insert_rec(inode, &rec);
102
103 bail:
104- if (last_eb_bh)
105- brelse(last_eb_bh);
106+ brelse(last_eb_bh);
107
108 mlog_exit(status);
109 return status;
110@@ -5686,8 +5677,7 @@ int ocfs2_begin_truncate_log_recovery(st
111 bail:
112 if (tl_inode)
113 iput(tl_inode);
114- if (tl_bh)
115- brelse(tl_bh);
116+ brelse(tl_bh);
117
118 if (status < 0 && (*tl_copy)) {
119 kfree(*tl_copy);
120@@ -7124,8 +7114,7 @@ static void ocfs2_free_truncate_context(
121 mlog(ML_NOTICE,
122 "Truncate completion has non-empty dealloc context\n");
123
124- if (tc->tc_last_eb_bh)
125- brelse(tc->tc_last_eb_bh);
126+ brelse(tc->tc_last_eb_bh);
127
128 kfree(tc);
129 }
130Index: linux-2.6.27/fs/ocfs2/aops.c
131===================================================================
132--- linux-2.6.27.orig/fs/ocfs2/aops.c
133+++ linux-2.6.27/fs/ocfs2/aops.c
134@@ -128,8 +128,7 @@ static int ocfs2_symlink_get_block(struc
135 err = 0;
136
137 bail:
138- if (bh)
139- brelse(bh);
140+ brelse(bh);
141
142 mlog_exit(err);
143 return err;
144Index: linux-2.6.27/fs/ocfs2/dir.c
145===================================================================
146--- linux-2.6.27.orig/fs/ocfs2/dir.c
147+++ linux-2.6.27/fs/ocfs2/dir.c
148@@ -716,8 +716,7 @@ static int ocfs2_dir_foreach_blk_el(stru
149 for (i = ra_sectors >> (sb->s_blocksize_bits - 9);
150 i > 0; i--) {
151 tmp = ocfs2_bread(inode, ++blk, &err, 1);
152- if (tmp)
153- brelse(tmp);
154+ brelse(tmp);
155 }
156 last_ra_blk = blk;
157 ra_sectors = 8;
158@@ -899,10 +898,8 @@ int ocfs2_find_files_on_disk(const char
159 leave:
160 if (status < 0) {
161 *dirent = NULL;
162- if (*dirent_bh) {
163- brelse(*dirent_bh);
164- *dirent_bh = NULL;
165- }
166+ brelse(*dirent_bh);
167+ *dirent_bh = NULL;
168 }
169
170 mlog_exit(status);
171@@ -951,8 +948,7 @@ int ocfs2_check_dir_for_entry(struct ino
172
173 ret = 0;
174 bail:
175- if (dirent_bh)
176- brelse(dirent_bh);
177+ brelse(dirent_bh);
178
179 mlog_exit(ret);
180 return ret;
181@@ -1127,8 +1123,7 @@ static int ocfs2_fill_new_dir_el(struct
182
183 status = 0;
184 bail:
185- if (new_bh)
186- brelse(new_bh);
187+ brelse(new_bh);
188
189 mlog_exit(status);
190 return status;
191@@ -1574,8 +1569,7 @@ bail:
192 if (meta_ac)
193 ocfs2_free_alloc_context(meta_ac);
194
195- if (new_bh)
196- brelse(new_bh);
197+ brelse(new_bh);
198
199 mlog_exit(status);
200 return status;
201@@ -1702,8 +1696,7 @@ static int ocfs2_find_dir_space_el(struc
202
203 status = 0;
204 bail:
205- if (bh)
206- brelse(bh);
207+ brelse(bh);
208
209 mlog_exit(status);
210 return status;
211@@ -1762,7 +1755,6 @@ int ocfs2_prepare_dir_for_insert(struct
212 *ret_de_bh = bh;
213 bh = NULL;
214 out:
215- if (bh)
216- brelse(bh);
217+ brelse(bh);
218 return ret;
219 }
220Index: linux-2.6.27/fs/ocfs2/file.c
221===================================================================
222--- linux-2.6.27.orig/fs/ocfs2/file.c
223+++ linux-2.6.27/fs/ocfs2/file.c
224@@ -671,10 +671,8 @@ leave:
225 restart_func = 0;
226 goto restart_all;
227 }
228- if (bh) {
229- brelse(bh);
230- bh = NULL;
231- }
232+ brelse(bh);
233+ bh = NULL;
234
235 mlog_exit(status);
236 return status;
237@@ -991,8 +989,7 @@ bail_unlock_rw:
238 if (size_change)
239 ocfs2_rw_unlock(inode, 1);
240 bail:
241- if (bh)
242- brelse(bh);
243+ brelse(bh);
244
245 mlog_exit(status);
246 return status;
247Index: linux-2.6.27/fs/ocfs2/inode.c
248===================================================================
249--- linux-2.6.27.orig/fs/ocfs2/inode.c
250+++ linux-2.6.27/fs/ocfs2/inode.c
251@@ -1174,10 +1174,9 @@ struct buffer_head *ocfs2_bread(struct i
252 return bh;
253
254 fail:
255- if (bh) {
256- brelse(bh);
257- bh = NULL;
258- }
259+ brelse(bh);
260+ bh = NULL;
261+
262 *err = -EIO;
263 return NULL;
264 }
265Index: linux-2.6.27/fs/ocfs2/ioctl.c
266===================================================================
267--- linux-2.6.27.orig/fs/ocfs2/ioctl.c
268+++ linux-2.6.27/fs/ocfs2/ioctl.c
269@@ -102,8 +102,7 @@ bail_unlock:
270 bail:
271 mutex_unlock(&inode->i_mutex);
272
273- if (bh)
274- brelse(bh);
275+ brelse(bh);
276
277 mlog_exit(status);
278 return status;
279Index: linux-2.6.27/fs/ocfs2/journal.c
280===================================================================
281--- linux-2.6.27.orig/fs/ocfs2/journal.c
282+++ linux-2.6.27/fs/ocfs2/journal.c
283@@ -554,8 +554,7 @@ done:
284 if (status < 0) {
285 if (inode_lock)
286 ocfs2_inode_unlock(inode, 1);
287- if (bh != NULL)
288- brelse(bh);
289+ brelse(bh);
290 if (inode) {
291 OCFS2_I(inode)->ip_open_count--;
292 iput(inode);
293@@ -869,8 +868,7 @@ static int ocfs2_force_read_journal(stru
294
295 bail:
296 for(i = 0; i < CONCURRENT_JOURNAL_FILL; i++)
297- if (bhs[i])
298- brelse(bhs[i]);
299+ brelse(bhs[i]);
300 mlog_exit(status);
301 return status;
302 }
303@@ -1286,8 +1284,7 @@ done:
304 if (inode)
305 iput(inode);
306
307- if (bh)
308- brelse(bh);
309+ brelse(bh);
310
311 mlog_exit(status);
312 return status;
313Index: linux-2.6.27/fs/ocfs2/localalloc.c
314===================================================================
315--- linux-2.6.27.orig/fs/ocfs2/localalloc.c
316+++ linux-2.6.27/fs/ocfs2/localalloc.c
317@@ -294,8 +294,7 @@ int ocfs2_load_local_alloc(struct ocfs2_
318
319 bail:
320 if (status < 0)
321- if (alloc_bh)
322- brelse(alloc_bh);
323+ brelse(alloc_bh);
324 if (inode)
325 iput(inode);
326
327@@ -411,8 +410,7 @@ out_commit:
328 ocfs2_commit_trans(osb, handle);
329
330 out_unlock:
331- if (main_bm_bh)
332- brelse(main_bm_bh);
333+ brelse(main_bm_bh);
334
335 ocfs2_inode_unlock(main_bm_inode, 1);
336
337@@ -488,8 +486,7 @@ bail:
338 *alloc_copy = NULL;
339 }
340
341- if (alloc_bh)
342- brelse(alloc_bh);
343+ brelse(alloc_bh);
344
345 if (inode) {
346 mutex_unlock(&inode->i_mutex);
347@@ -557,8 +554,7 @@ out_unlock:
348 out_mutex:
349 mutex_unlock(&main_bm_inode->i_mutex);
350
351- if (main_bm_bh)
352- brelse(main_bm_bh);
353+ brelse(main_bm_bh);
354
355 iput(main_bm_inode);
356
357@@ -1281,8 +1277,7 @@ bail:
358 if (handle)
359 ocfs2_commit_trans(osb, handle);
360
361- if (main_bm_bh)
362- brelse(main_bm_bh);
363+ brelse(main_bm_bh);
364
365 if (main_bm_inode)
366 iput(main_bm_inode);
367Index: linux-2.6.27/fs/ocfs2/namei.c
368===================================================================
369--- linux-2.6.27.orig/fs/ocfs2/namei.c
370+++ linux-2.6.27/fs/ocfs2/namei.c
371@@ -328,14 +328,9 @@ leave:
372 if (status == -ENOSPC)
373 mlog(0, "Disk is full\n");
374
375- if (new_fe_bh)
376- brelse(new_fe_bh);
377-
378- if (de_bh)
379- brelse(de_bh);
380-
381- if (parent_fe_bh)
382- brelse(parent_fe_bh);
383+ brelse(new_fe_bh);
384+ brelse(de_bh);
385+ brelse(parent_fe_bh);
386
387 if ((status < 0) && inode)
388 iput(inode);
389@@ -648,12 +643,9 @@ out_unlock_inode:
390 out:
391 ocfs2_inode_unlock(dir, 1);
392
393- if (de_bh)
394- brelse(de_bh);
395- if (fe_bh)
396- brelse(fe_bh);
397- if (parent_fe_bh)
398- brelse(parent_fe_bh);
399+ brelse(de_bh);
400+ brelse(fe_bh);
401+ brelse(parent_fe_bh);
402
403 mlog_exit(err);
404
405@@ -852,17 +844,10 @@ leave:
406 iput(orphan_dir);
407 }
408
409- if (fe_bh)
410- brelse(fe_bh);
411-
412- if (dirent_bh)
413- brelse(dirent_bh);
414-
415- if (parent_node_bh)
416- brelse(parent_node_bh);
417-
418- if (orphan_entry_bh)
419- brelse(orphan_entry_bh);
420+ brelse(fe_bh);
421+ brelse(dirent_bh);
422+ brelse(parent_node_bh);
423+ brelse(orphan_entry_bh);
424
425 mlog_exit(status);
426
427@@ -1373,24 +1358,15 @@ bail:
428
429 if (new_inode)
430 iput(new_inode);
431- if (newfe_bh)
432- brelse(newfe_bh);
433- if (old_inode_bh)
434- brelse(old_inode_bh);
435- if (old_dir_bh)
436- brelse(old_dir_bh);
437- if (new_dir_bh)
438- brelse(new_dir_bh);
439- if (new_de_bh)
440- brelse(new_de_bh);
441- if (old_de_bh)
442- brelse(old_de_bh);
443- if (old_inode_de_bh)
444- brelse(old_inode_de_bh);
445- if (orphan_entry_bh)
446- brelse(orphan_entry_bh);
447- if (insert_entry_bh)
448- brelse(insert_entry_bh);
449+ brelse(newfe_bh);
450+ brelse(old_inode_bh);
451+ brelse(old_dir_bh);
452+ brelse(new_dir_bh);
453+ brelse(new_de_bh);
454+ brelse(old_de_bh);
455+ brelse(old_inode_de_bh);
456+ brelse(orphan_entry_bh);
457+ brelse(insert_entry_bh);
458
459 mlog_exit(status);
460
461@@ -1493,8 +1469,7 @@ bail:
462
463 if (bhs) {
464 for(i = 0; i < blocks; i++)
465- if (bhs[i])
466- brelse(bhs[i]);
467+ brelse(bhs[i]);
468 kfree(bhs);
469 }
470
471@@ -1660,12 +1635,9 @@ bail:
472
473 ocfs2_inode_unlock(dir, 1);
474
475- if (new_fe_bh)
476- brelse(new_fe_bh);
477- if (parent_fe_bh)
478- brelse(parent_fe_bh);
479- if (de_bh)
480- brelse(de_bh);
481+ brelse(new_fe_bh);
482+ brelse(parent_fe_bh);
483+ brelse(de_bh);
484 if (inode_ac)
485 ocfs2_free_alloc_context(inode_ac);
486 if (data_ac)
487@@ -1760,8 +1732,7 @@ leave:
488 iput(orphan_dir_inode);
489 }
490
491- if (orphan_dir_bh)
492- brelse(orphan_dir_bh);
493+ brelse(orphan_dir_bh);
494
495 mlog_exit(status);
496 return status;
497@@ -1830,8 +1801,7 @@ static int ocfs2_orphan_add(struct ocfs2
498 (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num);
499
500 leave:
501- if (orphan_dir_bh)
502- brelse(orphan_dir_bh);
503+ brelse(orphan_dir_bh);
504
505 mlog_exit(status);
506 return status;
507@@ -1899,8 +1869,7 @@ int ocfs2_orphan_del(struct ocfs2_super
508 }
509
510 leave:
511- if (target_de_bh)
512- brelse(target_de_bh);
513+ brelse(target_de_bh);
514
515 mlog_exit(status);
516 return status;
517Index: linux-2.6.27/fs/ocfs2/suballoc.c
518===================================================================
519--- linux-2.6.27.orig/fs/ocfs2/suballoc.c
520+++ linux-2.6.27/fs/ocfs2/suballoc.c
521@@ -130,10 +130,8 @@ void ocfs2_free_ac_resource(struct ocfs2
522 iput(inode);
523 ac->ac_inode = NULL;
524 }
525- if (ac->ac_bh) {
526- brelse(ac->ac_bh);
527- ac->ac_bh = NULL;
528- }
529+ brelse(ac->ac_bh);
530+ ac->ac_bh = NULL;
531 }
532
533 void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac)
534@@ -401,8 +399,7 @@ bail:
535 if (ac)
536 ocfs2_free_alloc_context(ac);
537
538- if (bg_bh)
539- brelse(bg_bh);
540+ brelse(bg_bh);
541
542 mlog_exit(status);
543 return status;
544@@ -494,8 +491,7 @@ static int ocfs2_reserve_suballoc_bits(s
545 get_bh(bh);
546 ac->ac_bh = bh;
547 bail:
548- if (bh)
549- brelse(bh);
550+ brelse(bh);
551
552 mlog_exit(status);
553 return status;
554@@ -1270,10 +1266,9 @@ static int ocfs2_search_chain(struct ocf
555 if (!bg->bg_next_group)
556 break;
557
558- if (prev_group_bh) {
559- brelse(prev_group_bh);
560- prev_group_bh = NULL;
561- }
562+ brelse(prev_group_bh);
563+ prev_group_bh = NULL;
564+
565 next_group = le64_to_cpu(bg->bg_next_group);
566 prev_group_bh = group_bh;
567 group_bh = NULL;
568@@ -1368,10 +1363,8 @@ static int ocfs2_search_chain(struct ocf
569 *bg_blkno = le64_to_cpu(bg->bg_blkno);
570 *bits_left = le16_to_cpu(bg->bg_free_bits_count);
571 bail:
572- if (group_bh)
573- brelse(group_bh);
574- if (prev_group_bh)
575- brelse(prev_group_bh);
576+ brelse(group_bh);
577+ brelse(prev_group_bh);
578
579 mlog_exit(status);
580 return status;
581@@ -1845,8 +1838,7 @@ int ocfs2_free_suballoc_bits(handle_t *h
582 }
583
584 bail:
585- if (group_bh)
586- brelse(group_bh);
587+ brelse(group_bh);
588
589 mlog_exit(status);
590 return status;
591Index: linux-2.6.27/fs/ocfs2/super.c
592===================================================================
593--- linux-2.6.27.orig/fs/ocfs2/super.c
594+++ linux-2.6.27/fs/ocfs2/super.c
595@@ -762,8 +762,7 @@ static int ocfs2_fill_super(struct super
596 return status;
597
598 read_super_error:
599- if (bh != NULL)
600- brelse(bh);
601+ brelse(bh);
602
603 if (inode)
604 iput(inode);
605Index: linux-2.6.27/fs/ocfs2/symlink.c
606===================================================================
607--- linux-2.6.27.orig/fs/ocfs2/symlink.c
608+++ linux-2.6.27/fs/ocfs2/symlink.c
609@@ -158,8 +158,7 @@ bail:
610 kunmap(page);
611 page_cache_release(page);
612 }
613- if (bh)
614- brelse(bh);
615+ brelse(bh);
616
617 return ERR_PTR(status);
618 }