Commit 0b492f68 authored by Junxiao Bi's avatar Junxiao Bi Committed by Linus Torvalds

ocfs2: improve recovery performance

Journal replay will be run when performing recovery for a dead node.  To
avoid the stale cache impact, all blocks of dead node's journal inode
were reloaded from disk.  This hurts the performance.  Check whether one
block is cached before reloading it can improve performance a lot.  In
my test env, the time doing recovery was improved from 120s to 1s.

[akpm@linux-foundation.org: clean up the for loop p_blkno handling]
Link: http://lkml.kernel.org/r/1466155682-24656-1-git-send-email-junxiao.bi@oracle.comSigned-off-by: default avatarJunxiao Bi <junxiao.bi@oracle.com>
Reviewed-by: default avatarJoseph Qi <joseph.qi@huawei.com>
Cc: "Gang He" <ghe@suse.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 191df2b5
...@@ -1159,10 +1159,8 @@ static int ocfs2_force_read_journal(struct inode *inode) ...@@ -1159,10 +1159,8 @@ static int ocfs2_force_read_journal(struct inode *inode)
int status = 0; int status = 0;
int i; int i;
u64 v_blkno, p_blkno, p_blocks, num_blocks; u64 v_blkno, p_blkno, p_blocks, num_blocks;
#define CONCURRENT_JOURNAL_FILL 32ULL struct buffer_head *bh = NULL;
struct buffer_head *bhs[CONCURRENT_JOURNAL_FILL]; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
memset(bhs, 0, sizeof(struct buffer_head *) * CONCURRENT_JOURNAL_FILL);
num_blocks = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); num_blocks = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode));
v_blkno = 0; v_blkno = 0;
...@@ -1174,29 +1172,32 @@ static int ocfs2_force_read_journal(struct inode *inode) ...@@ -1174,29 +1172,32 @@ static int ocfs2_force_read_journal(struct inode *inode)
goto bail; goto bail;
} }
if (p_blocks > CONCURRENT_JOURNAL_FILL) for (i = 0; i < p_blocks; i++, p_blkno++) {
p_blocks = CONCURRENT_JOURNAL_FILL; bh = __find_get_block(osb->sb->s_bdev, p_blkno,
osb->sb->s_blocksize);
/* We are reading journal data which should not /* block not cached. */
* be put in the uptodate cache */ if (!bh)
status = ocfs2_read_blocks_sync(OCFS2_SB(inode->i_sb), continue;
p_blkno, p_blocks, bhs);
if (status < 0) { brelse(bh);
mlog_errno(status); bh = NULL;
goto bail; /* We are reading journal data which should not
} * be put in the uptodate cache.
*/
status = ocfs2_read_blocks_sync(osb, p_blkno, 1, &bh);
if (status < 0) {
mlog_errno(status);
goto bail;
}
for(i = 0; i < p_blocks; i++) { brelse(bh);
brelse(bhs[i]); bh = NULL;
bhs[i] = NULL;
} }
v_blkno += p_blocks; v_blkno += p_blocks;
} }
bail: bail:
for(i = 0; i < CONCURRENT_JOURNAL_FILL; i++)
brelse(bhs[i]);
return status; return status;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment