ocfs2: improve recovery performance
PATCH v2 1/1 ocfs2: improve recovery performance
Journal replay will be run when do recovery for a dead node, to avoid the stale cache impact, all blocks of dead node's journal inode were reload from disk. This hurts the performance, check whether one block is cached before reload it can improve a lot performance. In my test env, the time doing recovery was improved from 120s to 1s.
--- fs/ocfs2/journal.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-)
fs/ocfs2/journal.c +23 -19
@@ -1159,10 +1159,8 @@ static int ocfs2_force_read_journal(struct inode *inode)int status =0 ;int i;u64 v_blkno, p_blkno, p_blocks, num_blocks; -#define CONCURRENT_JOURNAL_FILL 32ULL -struct buffer_head *bhs[CONCURRENT_JOURNAL_FILL ]; - -memset (bhs,0 ,sizeof (struct buffer_head *) *CONCURRENT_JOURNAL_FILL ); +struct buffer_head *bh =NULL ; +struct ocfs2_super *osb =OCFS2_SB (inode->i_sb); num_blocks =ocfs2_blocks_for_bytes (inode->i_sb,i_size_read (inode)); v_blkno =0 ;
@@ -1174,29 +1172,35 @@ static int ocfs2_force_read_journal(struct inode *inode) goto bail; } -if (p_blocks >CONCURRENT_JOURNAL_FILL ) - p_blocks =CONCURRENT_JOURNAL_FILL ; +for (i =0 ; i < p_blocks; i++) { + bh =__find_get_block (osb->sb->s_bdev, p_blkno, + osb->sb->s_blocksize); +/* block not cached. */ +if (!bh) { + p_blkno++; +continue ; + } -/* We are reading journal data which should not -* be put in the uptodate cache */ - status =ocfs2_read_blocks_sync (OCFS2_SB (inode->i_sb), - p_blkno, p_blocks, bhs); -if (status <0 ) { -mlog_errno (status); - goto bail; - } +brelse (bh); + bh =NULL ; +/* 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 (bhs[i]); - bhs[i] =NULL ; +brelse (bh); + bh =NULL ; + p_blkno++; } v_blkno += p_blocks; } bail: -for (i =0 ; i <CONCURRENT_JOURNAL_FILL ; i++) -brelse (bhs[i]);return status; }
Signature · 1 line
1.7.9.5
PATCH v2 1/1 ocfs2: improve recovery performance
Quoted 6 lines · On Thu, 7 Jul 2016 10:24:48 +0800 Junxiao Bi <[email protected]> wrote:
Journal replay will be run when do recovery for a dead node, to avoid the stale cache impact, all blocks of dead node's journal inode were reload from disk. This hurts the performance, check whether one block is cached before reload it can improve a lot performance. In my test env, the time doing recovery was improved from 120s to 1s.
So since v1 you did this (unchangelogged bugfix!):
fs/ocfs2/journal.c renamed from fs/ocfs2/journal.c~ocfs2-improve-recovery-performance-v2 +1 -0
@@ -1194,6 +1194,7 @@ static int ocfs2_force_read_journal(strubrelse (bh); bh =NULL ; + p_blkno++; } v_blkno += p_blocks;
I suppose this is a bit neater?
fs/ocfs2/journal.c renamed from fs/ocfs2/journal.c~ocfs2-improve-recovery-performance-v2-fix +2 -5
@@ -1172,14 +1172,12 @@ static int ocfs2_force_read_journal(stru goto bail; } -for (i =0 ; i < p_blocks; i++) { +for (i =0 ; i < p_blocks; i++, p_blkno++) { bh =__find_get_block (osb->sb->s_bdev, p_blkno, osb->sb->s_blocksize);/* block not cached. */ -if (!bh) { - p_blkno++; +if (!bh)continue ; - }brelse (bh); bh =NULL ;
@@ -1194,7 +1192,6 @@ static int ocfs2_force_read_journal(strubrelse (bh); bh =NULL ; - p_blkno++; } v_blkno += p_blocks;
_
PATCH v2 1/1 ocfs2: improve recovery performance
Quoted 23 lines · Andrew Morton
Quoted 6 lines · On Thu, 7 Jul 2016 10:24:48 +0800 Junxiao Bi <[email protected]> wrote:
Journal replay will be run when do recovery for a dead node, to avoid the stale cache impact, all blocks of dead node's journal inode were reload from disk. This hurts the performance, check whether one block is cached before reload it can improve a lot performance. In my test env, the time doing recovery was improved from 120s to 1s.
So since v1 you did this (unchangelogged bugfix!):
fs/ocfs2/journal.c renamed from fs/ocfs2/journal.c~ocfs2-improve-recovery-performance-v2 +1
-0@@ -1194,6 +1194,7 @@ static int ocfs2_force_read_journal(strubrelse (bh); bh =NULL ; + p_blkno++; } v_blkno += p_blocks;
Quoted 1 line
I suppose this is a bit neater?
Yes, looks good. Thank you.
Thanks,
Junxiao.
Quoted 30 lines
fs/ocfs2/journal.c renamed from fs/ocfs2/journal.c~ocfs2-improve-recovery-performance-v2-fix +2
-5@@ -1172,14 +1172,12 @@ static int ocfs2_force_read_journal(stru goto bail; } -for (i =0 ; i < p_blocks; i++) { +for (i =0 ; i < p_blocks; i++, p_blkno++) { bh =__find_get_block (osb->sb->s_bdev, p_blkno, osb->sb->s_blocksize);/* block not cached. */ -if (!bh) { - p_blkno++; +if (!bh)continue ; - }brelse (bh); bh =NULL ;@@ -1194,7 +1192,6 @@ static int ocfs2_force_read_journal(strubrelse (bh); bh =NULL ; - p_blkno++; } v_blkno += p_blocks;_