Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0fcaa56a authored by Joel Becker's avatar Joel Becker Committed by Mark Fasheh
Browse files

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: default avatarJoel Becker <joel.becker@oracle.com>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent 31d33073
Loading
Loading
Loading
Loading
+10 −15
Original line number Diff line number Diff line
@@ -706,7 +706,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb,

	if (last_eb_blk) {
		retval = ocfs2_read_block(inode, last_eb_blk,
					  &eb_bh, OCFS2_BH_CACHED);
					  &eb_bh);
		if (retval < 0) {
			mlog_errno(retval);
			goto bail;
@@ -1176,7 +1176,7 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb,
		brelse(bh);
		bh = NULL;

		status = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED);
		status = ocfs2_read_block(inode, blkno, &bh);
		if (status < 0) {
			mlog_errno(status);
			goto bail;
@@ -1540,7 +1540,7 @@ static int __ocfs2_find_path(struct inode *inode,

		brelse(bh);
		bh = NULL;
		ret = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED);
		ret = ocfs2_read_block(inode, blkno, &bh);
		if (ret) {
			mlog_errno(ret);
			goto out;
@@ -4294,9 +4294,7 @@ static int ocfs2_figure_insert_type(struct inode *inode,
		 * ocfs2_figure_insert_type() and ocfs2_add_branch()
		 * may want it later.
		 */
		ret = ocfs2_read_block(inode,
				       ocfs2_et_get_last_eb_blk(et), &bh,
				       OCFS2_BH_CACHED);
		ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), &bh);
		if (ret) {
			mlog_exit(ret);
			goto out;
@@ -4762,9 +4760,8 @@ static int __ocfs2_mark_extent_written(struct inode *inode,
	if (path->p_tree_depth) {
		struct ocfs2_extent_block *eb;

		ret = ocfs2_read_block(inode,
				       ocfs2_et_get_last_eb_blk(et),
				       &last_eb_bh, OCFS2_BH_CACHED);
		ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et),
				       &last_eb_bh);
		if (ret) {
			mlog_exit(ret);
			goto out;
@@ -4921,9 +4918,8 @@ static int ocfs2_split_tree(struct inode *inode, struct ocfs2_extent_tree *et,

	depth = path->p_tree_depth;
	if (depth > 0) {
		ret = ocfs2_read_block(inode,
				       ocfs2_et_get_last_eb_blk(et),
				       &last_eb_bh, OCFS2_BH_CACHED);
		ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et),
				       &last_eb_bh);
		if (ret < 0) {
			mlog_errno(ret);
			goto out;
@@ -5590,8 +5586,7 @@ static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb,
		goto bail;
	}

	status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh,
				  OCFS2_BH_CACHED);
	status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh);
	if (status < 0) {
		iput(inode);
		mlog_errno(status);
@@ -6990,7 +6985,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,

	if (fe->id2.i_list.l_tree_depth) {
		status = ocfs2_read_block(inode, le64_to_cpu(fe->i_last_eb_blk),
					  &last_eb_bh, OCFS2_BH_CACHED);
					  &last_eb_bh);
		if (status < 0) {
			mlog_errno(status);
			goto bail;
+2 −4
Original line number Diff line number Diff line
@@ -68,8 +68,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
		goto bail;
	}

	status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno,
				  &bh, OCFS2_BH_CACHED);
	status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh);
	if (status < 0) {
		mlog_errno(status);
		goto bail;
@@ -263,8 +262,7 @@ static int ocfs2_readpage_inline(struct inode *inode, struct page *page)
	BUG_ON(!PageLocked(page));
	BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL));

	ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh,
			       OCFS2_BH_CACHED);
	ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh);
	if (ret) {
		mlog_errno(ret);
		goto out;
+3 −4
Original line number Diff line number Diff line
@@ -33,8 +33,7 @@ void ocfs2_end_buffer_io_sync(struct buffer_head *bh,

static inline int ocfs2_read_block(struct inode	       *inode,
				   u64                  off,
				   struct buffer_head **bh,
				   int                  flags);
				   struct buffer_head **bh);

int ocfs2_write_block(struct ocfs2_super          *osb,
		      struct buffer_head  *bh,
@@ -54,7 +53,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
#define OCFS2_BH_READAHEAD         8

static inline int ocfs2_read_block(struct inode *inode, u64 off,
				   struct buffer_head **bh, int flags)
				   struct buffer_head **bh)
{
	int status = 0;

@@ -64,7 +63,7 @@ static inline int ocfs2_read_block(struct inode *inode, u64 off,
		goto bail;
	}

	status = ocfs2_read_blocks(inode, off, 1, bh, flags);
	status = ocfs2_read_blocks(inode, off, 1, bh, OCFS2_BH_CACHED);

bail:
	return status;
+3 −6
Original line number Diff line number Diff line
@@ -188,8 +188,7 @@ static struct buffer_head *ocfs2_find_entry_id(const char *name,
	struct ocfs2_dinode *di;
	struct ocfs2_inline_data *data;

	ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh,
			       OCFS2_BH_CACHED);
	ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh);
	if (ret) {
		mlog_errno(ret);
		goto out;
@@ -417,8 +416,7 @@ static inline int ocfs2_delete_entry_id(handle_t *handle,
	struct ocfs2_dinode *di;
	struct ocfs2_inline_data *data;

	ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno,
			       &di_bh, OCFS2_BH_CACHED);
	ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh);
	if (ret) {
		mlog_errno(ret);
		goto out;
@@ -596,8 +594,7 @@ static int ocfs2_dir_foreach_blk_id(struct inode *inode,
	struct ocfs2_inline_data *data;
	struct ocfs2_dir_entry *de;

	ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno,
			       &di_bh, OCFS2_BH_CACHED);
	ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh);
	if (ret) {
		mlog(ML_ERROR, "Unable to read inode block for dir %llu\n",
		     (unsigned long long)OCFS2_I(inode)->ip_blkno);
+2 −6
Original line number Diff line number Diff line
@@ -2024,8 +2024,7 @@ static int ocfs2_inode_lock_update(struct inode *inode,
	} else {
		/* Boo, we have to go to disk. */
		/* read bh, cast, ocfs2_refresh_inode */
		status = ocfs2_read_block(inode, oi->ip_blkno,
					  bh, OCFS2_BH_CACHED);
		status = ocfs2_read_block(inode, oi->ip_blkno, bh);
		if (status < 0) {
			mlog_errno(status);
			goto bail_refresh;
@@ -2086,10 +2085,7 @@ static int ocfs2_assign_bh(struct inode *inode,
		return 0;
	}

	status = ocfs2_read_block(inode,
				  OCFS2_I(inode)->ip_blkno,
				  ret_bh,
				  OCFS2_BH_CACHED);
	status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, ret_bh);
	if (status < 0)
		mlog_errno(status);

Loading