1 From: Joel Becker <joel.becker@oracle.com>
2 Subject: ocfs2: Simplify ocfs2_read_block()
5 More than 30 callers of ocfs2_read_block() pass exactly OCFS2_BH_CACHED.
6 Only six pass a different flag set. Rather than have every caller care,
7 let's make ocfs2_read_block() take no flags and always do a cached read.
8 The remaining six places can call ocfs2_read_blocks() directly.
10 Signed-off-by: Joel Becker <joel.becker@oracle.com>
11 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
13 fs/ocfs2/alloc.c | 25 ++++++++++---------------
14 fs/ocfs2/aops.c | 6 ++----
15 fs/ocfs2/buffer_head_io.h | 7 +++----
16 fs/ocfs2/dir.c | 9 +++------
17 fs/ocfs2/dlmglue.c | 8 ++------
18 fs/ocfs2/extent_map.c | 8 +++-----
19 fs/ocfs2/file.c | 7 +++----
20 fs/ocfs2/inode.c | 4 ++--
21 fs/ocfs2/journal.c | 2 +-
22 fs/ocfs2/localalloc.c | 8 ++++----
23 fs/ocfs2/namei.c | 2 +-
24 fs/ocfs2/resize.c | 3 +--
25 fs/ocfs2/slot_map.c | 2 +-
26 fs/ocfs2/suballoc.c | 11 ++++-------
27 fs/ocfs2/symlink.c | 5 +----
28 fs/ocfs2/xattr.c | 42 ++++++++++++++----------------------------
29 16 files changed, 55 insertions(+), 94 deletions(-)
31 Index: linux-2.6.27/fs/ocfs2/alloc.c
32 ===================================================================
33 --- linux-2.6.27.orig/fs/ocfs2/alloc.c
34 +++ linux-2.6.27/fs/ocfs2/alloc.c
35 @@ -706,7 +706,7 @@ int ocfs2_num_free_extents(struct ocfs2_
38 retval = ocfs2_read_block(inode, last_eb_blk,
39 - &eb_bh, OCFS2_BH_CACHED);
44 @@ -1176,7 +1176,7 @@ static int ocfs2_find_branch_target(stru
48 - status = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED);
49 + status = ocfs2_read_block(inode, blkno, &bh);
53 @@ -1549,7 +1549,7 @@ static int __ocfs2_find_path(struct inod
57 - ret = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED);
58 + ret = ocfs2_read_block(inode, blkno, &bh);
62 @@ -4303,9 +4303,7 @@ static int ocfs2_figure_insert_type(stru
63 * ocfs2_figure_insert_type() and ocfs2_add_branch()
66 - ret = ocfs2_read_block(inode,
67 - ocfs2_et_get_last_eb_blk(et), &bh,
69 + ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), &bh);
73 @@ -4771,9 +4769,8 @@ static int __ocfs2_mark_extent_written(s
74 if (path->p_tree_depth) {
75 struct ocfs2_extent_block *eb;
77 - ret = ocfs2_read_block(inode,
78 - ocfs2_et_get_last_eb_blk(et),
79 - &last_eb_bh, OCFS2_BH_CACHED);
80 + ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et),
85 @@ -4930,9 +4927,8 @@ static int ocfs2_split_tree(struct inode
87 depth = path->p_tree_depth;
89 - ret = ocfs2_read_block(inode,
90 - ocfs2_et_get_last_eb_blk(et),
91 - &last_eb_bh, OCFS2_BH_CACHED);
92 + ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et),
97 @@ -5599,8 +5595,7 @@ static int ocfs2_get_truncate_log_info(s
101 - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh,
103 + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh);
107 @@ -6999,7 +6994,7 @@ int ocfs2_prepare_truncate(struct ocfs2_
109 if (fe->id2.i_list.l_tree_depth) {
110 status = ocfs2_read_block(inode, le64_to_cpu(fe->i_last_eb_blk),
111 - &last_eb_bh, OCFS2_BH_CACHED);
116 Index: linux-2.6.27/fs/ocfs2/aops.c
117 ===================================================================
118 --- linux-2.6.27.orig/fs/ocfs2/aops.c
119 +++ linux-2.6.27/fs/ocfs2/aops.c
120 @@ -68,8 +68,7 @@ static int ocfs2_symlink_get_block(struc
124 - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno,
125 - &bh, OCFS2_BH_CACHED);
126 + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh);
130 @@ -263,8 +262,7 @@ static int ocfs2_readpage_inline(struct
131 BUG_ON(!PageLocked(page));
132 BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL));
134 - ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh,
136 + ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh);
140 Index: linux-2.6.27/fs/ocfs2/buffer_head_io.h
141 ===================================================================
142 --- linux-2.6.27.orig/fs/ocfs2/buffer_head_io.h
143 +++ linux-2.6.27/fs/ocfs2/buffer_head_io.h
144 @@ -33,8 +33,7 @@ void ocfs2_end_buffer_io_sync(struct buf
146 static inline int ocfs2_read_block(struct inode *inode,
148 - struct buffer_head **bh,
150 + struct buffer_head **bh);
152 int ocfs2_write_block(struct ocfs2_super *osb,
153 struct buffer_head *bh,
154 @@ -54,7 +53,7 @@ int ocfs2_write_super_or_backup(struct o
155 #define OCFS2_BH_READAHEAD 8
157 static inline int ocfs2_read_block(struct inode *inode, u64 off,
158 - struct buffer_head **bh, int flags)
159 + struct buffer_head **bh)
163 @@ -64,7 +63,7 @@ static inline int ocfs2_read_block(struc
167 - status = ocfs2_read_blocks(inode, off, 1, bh, flags);
168 + status = ocfs2_read_blocks(inode, off, 1, bh, OCFS2_BH_CACHED);
172 Index: linux-2.6.27/fs/ocfs2/dir.c
173 ===================================================================
174 --- linux-2.6.27.orig/fs/ocfs2/dir.c
175 +++ linux-2.6.27/fs/ocfs2/dir.c
176 @@ -188,8 +188,7 @@ static struct buffer_head *ocfs2_find_en
177 struct ocfs2_dinode *di;
178 struct ocfs2_inline_data *data;
180 - ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh,
182 + ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh);
186 @@ -417,8 +416,7 @@ static inline int ocfs2_delete_entry_id(
187 struct ocfs2_dinode *di;
188 struct ocfs2_inline_data *data;
190 - ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno,
191 - &di_bh, OCFS2_BH_CACHED);
192 + ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh);
196 @@ -596,8 +594,7 @@ static int ocfs2_dir_foreach_blk_id(stru
197 struct ocfs2_inline_data *data;
198 struct ocfs2_dir_entry *de;
200 - ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno,
201 - &di_bh, OCFS2_BH_CACHED);
202 + ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh);
204 mlog(ML_ERROR, "Unable to read inode block for dir %llu\n",
205 (unsigned long long)OCFS2_I(inode)->ip_blkno);
206 Index: linux-2.6.27/fs/ocfs2/dlmglue.c
207 ===================================================================
208 --- linux-2.6.27.orig/fs/ocfs2/dlmglue.c
209 +++ linux-2.6.27/fs/ocfs2/dlmglue.c
210 @@ -2024,8 +2024,7 @@ static int ocfs2_inode_lock_update(struc
212 /* Boo, we have to go to disk. */
213 /* read bh, cast, ocfs2_refresh_inode */
214 - status = ocfs2_read_block(inode, oi->ip_blkno,
215 - bh, OCFS2_BH_CACHED);
216 + status = ocfs2_read_block(inode, oi->ip_blkno, bh);
220 @@ -2086,10 +2085,7 @@ static int ocfs2_assign_bh(struct inode
224 - status = ocfs2_read_block(inode,
225 - OCFS2_I(inode)->ip_blkno,
228 + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, ret_bh);
232 Index: linux-2.6.27/fs/ocfs2/extent_map.c
233 ===================================================================
234 --- linux-2.6.27.orig/fs/ocfs2/extent_map.c
235 +++ linux-2.6.27/fs/ocfs2/extent_map.c
236 @@ -337,7 +337,7 @@ static int ocfs2_figure_hole_clusters(st
238 ret = ocfs2_read_block(inode,
239 le64_to_cpu(eb->h_next_leaf_blk),
240 - &next_eb_bh, OCFS2_BH_CACHED);
245 @@ -458,8 +458,7 @@ int ocfs2_get_clusters(struct inode *ino
249 - ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno,
250 - &di_bh, OCFS2_BH_CACHED);
251 + ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh);
255 Index: linux-2.6.27/fs/ocfs2/file.c
256 ===================================================================
257 --- linux-2.6.27.orig/fs/ocfs2/file.c
258 +++ linux-2.6.27/fs/ocfs2/file.c
259 @@ -545,8 +545,7 @@ static int __ocfs2_extend_allocation(str
261 BUG_ON(mark_unwritten && !ocfs2_sparse_alloc(osb));
263 - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh,
265 + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh);
269 @@ -1132,7 +1131,7 @@ static int ocfs2_write_remove_suid(struc
270 struct buffer_head *bh = NULL;
271 struct ocfs2_inode_info *oi = OCFS2_I(inode);
273 - ret = ocfs2_read_block(inode, oi->ip_blkno, &bh, OCFS2_BH_CACHED);
274 + ret = ocfs2_read_block(inode, oi->ip_blkno, &bh);
278 @@ -1159,7 +1158,7 @@ static int ocfs2_allocate_unwritten_exte
280 if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
281 ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno,
282 - &di_bh, OCFS2_BH_CACHED);
287 Index: linux-2.6.27/fs/ocfs2/inode.c
288 ===================================================================
289 --- linux-2.6.27.orig/fs/ocfs2/inode.c
290 +++ linux-2.6.27/fs/ocfs2/inode.c
291 @@ -461,7 +461,7 @@ static int ocfs2_read_locked_inode(struc
295 - status = ocfs2_read_block(inode, args->fi_blkno, &bh, 0);
296 + status = ocfs2_read_blocks(inode, args->fi_blkno, 1, &bh, 0);
298 status = ocfs2_read_blocks_sync(osb, args->fi_blkno, 1, &bh);
300 @@ -1165,7 +1165,7 @@ struct buffer_head *ocfs2_bread(struct i
304 - tmperr = ocfs2_read_block(inode, p_blkno, &bh, readflags);
305 + tmperr = ocfs2_read_blocks(inode, p_blkno, 1, &bh, readflags);
309 Index: linux-2.6.27/fs/ocfs2/journal.c
310 ===================================================================
311 --- linux-2.6.27.orig/fs/ocfs2/journal.c
312 +++ linux-2.6.27/fs/ocfs2/journal.c
313 @@ -1134,7 +1134,7 @@ static int ocfs2_read_journal_inode(stru
315 SET_INODE_JOURNAL(inode);
317 - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, bh, 0);
318 + status = ocfs2_read_blocks(inode, OCFS2_I(inode)->ip_blkno, 1, bh, 0);
322 Index: linux-2.6.27/fs/ocfs2/localalloc.c
323 ===================================================================
324 --- linux-2.6.27.orig/fs/ocfs2/localalloc.c
325 +++ linux-2.6.27/fs/ocfs2/localalloc.c
326 @@ -248,8 +248,8 @@ int ocfs2_load_local_alloc(struct ocfs2_
330 - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno,
332 + status = ocfs2_read_blocks(inode, OCFS2_I(inode)->ip_blkno, 1,
337 @@ -459,8 +459,8 @@ int ocfs2_begin_local_alloc_recovery(str
339 mutex_lock(&inode->i_mutex);
341 - status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno,
343 + status = ocfs2_read_blocks(inode, OCFS2_I(inode)->ip_blkno, 1,
348 Index: linux-2.6.27/fs/ocfs2/namei.c
349 ===================================================================
350 --- linux-2.6.27.orig/fs/ocfs2/namei.c
351 +++ linux-2.6.27/fs/ocfs2/namei.c
352 @@ -1754,7 +1754,7 @@ static int ocfs2_orphan_add(struct ocfs2
354 status = ocfs2_read_block(orphan_dir_inode,
355 OCFS2_I(orphan_dir_inode)->ip_blkno,
356 - &orphan_dir_bh, OCFS2_BH_CACHED);
361 Index: linux-2.6.27/fs/ocfs2/resize.c
362 ===================================================================
363 --- linux-2.6.27.orig/fs/ocfs2/resize.c
364 +++ linux-2.6.27/fs/ocfs2/resize.c
365 @@ -332,8 +332,7 @@ int ocfs2_group_extend(struct inode * in
366 lgd_blkno = ocfs2_which_cluster_group(main_bm_inode,
367 first_new_cluster - 1);
369 - ret = ocfs2_read_block(main_bm_inode, lgd_blkno, &group_bh,
371 + ret = ocfs2_read_block(main_bm_inode, lgd_blkno, &group_bh);
375 Index: linux-2.6.27/fs/ocfs2/slot_map.c
376 ===================================================================
377 --- linux-2.6.27.orig/fs/ocfs2/slot_map.c
378 +++ linux-2.6.27/fs/ocfs2/slot_map.c
379 @@ -403,7 +403,7 @@ static int ocfs2_map_slot_buffers(struct
380 (unsigned long long)blkno);
382 bh = NULL; /* Acquire a fresh bh */
383 - status = ocfs2_read_block(si->si_inode, blkno, &bh, 0);
384 + status = ocfs2_read_blocks(si->si_inode, blkno, 1, &bh, 0);
388 Index: linux-2.6.27/fs/ocfs2/suballoc.c
389 ===================================================================
390 --- linux-2.6.27.orig/fs/ocfs2/suballoc.c
391 +++ linux-2.6.27/fs/ocfs2/suballoc.c
392 @@ -1172,8 +1172,7 @@ static int ocfs2_search_one_group(struct
393 struct ocfs2_group_desc *gd;
394 struct inode *alloc_inode = ac->ac_inode;
396 - ret = ocfs2_read_block(alloc_inode, gd_blkno,
397 - &group_bh, OCFS2_BH_CACHED);
398 + ret = ocfs2_read_block(alloc_inode, gd_blkno, &group_bh);
402 @@ -1244,7 +1243,7 @@ static int ocfs2_search_chain(struct ocf
404 status = ocfs2_read_block(alloc_inode,
405 le64_to_cpu(cl->cl_recs[chain].c_blkno),
406 - &group_bh, OCFS2_BH_CACHED);
411 @@ -1273,8 +1272,7 @@ static int ocfs2_search_chain(struct ocf
412 prev_group_bh = group_bh;
414 status = ocfs2_read_block(alloc_inode,
415 - next_group, &group_bh,
417 + next_group, &group_bh);
421 @@ -1795,8 +1793,7 @@ int ocfs2_free_suballoc_bits(handle_t *h
422 (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, count,
423 (unsigned long long)bg_blkno, start_bit);
425 - status = ocfs2_read_block(alloc_inode, bg_blkno, &group_bh,
427 + status = ocfs2_read_block(alloc_inode, bg_blkno, &group_bh);
431 Index: linux-2.6.27/fs/ocfs2/symlink.c
432 ===================================================================
433 --- linux-2.6.27.orig/fs/ocfs2/symlink.c
434 +++ linux-2.6.27/fs/ocfs2/symlink.c
435 @@ -84,10 +84,7 @@ static char *ocfs2_fast_symlink_getlink(
439 - status = ocfs2_read_block(inode,
440 - OCFS2_I(inode)->ip_blkno,
443 + status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, bh);
446 link = ERR_PTR(status);
447 Index: linux-2.6.27/fs/ocfs2/xattr.c
448 ===================================================================
449 --- linux-2.6.27.orig/fs/ocfs2/xattr.c
450 +++ linux-2.6.27/fs/ocfs2/xattr.c
451 @@ -553,9 +553,7 @@ static int ocfs2_xattr_block_list(struct
452 if (!di->i_xattr_loc)
455 - ret = ocfs2_read_block(inode,
456 - le64_to_cpu(di->i_xattr_loc),
457 - &blk_bh, OCFS2_BH_CACHED);
458 + ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh);
462 @@ -688,8 +686,7 @@ static int ocfs2_xattr_get_value_outside
463 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
464 /* Copy ocfs2_xattr_value */
465 for (i = 0; i < num_clusters * bpc; i++, blkno++) {
466 - ret = ocfs2_read_block(inode, blkno,
467 - &bh, OCFS2_BH_CACHED);
468 + ret = ocfs2_read_block(inode, blkno, &bh);
472 @@ -780,9 +777,7 @@ static int ocfs2_xattr_block_get(struct
474 memset(&xs->bucket, 0, sizeof(xs->bucket));
476 - ret = ocfs2_read_block(inode,
477 - le64_to_cpu(di->i_xattr_loc),
478 - &blk_bh, OCFS2_BH_CACHED);
479 + ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh);
483 @@ -938,8 +933,7 @@ static int __ocfs2_xattr_set_value_outsi
484 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
486 for (i = 0; i < num_clusters * bpc; i++, blkno++) {
487 - ret = ocfs2_read_block(inode, blkno,
488 - &bh, OCFS2_BH_CACHED);
489 + ret = ocfs2_read_block(inode, blkno, &bh);
493 @@ -1530,8 +1524,7 @@ static int ocfs2_xattr_free_block(struct
497 - ret = ocfs2_read_block(inode, block, &blk_bh,
499 + ret = ocfs2_read_block(inode, block, &blk_bh);
503 @@ -1789,9 +1782,7 @@ static int ocfs2_xattr_block_find(struct
504 if (!di->i_xattr_loc)
507 - ret = ocfs2_read_block(inode,
508 - le64_to_cpu(di->i_xattr_loc),
509 - &blk_bh, OCFS2_BH_CACHED);
510 + ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh);
514 @@ -2232,9 +2223,8 @@ static int ocfs2_find_xe_in_bucket(struc
518 - ret = ocfs2_read_block(inode,
519 - header_bh->b_blocknr + block_off,
520 - &name_bh, OCFS2_BH_CACHED);
521 + ret = ocfs2_read_block(inode, header_bh->b_blocknr + block_off,
526 @@ -2285,7 +2275,7 @@ static int ocfs2_xattr_bucket_find(struc
530 - ret = ocfs2_read_block(inode, p_blkno, &bh, OCFS2_BH_CACHED);
531 + ret = ocfs2_read_block(inode, p_blkno, &bh);
535 @@ -2301,7 +2291,7 @@ static int ocfs2_xattr_bucket_find(struc
537 blkno = p_blkno + bucket * blk_per_bucket;
539 - ret = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED);
540 + ret = ocfs2_read_block(inode, blkno, &bh);
544 @@ -2914,7 +2904,6 @@ static int ocfs2_defrag_xattr_bucket(str
545 u64 blkno = bucket->bhs[0]->b_blocknr;
546 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
548 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
549 size_t blocksize = inode->i_sb->s_blocksize;
551 struct buffer_head **bhs;
552 @@ -3126,8 +3115,7 @@ static int ocfs2_mv_xattr_bucket_cross_c
556 - ret = ocfs2_read_block(inode, prev_blkno,
557 - &old_bh, OCFS2_BH_CACHED);
558 + ret = ocfs2_read_block(inode, prev_blkno, &old_bh);
562 @@ -3497,7 +3485,7 @@ static int ocfs2_cp_xattr_cluster(struct
563 ocfs2_journal_dirty(handle, first_bh);
565 /* update the new bucket header. */
566 - ret = ocfs2_read_block(inode, to_blk_start, &bh, OCFS2_BH_CACHED);
567 + ret = ocfs2_read_block(inode, to_blk_start, &bh);
571 @@ -3884,8 +3872,7 @@ static int ocfs2_add_new_xattr_bucket(st
575 - ret = ocfs2_read_block(inode, p_blkno,
576 - &first_bh, OCFS2_BH_CACHED);
577 + ret = ocfs2_read_block(inode, p_blkno, &first_bh);
581 @@ -4236,8 +4223,7 @@ static int ocfs2_xattr_bucket_value_trun
582 BUG_ON(value_blk != (offset + OCFS2_XATTR_ROOT_SIZE - 1) / blocksize);
583 value_blk += header_bh->b_blocknr;
585 - ret = ocfs2_read_block(inode, value_blk,
586 - &value_bh, OCFS2_BH_CACHED);
587 + ret = ocfs2_read_block(inode, value_blk, &value_bh);