aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiro SEKIBA <jir@unicus.jp>2009-07-22 12:33:49 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-09-14 05:27:14 -0400
commit1dfa27105a6cf4171c439fd40a004a0a17838115 (patch)
tree7d348398a9e623324ca86eafd050b8c12abf3cea
parent79efdd94111f30c373fce05e4e5822d8ff671c2a (diff)
nilfs2: stop using periodic write_super callback
This removes nilfs_write_super and commit super block in nilfs internal thread, instead of periodic write_super callback. VFS layer calls ->write_super callback periodically. However, it looks like that calling back is ommited when disk I/O is busy. And when cleanerd (nilfs GC) is runnig, disk I/O tend to be busy thus nilfs superblock is not synchronized as nilfs designed. To avoid it, syncing superblock by nilfs thread instead of pdflush. Signed-off-by: Jiro SEKIBA <jir@unicus.jp> Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
-rw-r--r--fs/nilfs2/segment.c7
-rw-r--r--fs/nilfs2/super.c46
2 files changed, 7 insertions, 46 deletions
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 51ff3d0a4ee2..683df89dbae5 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -2501,7 +2501,8 @@ static int nilfs_segctor_construct(struct nilfs_sc_info *sci,
2501 if (test_bit(NILFS_SC_SUPER_ROOT, &sci->sc_flags) && 2501 if (test_bit(NILFS_SC_SUPER_ROOT, &sci->sc_flags) &&
2502 nilfs_discontinued(nilfs)) { 2502 nilfs_discontinued(nilfs)) {
2503 down_write(&nilfs->ns_sem); 2503 down_write(&nilfs->ns_sem);
2504 req->sb_err = nilfs_commit_super(sbi, 0); 2504 req->sb_err = nilfs_commit_super(sbi,
2505 nilfs_altsb_need_update(nilfs));
2505 up_write(&nilfs->ns_sem); 2506 up_write(&nilfs->ns_sem);
2506 } 2507 }
2507 } 2508 }
@@ -2689,6 +2690,7 @@ static int nilfs_segctor_thread(void *arg)
2689 } else { 2690 } else {
2690 DEFINE_WAIT(wait); 2691 DEFINE_WAIT(wait);
2691 int should_sleep = 1; 2692 int should_sleep = 1;
2693 struct the_nilfs *nilfs;
2692 2694
2693 prepare_to_wait(&sci->sc_wait_daemon, &wait, 2695 prepare_to_wait(&sci->sc_wait_daemon, &wait,
2694 TASK_INTERRUPTIBLE); 2696 TASK_INTERRUPTIBLE);
@@ -2709,6 +2711,9 @@ static int nilfs_segctor_thread(void *arg)
2709 finish_wait(&sci->sc_wait_daemon, &wait); 2711 finish_wait(&sci->sc_wait_daemon, &wait);
2710 timeout = ((sci->sc_state & NILFS_SEGCTOR_COMMIT) && 2712 timeout = ((sci->sc_state & NILFS_SEGCTOR_COMMIT) &&
2711 time_after_eq(jiffies, sci->sc_timer->expires)); 2713 time_after_eq(jiffies, sci->sc_timer->expires));
2714 nilfs = sci->sc_sbi->s_nilfs;
2715 if (sci->sc_super->s_dirt && nilfs_sb_need_update(nilfs))
2716 set_nilfs_discontinued(nilfs);
2712 } 2717 }
2713 goto loop; 2718 goto loop;
2714 2719
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 70e8613a1954..ed8ec5718ae6 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -67,7 +67,6 @@ MODULE_DESCRIPTION("A New Implementation of the Log-structured Filesystem "
67 "(NILFS)"); 67 "(NILFS)");
68MODULE_LICENSE("GPL"); 68MODULE_LICENSE("GPL");
69 69
70static void nilfs_write_super(struct super_block *sb);
71static int nilfs_remount(struct super_block *sb, int *flags, char *data); 70static int nilfs_remount(struct super_block *sb, int *flags, char *data);
72 71
73/** 72/**
@@ -335,49 +334,6 @@ static void nilfs_put_super(struct super_block *sb)
335 unlock_kernel(); 334 unlock_kernel();
336} 335}
337 336
338/**
339 * nilfs_write_super - write super block(s) of NILFS
340 * @sb: super_block
341 *
342 * nilfs_write_super() gets a fs-dependent lock, writes super block(s), and
343 * clears s_dirt. This function is called in the section protected by
344 * lock_super().
345 *
346 * The s_dirt flag is managed by each filesystem and we protect it by ns_sem
347 * of the struct the_nilfs. Lock order must be as follows:
348 *
349 * 1. lock_super()
350 * 2. down_write(&nilfs->ns_sem)
351 *
352 * Inside NILFS, locking ns_sem is enough to protect s_dirt and the buffer
353 * of the super block (nilfs->ns_sbp[]).
354 *
355 * In most cases, VFS functions call lock_super() before calling these
356 * methods. So we must be careful not to bring on deadlocks when using
357 * lock_super(); see generic_shutdown_super(), write_super(), and so on.
358 *
359 * Note that order of lock_kernel() and lock_super() depends on contexts
360 * of VFS. We should also note that lock_kernel() can be used in its
361 * protective section and only the outermost one has an effect.
362 */
363static void nilfs_write_super(struct super_block *sb)
364{
365 struct nilfs_sb_info *sbi = NILFS_SB(sb);
366 struct the_nilfs *nilfs = sbi->s_nilfs;
367
368 down_write(&nilfs->ns_sem);
369 if (!(sb->s_flags & MS_RDONLY)) {
370 if (!nilfs_discontinued(nilfs) &&
371 !nilfs_sb_need_update(nilfs)) {
372 up_write(&nilfs->ns_sem);
373 return;
374 }
375 nilfs_commit_super(sbi, nilfs_altsb_need_update(nilfs));
376 }
377 sb->s_dirt = 0;
378 up_write(&nilfs->ns_sem);
379}
380
381static int nilfs_sync_fs(struct super_block *sb, int wait) 337static int nilfs_sync_fs(struct super_block *sb, int wait)
382{ 338{
383 struct nilfs_sb_info *sbi = NILFS_SB(sb); 339 struct nilfs_sb_info *sbi = NILFS_SB(sb);
@@ -558,7 +514,7 @@ static struct super_operations nilfs_sops = {
558 /* .drop_inode = nilfs_drop_inode, */ 514 /* .drop_inode = nilfs_drop_inode, */
559 .delete_inode = nilfs_delete_inode, 515 .delete_inode = nilfs_delete_inode,
560 .put_super = nilfs_put_super, 516 .put_super = nilfs_put_super,
561 .write_super = nilfs_write_super, 517 /* .write_super = nilfs_write_super, */
562 .sync_fs = nilfs_sync_fs, 518 .sync_fs = nilfs_sync_fs,
563 /* .write_super_lockfs */ 519 /* .write_super_lockfs */
564 /* .unlockfs */ 520 /* .unlockfs */