diff options
author | Jiro SEKIBA <jir@unicus.jp> | 2010-06-28 04:49:33 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-07-22 21:02:11 -0400 |
commit | b2ac86e1a8e3a3b0ab4449d062c582f07a078e7b (patch) | |
tree | b681ea820685a278e06995ff23b58f7a85904b70 /fs/nilfs2/segment.c | |
parent | d26493b6f017c0b0063a15bf893411ddae85eee4 (diff) |
nilfs2: sync super blocks in turns
This will sync super blocks in turns instead of syncing duplicate
super blocks at the time. This will help searching valid super root
when super block is written into disk before log is written, which is
happen when barrier-less block devices are unmounted uncleanly. In
the situation, old super block likely points to valid log.
This patch introduces ns_sbwcount member to the nilfs object and adds
nilfs_sb_will_flip() function; ns_sbwcount counts how many times super
blocks write back to the disk. And, nilfs_sb_will_flip() decides
whether flipping required or not based on the count of ns_sbwcount to
sync super blocks asymmetrically.
The following functions are also changed:
- nilfs_prepare_super(): flips super blocks according to the
argument. The argument is calculated by nilfs_sb_will_flip()
function.
- nilfs_cleanup_super(): sets "clean" flag to both super blocks if
they point to the same checkpoint.
To update both of super block information, caller of
nilfs_commit_super must set the information on both super blocks.
Signed-off-by: Jiro SEKIBA <jir@unicus.jp>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/segment.c')
-rw-r--r-- | fs/nilfs2/segment.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 9e680a93b13a..04e04854a311 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
@@ -2425,10 +2425,12 @@ static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode) | |||
2425 | nilfs_discontinued(nilfs)) { | 2425 | nilfs_discontinued(nilfs)) { |
2426 | down_write(&nilfs->ns_sem); | 2426 | down_write(&nilfs->ns_sem); |
2427 | err = -EIO; | 2427 | err = -EIO; |
2428 | sbp = nilfs_prepare_super(sbi); | 2428 | sbp = nilfs_prepare_super(sbi, |
2429 | if (likely(sbp)) | 2429 | nilfs_sb_will_flip(nilfs)); |
2430 | err = nilfs_commit_super( | 2430 | if (likely(sbp)) { |
2431 | sbi, nilfs_altsb_need_update(nilfs)); | 2431 | nilfs_set_log_cursor(sbp[0], nilfs); |
2432 | err = nilfs_commit_super(sbi, NILFS_SB_COMMIT); | ||
2433 | } | ||
2432 | up_write(&nilfs->ns_sem); | 2434 | up_write(&nilfs->ns_sem); |
2433 | } | 2435 | } |
2434 | } | 2436 | } |