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>
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 63037bd..c25780a 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -537,9 +537,7 @@
if (!di->i_xattr_loc)
return ret;
- ret = ocfs2_read_block(inode,
- le64_to_cpu(di->i_xattr_loc),
- &blk_bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh);
if (ret < 0) {
mlog_errno(ret);
return ret;
@@ -672,8 +670,7 @@
blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
/* Copy ocfs2_xattr_value */
for (i = 0; i < num_clusters * bpc; i++, blkno++) {
- ret = ocfs2_read_block(inode, blkno,
- &bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, blkno, &bh);
if (ret) {
mlog_errno(ret);
goto out;
@@ -764,9 +761,7 @@
memset(&xs->bucket, 0, sizeof(xs->bucket));
- ret = ocfs2_read_block(inode,
- le64_to_cpu(di->i_xattr_loc),
- &blk_bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh);
if (ret < 0) {
mlog_errno(ret);
return ret;
@@ -922,8 +917,7 @@
blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
for (i = 0; i < num_clusters * bpc; i++, blkno++) {
- ret = ocfs2_read_block(inode, blkno,
- &bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, blkno, &bh);
if (ret) {
mlog_errno(ret);
goto out_commit;
@@ -1514,8 +1508,7 @@
u64 blk, bg_blkno;
u16 bit;
- ret = ocfs2_read_block(inode, block, &blk_bh,
- OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, block, &blk_bh);
if (ret < 0) {
mlog_errno(ret);
goto out;
@@ -1773,9 +1766,7 @@
if (!di->i_xattr_loc)
return ret;
- ret = ocfs2_read_block(inode,
- le64_to_cpu(di->i_xattr_loc),
- &blk_bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh);
if (ret < 0) {
mlog_errno(ret);
return ret;
@@ -2216,9 +2207,8 @@
break;
}
- ret = ocfs2_read_block(inode,
- header_bh->b_blocknr + block_off,
- &name_bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, header_bh->b_blocknr + block_off,
+ &name_bh);
if (ret) {
mlog_errno(ret);
break;
@@ -2269,7 +2259,7 @@
u32 last_hash;
u64 blkno;
- ret = ocfs2_read_block(inode, p_blkno, &bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, p_blkno, &bh);
if (ret) {
mlog_errno(ret);
goto out;
@@ -2285,7 +2275,7 @@
blkno = p_blkno + bucket * blk_per_bucket;
- ret = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, blkno, &bh);
if (ret) {
mlog_errno(ret);
goto out;
@@ -2898,7 +2888,6 @@
u64 blkno = bucket->bhs[0]->b_blocknr;
u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
u16 xh_free_start;
- struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
size_t blocksize = inode->i_sb->s_blocksize;
handle_t *handle;
struct buffer_head **bhs;
@@ -3110,8 +3099,7 @@
goto out;
}
- ret = ocfs2_read_block(inode, prev_blkno,
- &old_bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, prev_blkno, &old_bh);
if (ret < 0) {
mlog_errno(ret);
brelse(new_bh);
@@ -3481,7 +3469,7 @@
ocfs2_journal_dirty(handle, first_bh);
/* update the new bucket header. */
- ret = ocfs2_read_block(inode, to_blk_start, &bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, to_blk_start, &bh);
if (ret < 0) {
mlog_errno(ret);
goto out;
@@ -3868,8 +3856,7 @@
goto out;
}
- ret = ocfs2_read_block(inode, p_blkno,
- &first_bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, p_blkno, &first_bh);
if (ret) {
mlog_errno(ret);
goto out;
@@ -4220,8 +4207,7 @@
BUG_ON(value_blk != (offset + OCFS2_XATTR_ROOT_SIZE - 1) / blocksize);
value_blk += header_bh->b_blocknr;
- ret = ocfs2_read_block(inode, value_blk,
- &value_bh, OCFS2_BH_CACHED);
+ ret = ocfs2_read_block(inode, value_blk, &value_bh);
if (ret) {
mlog_errno(ret);
goto out;