Commit 79efdd94 authored by Jiro SEKIBA's avatar Jiro SEKIBA Committed by Ryusuke Konishi

nilfs2: clean up nilfs_write_super

Separate conditions that check if syncing super block and alternative
super block are required as inline functions to reuse the conditions.
Signed-off-by: default avatarJiro SEKIBA <jir@unicus.jp>
Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
parent 6233caa9
...@@ -367,17 +367,12 @@ static void nilfs_write_super(struct super_block *sb) ...@@ -367,17 +367,12 @@ static void nilfs_write_super(struct super_block *sb)
down_write(&nilfs->ns_sem); down_write(&nilfs->ns_sem);
if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->s_flags & MS_RDONLY)) {
struct nilfs_super_block **sbp = nilfs->ns_sbp; if (!nilfs_discontinued(nilfs) &&
u64 t = get_seconds(); !nilfs_sb_need_update(nilfs)) {
int dupsb;
if (!nilfs_discontinued(nilfs) && t >= nilfs->ns_sbwtime[0] &&
t < nilfs->ns_sbwtime[0] + NILFS_SB_FREQ) {
up_write(&nilfs->ns_sem); up_write(&nilfs->ns_sem);
return; return;
} }
dupsb = sbp[1] && t > nilfs->ns_sbwtime[1] + NILFS_ALTSB_FREQ; nilfs_commit_super(sbi, nilfs_altsb_need_update(nilfs));
nilfs_commit_super(sbi, dupsb);
} }
sb->s_dirt = 0; sb->s_dirt = 0;
up_write(&nilfs->ns_sem); up_write(&nilfs->ns_sem);
......
...@@ -200,6 +200,20 @@ THE_NILFS_FNS(DISCONTINUED, discontinued) ...@@ -200,6 +200,20 @@ THE_NILFS_FNS(DISCONTINUED, discontinued)
#define NILFS_SB_FREQ 10 #define NILFS_SB_FREQ 10
#define NILFS_ALTSB_FREQ 60 /* spare superblock */ #define NILFS_ALTSB_FREQ 60 /* spare superblock */
static inline int nilfs_sb_need_update(struct the_nilfs *nilfs)
{
u64 t = get_seconds();
return t < nilfs->ns_sbwtime[0] ||
t > nilfs->ns_sbwtime[0] + NILFS_SB_FREQ;
}
static inline int nilfs_altsb_need_update(struct the_nilfs *nilfs)
{
u64 t = get_seconds();
struct nilfs_super_block **sbp = nilfs->ns_sbp;
return sbp[1] && t > nilfs->ns_sbwtime[1] + NILFS_ALTSB_FREQ;
}
void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64); void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64);
struct the_nilfs *find_or_create_nilfs(struct block_device *); struct the_nilfs *find_or_create_nilfs(struct block_device *);
void put_nilfs(struct the_nilfs *); void put_nilfs(struct the_nilfs *);
......
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