diff options
author | Jiro SEKIBA <jir@unicus.jp> | 2009-07-22 12:26:34 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-09-14 05:27:14 -0400 |
commit | 79efdd94111f30c373fce05e4e5822d8ff671c2a (patch) | |
tree | 9d12c0e87146fb4fb63362f567e574d629a222a1 | |
parent | 6233caa9d5b153c2190d6c1c35c1dd1010104fc1 (diff) |
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: Jiro SEKIBA <jir@unicus.jp>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
-rw-r--r-- | fs/nilfs2/super.c | 11 | ||||
-rw-r--r-- | fs/nilfs2/the_nilfs.h | 14 |
2 files changed, 17 insertions, 8 deletions
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 9926a1d6d225..70e8613a1954 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
@@ -367,17 +367,12 @@ static void nilfs_write_super(struct super_block *sb) | |||
367 | 367 | ||
368 | down_write(&nilfs->ns_sem); | 368 | down_write(&nilfs->ns_sem); |
369 | if (!(sb->s_flags & MS_RDONLY)) { | 369 | if (!(sb->s_flags & MS_RDONLY)) { |
370 | struct nilfs_super_block **sbp = nilfs->ns_sbp; | 370 | if (!nilfs_discontinued(nilfs) && |
371 | u64 t = get_seconds(); | 371 | !nilfs_sb_need_update(nilfs)) { |
372 | int dupsb; | ||
373 | |||
374 | if (!nilfs_discontinued(nilfs) && t >= nilfs->ns_sbwtime[0] && | ||
375 | t < nilfs->ns_sbwtime[0] + NILFS_SB_FREQ) { | ||
376 | up_write(&nilfs->ns_sem); | 372 | up_write(&nilfs->ns_sem); |
377 | return; | 373 | return; |
378 | } | 374 | } |
379 | dupsb = sbp[1] && t > nilfs->ns_sbwtime[1] + NILFS_ALTSB_FREQ; | 375 | nilfs_commit_super(sbi, nilfs_altsb_need_update(nilfs)); |
380 | nilfs_commit_super(sbi, dupsb); | ||
381 | } | 376 | } |
382 | sb->s_dirt = 0; | 377 | sb->s_dirt = 0; |
383 | up_write(&nilfs->ns_sem); | 378 | up_write(&nilfs->ns_sem); |
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index fa3a1dfe4053..68e9626e3d44 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h | |||
@@ -200,6 +200,20 @@ THE_NILFS_FNS(DISCONTINUED, discontinued) | |||
200 | #define NILFS_SB_FREQ 10 | 200 | #define NILFS_SB_FREQ 10 |
201 | #define NILFS_ALTSB_FREQ 60 /* spare superblock */ | 201 | #define NILFS_ALTSB_FREQ 60 /* spare superblock */ |
202 | 202 | ||
203 | static inline int nilfs_sb_need_update(struct the_nilfs *nilfs) | ||
204 | { | ||
205 | u64 t = get_seconds(); | ||
206 | return t < nilfs->ns_sbwtime[0] || | ||
207 | t > nilfs->ns_sbwtime[0] + NILFS_SB_FREQ; | ||
208 | } | ||
209 | |||
210 | static inline int nilfs_altsb_need_update(struct the_nilfs *nilfs) | ||
211 | { | ||
212 | u64 t = get_seconds(); | ||
213 | struct nilfs_super_block **sbp = nilfs->ns_sbp; | ||
214 | return sbp[1] && t > nilfs->ns_sbwtime[1] + NILFS_ALTSB_FREQ; | ||
215 | } | ||
216 | |||
203 | void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64); | 217 | void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64); |
204 | struct the_nilfs *find_or_create_nilfs(struct block_device *); | 218 | struct the_nilfs *find_or_create_nilfs(struct block_device *); |
205 | void put_nilfs(struct the_nilfs *); | 219 | void put_nilfs(struct the_nilfs *); |