aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-10-09 20:20:31 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-14 14:51:57 -0400
commit0fcaa56a2a020dd6f90c202b7084e6f4cbedb6c2 (patch)
tree057204016523ce0274d4a23ec02944075f084e8c
parent31d33073ca38603dea705dae45e094a64ca062d6 (diff)
ocfs2: Simplify ocfs2_read_block()
More than 30 callers of ocfs2_read_block() pass exactly OCFS2_BH_CACHED. Only six pass a different flag set. Rather than have every caller care, let's make ocfs2_read_block() take no flags and always do a cached read. The remaining six places can call ocfs2_read_blocks() directly. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
-rw-r--r--fs/ocfs2/alloc.c25
-rw-r--r--fs/ocfs2/aops.c6
-rw-r--r--fs/ocfs2/buffer_head_io.h7
-rw-r--r--fs/ocfs2/dir.c9
-rw-r--r--fs/ocfs2/dlmglue.c8
-rw-r--r--fs/ocfs2/extent_map.c8
-rw-r--r--fs/ocfs2/file.c7
-rw-r--r--fs/ocfs2/inode.c4
-rw-r--r--fs/ocfs2/journal.c2
-rw-r--r--fs/ocfs2/localalloc.c8
-rw-r--r--fs/ocfs2/namei.c2
-rw-r--r--fs/ocfs2/resize.c3
-rw-r--r--fs/ocfs2/slot_map.c2
-rw-r--r--fs/ocfs2/suballoc.c11
-rw-r--r--fs/ocfs2/symlink.c5
-rw-r--r--fs/ocfs2/xattr.c42
16 files changed, 55 insertions, 94 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index a164e09491f..0cc2deb9394 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -706,7 +706,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb,
706 706
707 if (last_eb_blk) { 707 if (last_eb_blk) {
708 retval = ocfs2_read_block(inode, last_eb_blk, 708 retval = ocfs2_read_block(inode, last_eb_blk,
709 &eb_bh, OCFS2_BH_CACHED); 709 &eb_bh);
710 if (retval < 0) { 710 if (retval < 0) {
711 mlog_errno(retval); 711 mlog_errno(retval);
712 goto bail; 712 goto bail;
@@ -1176,7 +1176,7 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb,
1176 brelse(bh); 1176 brelse(bh);
1177 bh = NULL; 1177 bh = NULL;
1178 1178
1179 status = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED); 1179 status = ocfs2_read_block(inode, blkno, &bh);
1180 if (status < 0) { 1180 if (status < 0) {
1181 mlog_errno(status); 1181 mlog_errno(status);
1182 goto bail; 1182 goto bail;
@@ -1540,7 +1540,7 @@ static int __ocfs2_find_path(struct inode *inode,
1540 1540
1541 brelse(bh); 1541 brelse(bh);
1542 bh = NULL; 1542 bh = NULL;
1543 ret = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED); 1543 ret = ocfs2_read_block(inode, blkno, &bh);
1544 if (ret) { 1544 if (ret) {
1545 mlog_errno(ret); 1545 mlog_errno(ret);
1546 goto out; 1546 goto out;
@@ -4294,9 +4294,7 @@ static int ocfs2_figure_insert_type(struct inode *inode,
4294 * ocfs2_figure_insert_type() and ocfs2_add_branch() 4294 * ocfs2_figure_insert_type() and ocfs2_add_branch()
4295 * may want it later. 4295 * may want it later.
4296 */ 4296 */
4297 ret = ocfs2_read_block(inode, 4297 ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), &bh);
4298 ocfs2_et_get_last_eb_blk(et), &bh,
4299 OCFS2_BH_CACHED);
4300 if (ret) { 4298 if (ret) {
4301 mlog_exit(ret); 4299 mlog_exit(ret);
4302 goto out; 4300 goto out;
@@ -4762,9 +4760,8 @@ static int __ocfs2_mark_extent_written(struct inode *inode,
4762 if (path->p_tree_depth) { 4760 if (path->p_tree_depth) {
4763 struct ocfs2_extent_block *eb; 4761 struct ocfs2_extent_block *eb;
4764 4762
4765 ret = ocfs2_read_block(inode, 4763 ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et),
4766 ocfs2_et_get_last_eb_blk(et), 4764 &last_eb_bh);
4767 &last_eb_bh, OCFS2_BH_CACHED);
4768 if (ret) { 4765 if (ret) {
4769 mlog_exit(ret); 4766 mlog_exit(ret);
4770 goto out; 4767 goto out;
@@ -4921,9 +4918,8 @@ static int ocfs2_split_tree(struct inode *inode, struct ocfs2_extent_tree *et,
4921 4918
4922 depth = path->p_tree_depth; 4919 depth = path->p_tree_depth;
4923 if (depth > 0) { 4920 if (depth > 0) {
4924 ret = ocfs2_read_block(inode, 4921 ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et),
4925 ocfs2_et_get_last_eb_blk(et), 4922 &last_eb_bh);
4926 &last_eb_bh, OCFS2_BH_CACHED);
4927 if (ret < 0) { 4923 if (ret < 0) {
4928 mlog_errno(ret); 4924 mlog_errno(ret);
4929 goto out; 4925 goto out;
@@ -5590,8 +5586,7 @@ static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb,
5590 goto bail; 5586 goto bail;
5591 } 5587 }
5592 5588
5593 status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh, 5589 status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh);
5594 OCFS2_BH_CACHED);
5595 if (status < 0) { 5590 if (status < 0) {
5596 iput(inode); 5591 iput(inode);
5597 mlog_errno(status); 5592 mlog_errno(status);
@@ -6990,7 +6985,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
6990 6985
6991 if (fe->id2.i_list.l_tree_depth) { 6986 if (fe->id2.i_list.l_tree_depth) {
6992 status = ocfs2_read_block(inode, le64_to_cpu(fe->i_last_eb_blk), 6987 status = ocfs2_read_block(inode, le64_to_cpu(fe->i_last_eb_blk),
6993 &last_eb_bh, OCFS2_BH_CACHED); 6988 &last_eb_bh);
6994 if (status < 0) { 6989 if (status < 0) {
6995 mlog_errno(status); 6990 mlog_errno(status);
6996 goto bail; 6991 goto bail;
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index f232a0e3c30..c22543b3342 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -68,8 +68,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
68 goto bail; 68 goto bail;
69 } 69 }
70 70
71 status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, 71 status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh);
72 &bh, OCFS2_BH_CACHED);
73 if (status < 0) { 72 if (status < 0) {
74 mlog_errno(status); 73 mlog_errno(status);
75 goto bail; 74 goto bail;
@@ -263,8 +262,7 @@ static int ocfs2_readpage_inline(struct inode *inode, struct page *page)
263 BUG_ON(!PageLocked(page)); 262 BUG_ON(!PageLocked(page));
264 BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)); 263 BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL));
265 264
266 ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh, 265 ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh);
267 OCFS2_BH_CACHED);
268 if (ret) { 266 if (ret) {
269 mlog_errno(ret); 267 mlog_errno(ret);
270 goto out; 268 goto out;
diff --git a/fs/ocfs2/buffer_head_io.h b/fs/ocfs2/buffer_head_io.h
index fd0d774ac35..a2ef9e5f8bf 100644
--- a/fs/ocfs2/buffer_head_io.h
+++ b/fs/ocfs2/buffer_head_io.h
@@ -33,8 +33,7 @@ void ocfs2_end_buffer_io_sync(struct buffer_head *bh,
33 33
34static inline int ocfs2_read_block(struct inode *inode, 34static inline int ocfs2_read_block(struct inode *inode,
35 u64 off, 35 u64 off,
36 struct buffer_head **bh, 36 struct buffer_head **bh);
37 int flags);
38 37
39int ocfs2_write_block(struct ocfs2_super *osb, 38int ocfs2_write_block(struct ocfs2_super *osb,
40 struct buffer_head *bh, 39 struct buffer_head *bh,
@@ -54,7 +53,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
54#define OCFS2_BH_READAHEAD 8 53#define OCFS2_BH_READAHEAD 8
55 54
56static inline int ocfs2_read_block(struct inode *inode, u64 off, 55static inline int ocfs2_read_block(struct inode *inode, u64 off,
57 struct buffer_head **bh, int flags) 56 struct buffer_head **bh)
58{ 57{
59 int status = 0; 58 int status = 0;
60 59
@@ -64,7 +63,7 @@ static inline int ocfs2_read_block(struct inode *inode, u64 off,
64 goto bail; 63 goto bail;
65 } 64 }
66 65
67 status = ocfs2_read_blocks(inode, off, 1, bh, flags); 66 status = ocfs2_read_blocks(inode, off, 1, bh, OCFS2_BH_CACHED);
68 67
69bail: 68bail:
70 return status; 69 return status;
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 828437ca91b..459e6b8467d 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -188,8 +188,7 @@ static struct buffer_head *ocfs2_find_entry_id(const char *name,
188 struct ocfs2_dinode *di; 188 struct ocfs2_dinode *di;
189 struct ocfs2_inline_data *data; 189 struct ocfs2_inline_data *data;
190 190
191 ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh, 191 ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh);
192 OCFS2_BH_CACHED);
193 if (ret) { 192 if (ret) {
194 mlog_errno(ret); 193 mlog_errno(ret);
195 goto out; 194 goto out;
@@ -417,8 +416,7 @@ static inline int ocfs2_delete_entry_id(handle_t *handle,
417 struct ocfs2_dinode *di; 416 struct ocfs2_dinode *di;
418 struct ocfs2_inline_data *data; 417 struct ocfs2_inline_data *data;
419 418
420 ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, 419 ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh);
421 &di_bh, OCFS2_BH_CACHED);
422 if (ret) { 420 if (ret) {
423 mlog_errno(ret); 421 mlog_errno(ret);
424 goto out; 422 goto out;
@@ -596,8 +594,7 @@ static int ocfs2_dir_foreach_blk_id(struct inode *inode,
596 struct ocfs2_inline_data *data;