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

Commit 31d33073 authored by Joel Becker's avatar Joel Becker Committed by Mark Fasheh
Browse files

ocfs2: Require an inode for ocfs2_read_block(s)().



Now that synchronous readers are using ocfs2_read_blocks_sync(), all
callers of ocfs2_read_blocks() are passing an inode.  Use it
unconditionally.  Since it's there, we don't need to pass the
ocfs2_super either.

Signed-off-by: default avatarJoel Becker <joel.becker@oracle.com>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent da1e9098
Loading
Loading
Loading
Loading
+14 −16
Original line number Diff line number Diff line
@@ -705,8 +705,8 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb,
	last_eb_blk = ocfs2_et_get_last_eb_blk(et);

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

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

		brelse(bh);
		bh = NULL;
		ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), blkno,
				       &bh, OCFS2_BH_CACHED, inode);
		ret = ocfs2_read_block(inode, blkno, &bh, OCFS2_BH_CACHED);
		if (ret) {
			mlog_errno(ret);
			goto out;
@@ -4296,9 +4294,9 @@ 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(OCFS2_SB(inode->i_sb),
		ret = ocfs2_read_block(inode,
				       ocfs2_et_get_last_eb_blk(et), &bh,
				       OCFS2_BH_CACHED, inode);
				       OCFS2_BH_CACHED);
		if (ret) {
			mlog_exit(ret);
			goto out;
@@ -4764,9 +4762,9 @@ static int __ocfs2_mark_extent_written(struct inode *inode,
	if (path->p_tree_depth) {
		struct ocfs2_extent_block *eb;

		ret = ocfs2_read_block(OCFS2_SB(inode->i_sb),
		ret = ocfs2_read_block(inode,
				       ocfs2_et_get_last_eb_blk(et),
				       &last_eb_bh, OCFS2_BH_CACHED, inode);
				       &last_eb_bh, OCFS2_BH_CACHED);
		if (ret) {
			mlog_exit(ret);
			goto out;
@@ -4923,9 +4921,9 @@ 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(OCFS2_SB(inode->i_sb),
		ret = ocfs2_read_block(inode,
				       ocfs2_et_get_last_eb_blk(et),
				       &last_eb_bh, OCFS2_BH_CACHED, inode);
				       &last_eb_bh, OCFS2_BH_CACHED);
		if (ret < 0) {
			mlog_errno(ret);
			goto out;
@@ -5592,8 +5590,8 @@ static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb,
		goto bail;
	}

	status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, &bh,
				  OCFS2_BH_CACHED, inode);
	status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh,
				  OCFS2_BH_CACHED);
	if (status < 0) {
		iput(inode);
		mlog_errno(status);
@@ -6991,8 +6989,8 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
	ocfs2_init_dealloc_ctxt(&(*tc)->tc_dealloc);

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

	status = ocfs2_read_block(OCFS2_SB(inode->i_sb),
				  OCFS2_I(inode)->ip_blkno,
				  &bh, OCFS2_BH_CACHED, inode);
	status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno,
				  &bh, OCFS2_BH_CACHED);
	if (status < 0) {
		mlog_errno(status);
		goto bail;
@@ -260,13 +259,12 @@ static int ocfs2_readpage_inline(struct inode *inode, struct page *page)
{
	int ret;
	struct buffer_head *di_bh = NULL;
	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);

	BUG_ON(!PageLocked(page));
	BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL));

	ret = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, &di_bh,
			       OCFS2_BH_CACHED, inode);
	ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh,
			       OCFS2_BH_CACHED);
	if (ret) {
		mlog_errno(ret);
		goto out;
+12 −23
Original line number Diff line number Diff line
@@ -170,22 +170,20 @@ bail:
	return status;
}

int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr,
		      struct buffer_head *bhs[], int flags,
		      struct inode *inode)
int ocfs2_read_blocks(struct inode *inode, u64 block, int nr,
		      struct buffer_head *bhs[], int flags)
{
	int status = 0;
	struct super_block *sb;
	int i, ignore_cache = 0;
	struct buffer_head *bh;

	mlog_entry("(block=(%llu), nr=(%d), flags=%d, inode=%p)\n",
		   (unsigned long long)block, nr, flags, inode);
	mlog_entry("(inode=%p, block=(%llu), nr=(%d), flags=%d)\n",
		   inode, (unsigned long long)block, nr, flags);

	BUG_ON((flags & OCFS2_BH_READAHEAD) &&
	       (!inode || !(flags & OCFS2_BH_CACHED)));
	BUG_ON(!inode);
	BUG_ON((flags & OCFS2_BH_READAHEAD) && !(flags & OCFS2_BH_CACHED));

	if (osb == NULL || osb->sb == NULL || bhs == NULL) {
	if (bhs == NULL) {
		status = -EINVAL;
		mlog_errno(status);
		goto bail;
@@ -204,18 +202,11 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr,
		goto bail;
	}

	sb = osb->sb;

	if (flags & OCFS2_BH_CACHED && !inode)
		flags &= ~OCFS2_BH_CACHED;

	if (inode)
	mutex_lock(&OCFS2_I(inode)->ip_io_mutex);
	for (i = 0 ; i < nr ; i++) {
		if (bhs[i] == NULL) {
			bhs[i] = sb_getblk(sb, block++);
			bhs[i] = sb_getblk(inode->i_sb, block++);
			if (bhs[i] == NULL) {
				if (inode)
				mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);
				status = -EIO;
				mlog_errno(status);
@@ -347,10 +338,8 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr,
		/* Always set the buffer in the cache, even if it was
		 * a forced read, or read-ahead which hasn't yet
		 * completed. */
		if (inode)
		ocfs2_set_buffer_uptodate(inode, bh);
	}
	if (inode)
	mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);

	mlog(ML_BH_IO, "block=(%llu), nr=(%d), cached=%s, flags=0x%x\n", 
+7 −11
Original line number Diff line number Diff line
@@ -31,21 +31,19 @@
void ocfs2_end_buffer_io_sync(struct buffer_head *bh,
			     int uptodate);

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

int ocfs2_write_block(struct ocfs2_super          *osb,
		      struct buffer_head  *bh,
		      struct inode        *inode);
int ocfs2_read_blocks(struct ocfs2_super          *osb,
int ocfs2_read_blocks(struct inode	  *inode,
		      u64                  block,
		      int                  nr,
		      struct buffer_head  *bhs[],
		      int                  flags,
		      struct inode        *inode);
		      int                  flags);
int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
			   unsigned int nr, struct buffer_head *bhs[]);

@@ -55,9 +53,8 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
#define OCFS2_BH_CACHED            1
#define OCFS2_BH_READAHEAD         8

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

@@ -67,8 +64,7 @@ static inline int ocfs2_read_block(struct ocfs2_super * osb, u64 off,
		goto bail;
	}

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

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

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

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

	ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), OCFS2_I(inode)->ip_blkno,
			       &di_bh, OCFS2_BH_CACHED, inode);
	ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno,
			       &di_bh, OCFS2_BH_CACHED);
	if (ret) {
		mlog(ML_ERROR, "Unable to read inode block for dir %llu\n",
		     (unsigned long long)OCFS2_I(inode)->ip_blkno);
Loading