Skip to content

Commit

Permalink
ocfs2: Require an inode for ocfs2_read_block(s)().
Browse files Browse the repository at this point in the history
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: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
  • Loading branch information
Joel Becker authored and Mark Fasheh committed Oct 14, 2008
1 parent da1e909 commit 31d3307
Showing 17 changed files with 116 additions and 148 deletions.
30 changes: 14 additions & 16 deletions fs/ocfs2/alloc.c
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 4 additions & 6 deletions fs/ocfs2/aops.c
Original file line number Diff line number Diff line change
@@ -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;
35 changes: 12 additions & 23 deletions fs/ocfs2/buffer_head_io.c
Original file line number Diff line number Diff line change
@@ -170,22 +170,20 @@ int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
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,19 +202,12 @@ 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);
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);
mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);
status = -EIO;
mlog_errno(status);
goto bail;
@@ -347,11 +338,9 @@ 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);
ocfs2_set_buffer_uptodate(inode, bh);
}
if (inode)
mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);
mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);

mlog(ML_BH_IO, "block=(%llu), nr=(%d), cached=%s, flags=0x%x\n",
(unsigned long long)block, nr,
18 changes: 7 additions & 11 deletions fs/ocfs2/buffer_head_io.h
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 6 additions & 6 deletions fs/ocfs2/dir.c
Original file line number Diff line number Diff line change
@@ -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);
9 changes: 4 additions & 5 deletions fs/ocfs2/dlmglue.c
Original file line number Diff line number Diff line change
@@ -2024,8 +2024,8 @@ 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(OCFS2_SB(inode->i_sb), oi->ip_blkno,
bh, OCFS2_BH_CACHED, inode);
status = ocfs2_read_block(inode, oi->ip_blkno,
bh, OCFS2_BH_CACHED);
if (status < 0) {
mlog_errno(status);
goto bail_refresh;
@@ -2086,11 +2086,10 @@ static int ocfs2_assign_bh(struct inode *inode,
return 0;
}

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

12 changes: 6 additions & 6 deletions fs/ocfs2/extent_map.c
Original file line number Diff line number Diff line change
@@ -293,8 +293,8 @@ static int ocfs2_last_eb_is_empty(struct inode *inode,
struct ocfs2_extent_block *eb;
struct ocfs2_extent_list *el;

ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), last_eb_blk,
&eb_bh, OCFS2_BH_CACHED, inode);
ret = ocfs2_read_block(inode, last_eb_blk,
&eb_bh, OCFS2_BH_CACHED);
if (ret) {
mlog_errno(ret);
goto out;
@@ -382,9 +382,9 @@ static int ocfs2_figure_hole_clusters(struct inode *inode,
if (le64_to_cpu(eb->h_next_leaf_blk) == 0ULL)
goto no_more_extents;

ret = ocfs2_read_block(OCFS2_SB(inode->i_sb),
ret = ocfs2_read_block(inode,
le64_to_cpu(eb->h_next_leaf_blk),
&next_eb_bh, OCFS2_BH_CACHED, inode);
&next_eb_bh, OCFS2_BH_CACHED);
if (ret) {
mlog_errno(ret);
goto out;
@@ -631,8 +631,8 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster,
if (ret == 0)
goto out;

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_errno(ret);
goto out;
12 changes: 5 additions & 7 deletions fs/ocfs2/file.c
Original file line number Diff line number Diff line change
@@ -545,8 +545,8 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
*/
BUG_ON(mark_unwritten && !ocfs2_sparse_alloc(osb));

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) {
mlog_errno(status);
goto leave;
@@ -1132,8 +1132,7 @@ static int ocfs2_write_remove_suid(struct inode *inode)
struct buffer_head *bh = NULL;
struct ocfs2_inode_info *oi = OCFS2_I(inode);

ret = ocfs2_read_block(OCFS2_SB(inode->i_sb),
oi->ip_blkno, &bh, OCFS2_BH_CACHED, inode);
ret = ocfs2_read_block(inode, oi->ip_blkno, &bh, OCFS2_BH_CACHED);
if (ret < 0) {
mlog_errno(ret);
goto out;
@@ -1159,9 +1158,8 @@ static int ocfs2_allocate_unwritten_extents(struct inode *inode,
struct buffer_head *di_bh = NULL;

if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
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_errno(ret);
goto out;
6 changes: 2 additions & 4 deletions fs/ocfs2/inode.c
Original file line number Diff line number Diff line change
@@ -461,8 +461,7 @@ static int ocfs2_read_locked_inode(struct inode *inode,
}

if (can_lock)
status = ocfs2_read_block(osb, args->fi_blkno, &bh, 0,
inode);
status = ocfs2_read_block(inode, args->fi_blkno, &bh, 0);
else
status = ocfs2_read_blocks_sync(osb, args->fi_blkno, 1, &bh);
if (status < 0) {
@@ -1166,8 +1165,7 @@ struct buffer_head *ocfs2_bread(struct inode *inode,
goto fail;
}

tmperr = ocfs2_read_block(OCFS2_SB(inode->i_sb), p_blkno, &bh,
readflags, inode);
tmperr = ocfs2_read_block(inode, p_blkno, &bh, readflags);
if (tmperr < 0)
goto fail;

2 changes: 1 addition & 1 deletion fs/ocfs2/journal.c
Original file line number Diff line number Diff line change
@@ -1134,7 +1134,7 @@ static int ocfs2_read_journal_inode(struct ocfs2_super *osb,
}
SET_INODE_JOURNAL(inode);

status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, bh, 0, inode);
status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, bh, 0);
if (status < 0) {
mlog_errno(status);
goto bail;
Loading

0 comments on commit 31d3307

Please sign in to comment.