diff options
Diffstat (limited to 'fs/nilfs2/segment.c')
-rw-r--r-- | fs/nilfs2/segment.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 9cf71389f369..2a6b74e6699d 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
@@ -763,12 +763,12 @@ static void nilfs_dispose_list(struct nilfs_sb_info *sbi, | |||
763 | } | 763 | } |
764 | } | 764 | } |
765 | 765 | ||
766 | static int nilfs_test_metadata_dirty(struct nilfs_sb_info *sbi) | 766 | static int nilfs_test_metadata_dirty(struct the_nilfs *nilfs, |
767 | struct nilfs_root *root) | ||
767 | { | 768 | { |
768 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
769 | int ret = 0; | 769 | int ret = 0; |
770 | 770 | ||
771 | if (nilfs_mdt_fetch_dirty(sbi->s_ifile)) | 771 | if (nilfs_mdt_fetch_dirty(root->ifile)) |
772 | ret++; | 772 | ret++; |
773 | if (nilfs_mdt_fetch_dirty(nilfs->ns_cpfile)) | 773 | if (nilfs_mdt_fetch_dirty(nilfs->ns_cpfile)) |
774 | ret++; | 774 | ret++; |
@@ -793,7 +793,7 @@ static int nilfs_segctor_confirm(struct nilfs_sc_info *sci) | |||
793 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 793 | struct nilfs_sb_info *sbi = sci->sc_sbi; |
794 | int ret = 0; | 794 | int ret = 0; |
795 | 795 | ||
796 | if (nilfs_test_metadata_dirty(sbi)) | 796 | if (nilfs_test_metadata_dirty(sbi->s_nilfs, sci->sc_root)) |
797 | set_bit(NILFS_SC_DIRTY, &sci->sc_flags); | 797 | set_bit(NILFS_SC_DIRTY, &sci->sc_flags); |
798 | 798 | ||
799 | spin_lock(&sbi->s_inode_lock); | 799 | spin_lock(&sbi->s_inode_lock); |
@@ -809,7 +809,7 @@ static void nilfs_segctor_clear_metadata_dirty(struct nilfs_sc_info *sci) | |||
809 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 809 | struct nilfs_sb_info *sbi = sci->sc_sbi; |
810 | struct the_nilfs *nilfs = sbi->s_nilfs; | 810 | struct the_nilfs *nilfs = sbi->s_nilfs; |
811 | 811 | ||
812 | nilfs_mdt_clear_dirty(sbi->s_ifile); | 812 | nilfs_mdt_clear_dirty(sci->sc_root->ifile); |
813 | nilfs_mdt_clear_dirty(nilfs->ns_cpfile); | 813 | nilfs_mdt_clear_dirty(nilfs->ns_cpfile); |
814 | nilfs_mdt_clear_dirty(nilfs->ns_sufile); | 814 | nilfs_mdt_clear_dirty(nilfs->ns_sufile); |
815 | nilfs_mdt_clear_dirty(nilfs_dat_inode(nilfs)); | 815 | nilfs_mdt_clear_dirty(nilfs_dat_inode(nilfs)); |
@@ -869,7 +869,8 @@ static int nilfs_segctor_fill_in_checkpoint(struct nilfs_sc_info *sci) | |||
869 | else | 869 | else |
870 | nilfs_checkpoint_set_minor(raw_cp); | 870 | nilfs_checkpoint_set_minor(raw_cp); |
871 | 871 | ||
872 | nilfs_write_inode_common(sbi->s_ifile, &raw_cp->cp_ifile_inode, 1); | 872 | nilfs_write_inode_common(sci->sc_root->ifile, |
873 | &raw_cp->cp_ifile_inode, 1); | ||
873 | nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, nilfs->ns_cno, bh_cp); | 874 | nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, nilfs->ns_cno, bh_cp); |
874 | return 0; | 875 | return 0; |
875 | 876 | ||
@@ -894,13 +895,12 @@ static void nilfs_fill_in_file_bmap(struct inode *ifile, | |||
894 | } | 895 | } |
895 | } | 896 | } |
896 | 897 | ||
897 | static void nilfs_segctor_fill_in_file_bmap(struct nilfs_sc_info *sci, | 898 | static void nilfs_segctor_fill_in_file_bmap(struct nilfs_sc_info *sci) |
898 | struct inode *ifile) | ||
899 | { | 899 | { |
900 | struct nilfs_inode_info *ii; | 900 | struct nilfs_inode_info *ii; |
901 | 901 | ||
902 | list_for_each_entry(ii, &sci->sc_dirty_files, i_dirty) { | 902 | list_for_each_entry(ii, &sci->sc_dirty_files, i_dirty) { |
903 | nilfs_fill_in_file_bmap(ifile, ii); | 903 | nilfs_fill_in_file_bmap(sci->sc_root->ifile, ii); |
904 | set_bit(NILFS_I_COLLECTED, &ii->i_state); | 904 | set_bit(NILFS_I_COLLECTED, &ii->i_state); |
905 | } | 905 | } |
906 | } | 906 | } |
@@ -1143,7 +1143,7 @@ static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode) | |||
1143 | sci->sc_stage.flags |= NILFS_CF_IFILE_STARTED; | 1143 | sci->sc_stage.flags |= NILFS_CF_IFILE_STARTED; |
1144 | /* Fall through */ | 1144 | /* Fall through */ |
1145 | case NILFS_ST_IFILE: | 1145 | case NILFS_ST_IFILE: |
1146 | err = nilfs_segctor_scan_file(sci, sbi->s_ifile, | 1146 | err = nilfs_segctor_scan_file(sci, sci->sc_root->ifile, |
1147 | &nilfs_sc_file_ops); | 1147 | &nilfs_sc_file_ops); |
1148 | if (unlikely(err)) | 1148 | if (unlikely(err)) |
1149 | break; | 1149 | break; |
@@ -1984,6 +1984,7 @@ static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, | |||
1984 | struct nilfs_sb_info *sbi) | 1984 | struct nilfs_sb_info *sbi) |
1985 | { | 1985 | { |
1986 | struct nilfs_inode_info *ii, *n; | 1986 | struct nilfs_inode_info *ii, *n; |
1987 | struct inode *ifile = sci->sc_root->ifile; | ||
1987 | 1988 | ||
1988 | spin_lock(&sbi->s_inode_lock); | 1989 | spin_lock(&sbi->s_inode_lock); |
1989 | retry: | 1990 | retry: |
@@ -1994,14 +1995,14 @@ static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, | |||
1994 | 1995 | ||
1995 | spin_unlock(&sbi->s_inode_lock); | 1996 | spin_unlock(&sbi->s_inode_lock); |
1996 | err = nilfs_ifile_get_inode_block( | 1997 | err = nilfs_ifile_get_inode_block( |
1997 | sbi->s_ifile, ii->vfs_inode.i_ino, &ibh); | 1998 | ifile, ii->vfs_inode.i_ino, &ibh); |
1998 | if (unlikely(err)) { | 1999 | if (unlikely(err)) { |
1999 | nilfs_warning(sbi->s_super, __func__, | 2000 | nilfs_warning(sbi->s_super, __func__, |
2000 | "failed to get inode block.\n"); | 2001 | "failed to get inode block.\n"); |
2001 | return err; | 2002 | return err; |
2002 | } | 2003 | } |
2003 | nilfs_mdt_mark_buffer_dirty(ibh); | 2004 | nilfs_mdt_mark_buffer_dirty(ibh); |
2004 | nilfs_mdt_mark_dirty(sbi->s_ifile); | 2005 | nilfs_mdt_mark_dirty(ifile); |
2005 | spin_lock(&sbi->s_inode_lock); | 2006 | spin_lock(&sbi->s_inode_lock); |
2006 | if (likely(!ii->i_bh)) | 2007 | if (likely(!ii->i_bh)) |
2007 | ii->i_bh = ibh; | 2008 | ii->i_bh = ibh; |
@@ -2058,7 +2059,7 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2058 | if (unlikely(err)) | 2059 | if (unlikely(err)) |
2059 | goto out; | 2060 | goto out; |
2060 | 2061 | ||
2061 | if (nilfs_test_metadata_dirty(sbi)) | 2062 | if (nilfs_test_metadata_dirty(nilfs, sci->sc_root)) |
2062 | set_bit(NILFS_SC_DIRTY, &sci->sc_flags); | 2063 | set_bit(NILFS_SC_DIRTY, &sci->sc_flags); |
2063 | 2064 | ||
2064 | if (nilfs_segctor_clean(sci)) | 2065 | if (nilfs_segctor_clean(sci)) |
@@ -2090,7 +2091,7 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2090 | goto failed; | 2091 | goto failed; |
2091 | 2092 | ||
2092 | if (sci->sc_stage.flags & NILFS_CF_IFILE_STARTED) | 2093 | if (sci->sc_stage.flags & NILFS_CF_IFILE_STARTED) |
2093 | nilfs_segctor_fill_in_file_bmap(sci, sbi->s_ifile); | 2094 | nilfs_segctor_fill_in_file_bmap(sci); |
2094 | 2095 | ||
2095 | if (mode == SC_LSEG_SR && | 2096 | if (mode == SC_LSEG_SR && |
2096 | sci->sc_stage.scnt >= NILFS_ST_CPFILE) { | 2097 | sci->sc_stage.scnt >= NILFS_ST_CPFILE) { |
@@ -2684,7 +2685,8 @@ static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci) | |||
2684 | /* | 2685 | /* |
2685 | * Setup & clean-up functions | 2686 | * Setup & clean-up functions |
2686 | */ | 2687 | */ |
2687 | static struct nilfs_sc_info *nilfs_segctor_new(struct nilfs_sb_info *sbi) | 2688 | static struct nilfs_sc_info *nilfs_segctor_new(struct nilfs_sb_info *sbi, |
2689 | struct nilfs_root *root) | ||
2688 | { | 2690 | { |
2689 | struct nilfs_sc_info *sci; | 2691 | struct nilfs_sc_info *sci; |
2690 | 2692 | ||
@@ -2695,6 +2697,9 @@ static struct nilfs_sc_info *nilfs_segctor_new(struct nilfs_sb_info *sbi) | |||
2695 | sci->sc_sbi = sbi; | 2697 | sci->sc_sbi = sbi; |
2696 | sci->sc_super = sbi->s_super; | 2698 | sci->sc_super = sbi->s_super; |
2697 | 2699 | ||
2700 | nilfs_get_root(root); | ||
2701 | sci->sc_root = root; | ||
2702 | |||
2698 | init_waitqueue_head(&sci->sc_wait_request); | 2703 | init_waitqueue_head(&sci->sc_wait_request); |
2699 | init_waitqueue_head(&sci->sc_wait_daemon); | 2704 | init_waitqueue_head(&sci->sc_wait_daemon); |
2700 | init_waitqueue_head(&sci->sc_wait_task); | 2705 | init_waitqueue_head(&sci->sc_wait_task); |
@@ -2769,6 +2774,8 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2769 | WARN_ON(!list_empty(&sci->sc_segbufs)); | 2774 | WARN_ON(!list_empty(&sci->sc_segbufs)); |
2770 | WARN_ON(!list_empty(&sci->sc_write_logs)); | 2775 | WARN_ON(!list_empty(&sci->sc_write_logs)); |
2771 | 2776 | ||
2777 | nilfs_put_root(sci->sc_root); | ||
2778 | |||
2772 | down_write(&sbi->s_nilfs->ns_segctor_sem); | 2779 | down_write(&sbi->s_nilfs->ns_segctor_sem); |
2773 | 2780 | ||
2774 | del_timer_sync(&sci->sc_timer); | 2781 | del_timer_sync(&sci->sc_timer); |
@@ -2778,6 +2785,7 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2778 | /** | 2785 | /** |
2779 | * nilfs_attach_segment_constructor - attach a segment constructor | 2786 | * nilfs_attach_segment_constructor - attach a segment constructor |
2780 | * @sbi: nilfs_sb_info | 2787 | * @sbi: nilfs_sb_info |
2788 | * @root: root object of the current filesystem tree | ||
2781 | * | 2789 | * |
2782 | * nilfs_attach_segment_constructor() allocates a struct nilfs_sc_info, | 2790 | * nilfs_attach_segment_constructor() allocates a struct nilfs_sc_info, |
2783 | * initializes it, and starts the segment constructor. | 2791 | * initializes it, and starts the segment constructor. |
@@ -2787,7 +2795,8 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2787 | * | 2795 | * |
2788 | * %-ENOMEM - Insufficient memory available. | 2796 | * %-ENOMEM - Insufficient memory available. |
2789 | */ | 2797 | */ |
2790 | int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi) | 2798 | int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, |
2799 | struct nilfs_root *root) | ||
2791 | { | 2800 | { |
2792 | struct the_nilfs *nilfs = sbi->s_nilfs; | 2801 | struct the_nilfs *nilfs = sbi->s_nilfs; |
2793 | int err; | 2802 | int err; |
@@ -2801,7 +2810,7 @@ int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi) | |||
2801 | nilfs_detach_segment_constructor(sbi); | 2810 | nilfs_detach_segment_constructor(sbi); |
2802 | } | 2811 | } |
2803 | 2812 | ||
2804 | sbi->s_sc_info = nilfs_segctor_new(sbi); | 2813 | sbi->s_sc_info = nilfs_segctor_new(sbi, root); |
2805 | if (!sbi->s_sc_info) | 2814 | if (!sbi->s_sc_info) |
2806 | return -ENOMEM; | 2815 | return -ENOMEM; |
2807 | 2816 | ||