diff options
-rw-r--r-- | fs/nilfs2/inode.c | 30 | ||||
-rw-r--r-- | fs/nilfs2/sb.h | 3 | ||||
-rw-r--r-- | fs/nilfs2/segment.c | 80 | ||||
-rw-r--r-- | fs/nilfs2/super.c | 3 | ||||
-rw-r--r-- | fs/nilfs2/the_nilfs.c | 2 | ||||
-rw-r--r-- | fs/nilfs2/the_nilfs.h | 6 |
6 files changed, 63 insertions, 61 deletions
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index 22a816ba3621..dd5d6d633ea1 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c | |||
@@ -807,18 +807,18 @@ int nilfs_permission(struct inode *inode, int mask, unsigned int flags) | |||
807 | 807 | ||
808 | int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh) | 808 | int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh) |
809 | { | 809 | { |
810 | struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb); | 810 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; |
811 | struct nilfs_inode_info *ii = NILFS_I(inode); | 811 | struct nilfs_inode_info *ii = NILFS_I(inode); |
812 | int err; | 812 | int err; |
813 | 813 | ||
814 | spin_lock(&sbi->s_inode_lock); | 814 | spin_lock(&nilfs->ns_inode_lock); |
815 | if (ii->i_bh == NULL) { | 815 | if (ii->i_bh == NULL) { |
816 | spin_unlock(&sbi->s_inode_lock); | 816 | spin_unlock(&nilfs->ns_inode_lock); |
817 | err = nilfs_ifile_get_inode_block(ii->i_root->ifile, | 817 | err = nilfs_ifile_get_inode_block(ii->i_root->ifile, |
818 | inode->i_ino, pbh); | 818 | inode->i_ino, pbh); |
819 | if (unlikely(err)) | 819 | if (unlikely(err)) |
820 | return err; | 820 | return err; |
821 | spin_lock(&sbi->s_inode_lock); | 821 | spin_lock(&nilfs->ns_inode_lock); |
822 | if (ii->i_bh == NULL) | 822 | if (ii->i_bh == NULL) |
823 | ii->i_bh = *pbh; | 823 | ii->i_bh = *pbh; |
824 | else { | 824 | else { |
@@ -829,36 +829,36 @@ int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh) | |||
829 | *pbh = ii->i_bh; | 829 | *pbh = ii->i_bh; |
830 | 830 | ||
831 | get_bh(*pbh); | 831 | get_bh(*pbh); |
832 | spin_unlock(&sbi->s_inode_lock); | 832 | spin_unlock(&nilfs->ns_inode_lock); |
833 | return 0; | 833 | return 0; |
834 | } | 834 | } |
835 | 835 | ||
836 | int nilfs_inode_dirty(struct inode *inode) | 836 | int nilfs_inode_dirty(struct inode *inode) |
837 | { | 837 | { |
838 | struct nilfs_inode_info *ii = NILFS_I(inode); | 838 | struct nilfs_inode_info *ii = NILFS_I(inode); |
839 | struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb); | 839 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; |
840 | int ret = 0; | 840 | int ret = 0; |
841 | 841 | ||
842 | if (!list_empty(&ii->i_dirty)) { | 842 | if (!list_empty(&ii->i_dirty)) { |
843 | spin_lock(&sbi->s_inode_lock); | 843 | spin_lock(&nilfs->ns_inode_lock); |
844 | ret = test_bit(NILFS_I_DIRTY, &ii->i_state) || | 844 | ret = test_bit(NILFS_I_DIRTY, &ii->i_state) || |
845 | test_bit(NILFS_I_BUSY, &ii->i_state); | 845 | test_bit(NILFS_I_BUSY, &ii->i_state); |
846 | spin_unlock(&sbi->s_inode_lock); | 846 | spin_unlock(&nilfs->ns_inode_lock); |
847 | } | 847 | } |
848 | return ret; | 848 | return ret; |
849 | } | 849 | } |
850 | 850 | ||
851 | int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty) | 851 | int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty) |
852 | { | 852 | { |
853 | struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb); | ||
854 | struct nilfs_inode_info *ii = NILFS_I(inode); | 853 | struct nilfs_inode_info *ii = NILFS_I(inode); |
854 | struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs; | ||
855 | 855 | ||
856 | atomic_add(nr_dirty, &sbi->s_nilfs->ns_ndirtyblks); | 856 | atomic_add(nr_dirty, &nilfs->ns_ndirtyblks); |
857 | 857 | ||
858 | if (test_and_set_bit(NILFS_I_DIRTY, &ii->i_state)) | 858 | if (test_and_set_bit(NILFS_I_DIRTY, &ii->i_state)) |
859 | return 0; | 859 | return 0; |
860 | 860 | ||
861 | spin_lock(&sbi->s_inode_lock); | 861 | spin_lock(&nilfs->ns_inode_lock); |
862 | if (!test_bit(NILFS_I_QUEUED, &ii->i_state) && | 862 | if (!test_bit(NILFS_I_QUEUED, &ii->i_state) && |
863 | !test_bit(NILFS_I_BUSY, &ii->i_state)) { | 863 | !test_bit(NILFS_I_BUSY, &ii->i_state)) { |
864 | /* Because this routine may race with nilfs_dispose_list(), | 864 | /* Because this routine may race with nilfs_dispose_list(), |
@@ -866,18 +866,18 @@ int nilfs_set_file_dirty(struct inode *inode, unsigned nr_dirty) | |||
866 | if (list_empty(&ii->i_dirty) && igrab(inode) == NULL) { | 866 | if (list_empty(&ii->i_dirty) && igrab(inode) == NULL) { |
867 | /* This will happen when somebody is freeing | 867 | /* This will happen when somebody is freeing |
868 | this inode. */ | 868 | this inode. */ |
869 | nilfs_warning(sbi->s_super, __func__, | 869 | nilfs_warning(inode->i_sb, __func__, |
870 | "cannot get inode (ino=%lu)\n", | 870 | "cannot get inode (ino=%lu)\n", |
871 | inode->i_ino); | 871 | inode->i_ino); |
872 | spin_unlock(&sbi->s_inode_lock); | 872 | spin_unlock(&nilfs->ns_inode_lock); |
873 | return -EINVAL; /* NILFS_I_DIRTY may remain for | 873 | return -EINVAL; /* NILFS_I_DIRTY may remain for |
874 | freeing inode */ | 874 | freeing inode */ |
875 | } | 875 | } |
876 | list_del(&ii->i_dirty); | 876 | list_del(&ii->i_dirty); |
877 | list_add_tail(&ii->i_dirty, &sbi->s_dirty_files); | 877 | list_add_tail(&ii->i_dirty, &nilfs->ns_dirty_files); |
878 | set_bit(NILFS_I_QUEUED, &ii->i_state); | 878 | set_bit(NILFS_I_QUEUED, &ii->i_state); |
879 | } | 879 | } |
880 | spin_unlock(&sbi->s_inode_lock); | 880 | spin_unlock(&nilfs->ns_inode_lock); |
881 | return 0; | 881 | return 0; |
882 | } | 882 | } |
883 | 883 | ||
diff --git a/fs/nilfs2/sb.h b/fs/nilfs2/sb.h index 0512521ba8a4..3232e75fab75 100644 --- a/fs/nilfs2/sb.h +++ b/fs/nilfs2/sb.h | |||
@@ -39,10 +39,7 @@ struct nilfs_sb_info { | |||
39 | struct the_nilfs *s_nilfs; | 39 | struct the_nilfs *s_nilfs; |
40 | 40 | ||
41 | /* Segment constructor */ | 41 | /* Segment constructor */ |
42 | struct list_head s_dirty_files; /* dirty files list */ | ||
43 | struct nilfs_sc_info *s_sc_info; /* segment constructor info */ | 42 | struct nilfs_sc_info *s_sc_info; /* segment constructor info */ |
44 | spinlock_t s_inode_lock; /* Lock for the nilfs inode. | ||
45 | It covers s_dirty_files list */ | ||
46 | 43 | ||
47 | /* Inode allocator */ | 44 | /* Inode allocator */ |
48 | spinlock_t s_next_gen_lock; | 45 | spinlock_t s_next_gen_lock; |
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index a32d9cb2842a..6ac50d811841 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
@@ -104,8 +104,7 @@ struct nilfs_sc_operations { | |||
104 | static void nilfs_segctor_start_timer(struct nilfs_sc_info *); | 104 | static void nilfs_segctor_start_timer(struct nilfs_sc_info *); |
105 | static void nilfs_segctor_do_flush(struct nilfs_sc_info *, int); | 105 | static void nilfs_segctor_do_flush(struct nilfs_sc_info *, int); |
106 | static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *); | 106 | static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *); |
107 | static void nilfs_dispose_list(struct nilfs_sb_info *, struct list_head *, | 107 | static void nilfs_dispose_list(struct the_nilfs *, struct list_head *, int); |
108 | int); | ||
109 | 108 | ||
110 | #define nilfs_cnt32_gt(a, b) \ | 109 | #define nilfs_cnt32_gt(a, b) \ |
111 | (typecheck(__u32, a) && typecheck(__u32, b) && \ | 110 | (typecheck(__u32, a) && typecheck(__u32, b) && \ |
@@ -325,14 +324,15 @@ static void nilfs_transaction_lock(struct nilfs_sb_info *sbi, | |||
325 | static void nilfs_transaction_unlock(struct nilfs_sb_info *sbi) | 324 | static void nilfs_transaction_unlock(struct nilfs_sb_info *sbi) |
326 | { | 325 | { |
327 | struct nilfs_transaction_info *ti = current->journal_info; | 326 | struct nilfs_transaction_info *ti = current->journal_info; |
327 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
328 | 328 | ||
329 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); | 329 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); |
330 | BUG_ON(ti->ti_count > 0); | 330 | BUG_ON(ti->ti_count > 0); |
331 | 331 | ||
332 | up_write(&sbi->s_nilfs->ns_segctor_sem); | 332 | up_write(&nilfs->ns_segctor_sem); |
333 | current->journal_info = ti->ti_save; | 333 | current->journal_info = ti->ti_save; |
334 | if (!list_empty(&ti->ti_garbage)) | 334 | if (!list_empty(&ti->ti_garbage)) |
335 | nilfs_dispose_list(sbi, &ti->ti_garbage, 0); | 335 | nilfs_dispose_list(nilfs, &ti->ti_garbage, 0); |
336 | } | 336 | } |
337 | 337 | ||
338 | static void *nilfs_segctor_map_segsum_entry(struct nilfs_sc_info *sci, | 338 | static void *nilfs_segctor_map_segsum_entry(struct nilfs_sc_info *sci, |
@@ -714,7 +714,7 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode, | |||
714 | } | 714 | } |
715 | } | 715 | } |
716 | 716 | ||
717 | static void nilfs_dispose_list(struct nilfs_sb_info *sbi, | 717 | static void nilfs_dispose_list(struct the_nilfs *nilfs, |
718 | struct list_head *head, int force) | 718 | struct list_head *head, int force) |
719 | { | 719 | { |
720 | struct nilfs_inode_info *ii, *n; | 720 | struct nilfs_inode_info *ii, *n; |
@@ -722,7 +722,7 @@ static void nilfs_dispose_list(struct nilfs_sb_info *sbi, | |||
722 | unsigned nv = 0; | 722 | unsigned nv = 0; |
723 | 723 | ||
724 | while (!list_empty(head)) { | 724 | while (!list_empty(head)) { |
725 | spin_lock(&sbi->s_inode_lock); | 725 | spin_lock(&nilfs->ns_inode_lock); |
726 | list_for_each_entry_safe(ii, n, head, i_dirty) { | 726 | list_for_each_entry_safe(ii, n, head, i_dirty) { |
727 | list_del_init(&ii->i_dirty); | 727 | list_del_init(&ii->i_dirty); |
728 | if (force) { | 728 | if (force) { |
@@ -733,14 +733,14 @@ static void nilfs_dispose_list(struct nilfs_sb_info *sbi, | |||
733 | } else if (test_bit(NILFS_I_DIRTY, &ii->i_state)) { | 733 | } else if (test_bit(NILFS_I_DIRTY, &ii->i_state)) { |
734 | set_bit(NILFS_I_QUEUED, &ii->i_state); | 734 | set_bit(NILFS_I_QUEUED, &ii->i_state); |
735 | list_add_tail(&ii->i_dirty, | 735 | list_add_tail(&ii->i_dirty, |
736 | &sbi->s_dirty_files); | 736 | &nilfs->ns_dirty_files); |
737 | continue; | 737 | continue; |
738 | } | 738 | } |
739 | ivec[nv++] = ii; | 739 | ivec[nv++] = ii; |
740 | if (nv == SC_N_INODEVEC) | 740 | if (nv == SC_N_INODEVEC) |
741 | break; | 741 | break; |
742 | } | 742 | } |
743 | spin_unlock(&sbi->s_inode_lock); | 743 | spin_unlock(&nilfs->ns_inode_lock); |
744 | 744 | ||
745 | for (pii = ivec; nv > 0; pii++, nv--) | 745 | for (pii = ivec; nv > 0; pii++, nv--) |
746 | iput(&(*pii)->vfs_inode); | 746 | iput(&(*pii)->vfs_inode); |
@@ -773,17 +773,17 @@ static int nilfs_segctor_clean(struct nilfs_sc_info *sci) | |||
773 | 773 | ||
774 | static int nilfs_segctor_confirm(struct nilfs_sc_info *sci) | 774 | static int nilfs_segctor_confirm(struct nilfs_sc_info *sci) |
775 | { | 775 | { |
776 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 776 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; |
777 | int ret = 0; | 777 | int ret = 0; |
778 | 778 | ||
779 | if (nilfs_test_metadata_dirty(sbi->s_nilfs, sci->sc_root)) | 779 | if (nilfs_test_metadata_dirty(nilfs, sci->sc_root)) |
780 | set_bit(NILFS_SC_DIRTY, &sci->sc_flags); | 780 | set_bit(NILFS_SC_DIRTY, &sci->sc_flags); |
781 | 781 | ||
782 | spin_lock(&sbi->s_inode_lock); | 782 | spin_lock(&nilfs->ns_inode_lock); |
783 | if (list_empty(&sbi->s_dirty_files) && nilfs_segctor_clean(sci)) | 783 | if (list_empty(&nilfs->ns_dirty_files) && nilfs_segctor_clean(sci)) |
784 | ret++; | 784 | ret++; |
785 | 785 | ||
786 | spin_unlock(&sbi->s_inode_lock); | 786 | spin_unlock(&nilfs->ns_inode_lock); |
787 | return ret; | 787 | return ret; |
788 | } | 788 | } |
789 | 789 | ||
@@ -1963,30 +1963,30 @@ static int nilfs_segctor_wait(struct nilfs_sc_info *sci) | |||
1963 | return ret; | 1963 | return ret; |
1964 | } | 1964 | } |
1965 | 1965 | ||
1966 | static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, | 1966 | static int nilfs_segctor_collect_dirty_files(struct nilfs_sc_info *sci, |
1967 | struct nilfs_sb_info *sbi) | 1967 | struct the_nilfs *nilfs) |
1968 | { | 1968 | { |
1969 | struct nilfs_inode_info *ii, *n; | 1969 | struct nilfs_inode_info *ii, *n; |
1970 | struct inode *ifile = sci->sc_root->ifile; | 1970 | struct inode *ifile = sci->sc_root->ifile; |
1971 | 1971 | ||
1972 | spin_lock(&sbi->s_inode_lock); | 1972 | spin_lock(&nilfs->ns_inode_lock); |
1973 | retry: | 1973 | retry: |
1974 | list_for_each_entry_safe(ii, n, &sbi->s_dirty_files, i_dirty) { | 1974 | list_for_each_entry_safe(ii, n, &nilfs->ns_dirty_files, i_dirty) { |
1975 | if (!ii->i_bh) { | 1975 | if (!ii->i_bh) { |
1976 | struct buffer_head *ibh; | 1976 | struct buffer_head *ibh; |
1977 | int err; | 1977 | int err; |
1978 | 1978 | ||
1979 | spin_unlock(&sbi->s_inode_lock); | 1979 | spin_unlock(&nilfs->ns_inode_lock); |
1980 | err = nilfs_ifile_get_inode_block( | 1980 | err = nilfs_ifile_get_inode_block( |
1981 | ifile, ii->vfs_inode.i_ino, &ibh); | 1981 | ifile, ii->vfs_inode.i_ino, &ibh); |
1982 | if (unlikely(err)) { | 1982 | if (unlikely(err)) { |
1983 | nilfs_warning(sbi->s_super, __func__, | 1983 | nilfs_warning(sci->sc_super, __func__, |
1984 | "failed to get inode block.\n"); | 1984 | "failed to get inode block.\n"); |
1985 | return err; | 1985 | return err; |
1986 | } | 1986 | } |
1987 | nilfs_mdt_mark_buffer_dirty(ibh); | 1987 | nilfs_mdt_mark_buffer_dirty(ibh); |
1988 | nilfs_mdt_mark_dirty(ifile); | 1988 | nilfs_mdt_mark_dirty(ifile); |
1989 | spin_lock(&sbi->s_inode_lock); | 1989 | spin_lock(&nilfs->ns_inode_lock); |
1990 | if (likely(!ii->i_bh)) | 1990 | if (likely(!ii->i_bh)) |
1991 | ii->i_bh = ibh; | 1991 | ii->i_bh = ibh; |
1992 | else | 1992 | else |
@@ -1999,18 +1999,18 @@ static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, | |||
1999 | list_del(&ii->i_dirty); | 1999 | list_del(&ii->i_dirty); |
2000 | list_add_tail(&ii->i_dirty, &sci->sc_dirty_files); | 2000 | list_add_tail(&ii->i_dirty, &sci->sc_dirty_files); |
2001 | } | 2001 | } |
2002 | spin_unlock(&sbi->s_inode_lock); | 2002 | spin_unlock(&nilfs->ns_inode_lock); |
2003 | 2003 | ||
2004 | return 0; | 2004 | return 0; |
2005 | } | 2005 | } |
2006 | 2006 | ||
2007 | static void nilfs_segctor_check_out_files(struct nilfs_sc_info *sci, | 2007 | static void nilfs_segctor_drop_written_files(struct nilfs_sc_info *sci, |
2008 | struct nilfs_sb_info *sbi) | 2008 | struct the_nilfs *nilfs) |
2009 | { | 2009 | { |
2010 | struct nilfs_transaction_info *ti = current->journal_info; | 2010 | struct nilfs_transaction_info *ti = current->journal_info; |
2011 | struct nilfs_inode_info *ii, *n; | 2011 | struct nilfs_inode_info *ii, *n; |
2012 | 2012 | ||
2013 | spin_lock(&sbi->s_inode_lock); | 2013 | spin_lock(&nilfs->ns_inode_lock); |
2014 | list_for_each_entry_safe(ii, n, &sci->sc_dirty_files, i_dirty) { | 2014 | list_for_each_entry_safe(ii, n, &sci->sc_dirty_files, i_dirty) { |
2015 | if (!test_and_clear_bit(NILFS_I_UPDATED, &ii->i_state) || | 2015 | if (!test_and_clear_bit(NILFS_I_UPDATED, &ii->i_state) || |
2016 | test_bit(NILFS_I_DIRTY, &ii->i_state)) | 2016 | test_bit(NILFS_I_DIRTY, &ii->i_state)) |
@@ -2022,7 +2022,7 @@ static void nilfs_segctor_check_out_files(struct nilfs_sc_info *sci, | |||
2022 | list_del(&ii->i_dirty); | 2022 | list_del(&ii->i_dirty); |
2023 | list_add_tail(&ii->i_dirty, &ti->ti_garbage); | 2023 | list_add_tail(&ii->i_dirty, &ti->ti_garbage); |
2024 | } | 2024 | } |
2025 | spin_unlock(&sbi->s_inode_lock); | 2025 | spin_unlock(&nilfs->ns_inode_lock); |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | /* | 2028 | /* |
@@ -2038,7 +2038,7 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2038 | sci->sc_stage.scnt = NILFS_ST_INIT; | 2038 | sci->sc_stage.scnt = NILFS_ST_INIT; |
2039 | sci->sc_cno = nilfs->ns_cno; | 2039 | sci->sc_cno = nilfs->ns_cno; |
2040 | 2040 | ||
2041 | err = nilfs_segctor_check_in_files(sci, sbi); | 2041 | err = nilfs_segctor_collect_dirty_files(sci, nilfs); |
2042 | if (unlikely(err)) | 2042 | if (unlikely(err)) |
2043 | goto out; | 2043 | goto out; |
2044 | 2044 | ||
@@ -2116,7 +2116,7 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2116 | } while (sci->sc_stage.scnt != NILFS_ST_DONE); | 2116 | } while (sci->sc_stage.scnt != NILFS_ST_DONE); |
2117 | 2117 | ||
2118 | out: | 2118 | out: |
2119 | nilfs_segctor_check_out_files(sci, sbi); | 2119 | nilfs_segctor_drop_written_files(sci, nilfs); |
2120 | return err; | 2120 | return err; |
2121 | 2121 | ||
2122 | failed_to_write: | 2122 | failed_to_write: |
@@ -2319,14 +2319,14 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, | |||
2319 | return err; | 2319 | return err; |
2320 | } | 2320 | } |
2321 | 2321 | ||
2322 | spin_lock(&sbi->s_inode_lock); | 2322 | spin_lock(&nilfs->ns_inode_lock); |
2323 | if (!test_bit(NILFS_I_QUEUED, &ii->i_state) && | 2323 | if (!test_bit(NILFS_I_QUEUED, &ii->i_state) && |
2324 | !test_bit(NILFS_I_BUSY, &ii->i_state)) { | 2324 | !test_bit(NILFS_I_BUSY, &ii->i_state)) { |
2325 | spin_unlock(&sbi->s_inode_lock); | 2325 | spin_unlock(&nilfs->ns_inode_lock); |
2326 | nilfs_transaction_unlock(sbi); | 2326 | nilfs_transaction_unlock(sbi); |
2327 | return 0; | 2327 | return 0; |
2328 | } | 2328 | } |
2329 | spin_unlock(&sbi->s_inode_lock); | 2329 | spin_unlock(&nilfs->ns_inode_lock); |
2330 | sci->sc_dsync_inode = ii; | 2330 | sci->sc_dsync_inode = ii; |
2331 | sci->sc_dsync_start = start; | 2331 | sci->sc_dsync_start = start; |
2332 | sci->sc_dsync_end = end; | 2332 | sci->sc_dsync_end = end; |
@@ -2738,10 +2738,10 @@ static void nilfs_segctor_write_out(struct nilfs_sc_info *sci) | |||
2738 | */ | 2738 | */ |
2739 | static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | 2739 | static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) |
2740 | { | 2740 | { |
2741 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 2741 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; |
2742 | int flag; | 2742 | int flag; |
2743 | 2743 | ||
2744 | up_write(&sbi->s_nilfs->ns_segctor_sem); | 2744 | up_write(&nilfs->ns_segctor_sem); |
2745 | 2745 | ||
2746 | spin_lock(&sci->sc_state_lock); | 2746 | spin_lock(&sci->sc_state_lock); |
2747 | nilfs_segctor_kill_thread(sci); | 2747 | nilfs_segctor_kill_thread(sci); |
@@ -2755,9 +2755,9 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2755 | WARN_ON(!list_empty(&sci->sc_copied_buffers)); | 2755 | WARN_ON(!list_empty(&sci->sc_copied_buffers)); |
2756 | 2756 | ||
2757 | if (!list_empty(&sci->sc_dirty_files)) { | 2757 | if (!list_empty(&sci->sc_dirty_files)) { |
2758 | nilfs_warning(sbi->s_super, __func__, | 2758 | nilfs_warning(sci->sc_super, __func__, |
2759 | "dirty file(s) after the final construction\n"); | 2759 | "dirty file(s) after the final construction\n"); |
2760 | nilfs_dispose_list(sbi, &sci->sc_dirty_files, 1); | 2760 | nilfs_dispose_list(nilfs, &sci->sc_dirty_files, 1); |
2761 | } | 2761 | } |
2762 | 2762 | ||
2763 | WARN_ON(!list_empty(&sci->sc_segbufs)); | 2763 | WARN_ON(!list_empty(&sci->sc_segbufs)); |
@@ -2765,7 +2765,7 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2765 | 2765 | ||
2766 | nilfs_put_root(sci->sc_root); | 2766 | nilfs_put_root(sci->sc_root); |
2767 | 2767 | ||
2768 | down_write(&sbi->s_nilfs->ns_segctor_sem); | 2768 | down_write(&nilfs->ns_segctor_sem); |
2769 | 2769 | ||
2770 | del_timer_sync(&sci->sc_timer); | 2770 | del_timer_sync(&sci->sc_timer); |
2771 | kfree(sci); | 2771 | kfree(sci); |
@@ -2829,15 +2829,15 @@ void nilfs_detach_segment_constructor(struct nilfs_sb_info *sbi) | |||
2829 | } | 2829 | } |
2830 | 2830 | ||
2831 | /* Force to free the list of dirty files */ | 2831 | /* Force to free the list of dirty files */ |
2832 | spin_lock(&sbi->s_inode_lock); | 2832 | spin_lock(&nilfs->ns_inode_lock); |
2833 | if (!list_empty(&sbi->s_dirty_files)) { | 2833 | if (!list_empty(&nilfs->ns_dirty_files)) { |
2834 | list_splice_init(&sbi->s_dirty_files, &garbage_list); | 2834 | list_splice_init(&nilfs->ns_dirty_files, &garbage_list); |
2835 | nilfs_warning(sbi->s_super, __func__, | 2835 | nilfs_warning(sbi->s_super, __func__, |
2836 | "Non empty dirty list after the last " | 2836 | "Non empty dirty list after the last " |
2837 | "segment construction\n"); | 2837 | "segment construction\n"); |
2838 | } | 2838 | } |
2839 | spin_unlock(&sbi->s_inode_lock); | 2839 | spin_unlock(&nilfs->ns_inode_lock); |
2840 | up_write(&nilfs->ns_segctor_sem); | 2840 | up_write(&nilfs->ns_segctor_sem); |
2841 | 2841 | ||
2842 | nilfs_dispose_list(sbi, &garbage_list, 1); | 2842 | nilfs_dispose_list(nilfs, &garbage_list, 1); |
2843 | } | 2843 | } |
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 2f17a2f9ef9c..6dc8b3cad127 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
@@ -943,9 +943,6 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent) | |||
943 | if (err) | 943 | if (err) |
944 | goto failed_nilfs; | 944 | goto failed_nilfs; |
945 | 945 | ||
946 | spin_lock_init(&sbi->s_inode_lock); | ||
947 | INIT_LIST_HEAD(&sbi->s_dirty_files); | ||
948 | |||
949 | /* | 946 | /* |
950 | * Following initialization is overlapped because | 947 | * Following initialization is overlapped because |
951 | * nilfs_sb_info structure has been cleared at the beginning. | 948 | * nilfs_sb_info structure has been cleared at the beginning. |
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index d3775336a16c..40239a932dec 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c | |||
@@ -75,7 +75,9 @@ struct the_nilfs *alloc_nilfs(struct block_device *bdev) | |||
75 | nilfs->ns_bdev = bdev; | 75 | nilfs->ns_bdev = bdev; |
76 | atomic_set(&nilfs->ns_ndirtyblks, 0); | 76 | atomic_set(&nilfs->ns_ndirtyblks, 0); |
77 | init_rwsem(&nilfs->ns_sem); | 77 | init_rwsem(&nilfs->ns_sem); |
78 | INIT_LIST_HEAD(&nilfs->ns_dirty_files); | ||
78 | INIT_LIST_HEAD(&nilfs->ns_gc_inodes); | 79 | INIT_LIST_HEAD(&nilfs->ns_gc_inodes); |
80 | spin_lock_init(&nilfs->ns_inode_lock); | ||
79 | spin_lock_init(&nilfs->ns_last_segment_lock); | 81 | spin_lock_init(&nilfs->ns_last_segment_lock); |
80 | nilfs->ns_cptree = RB_ROOT; | 82 | nilfs->ns_cptree = RB_ROOT; |
81 | spin_lock_init(&nilfs->ns_cptree_lock); | 83 | spin_lock_init(&nilfs->ns_cptree_lock); |
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index 4a9bf3913c9c..6106ec5ad89a 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h | |||
@@ -71,6 +71,8 @@ enum { | |||
71 | * @ns_sufile: segusage file inode | 71 | * @ns_sufile: segusage file inode |
72 | * @ns_cptree: rb-tree of all mounted checkpoints (nilfs_root) | 72 | * @ns_cptree: rb-tree of all mounted checkpoints (nilfs_root) |
73 | * @ns_cptree_lock: lock protecting @ns_cptree | 73 | * @ns_cptree_lock: lock protecting @ns_cptree |
74 | * @ns_dirty_files: list of dirty files | ||
75 | * @ns_inode_lock: lock protecting @ns_dirty_files | ||
74 | * @ns_gc_inodes: dummy inodes to keep live blocks | 76 | * @ns_gc_inodes: dummy inodes to keep live blocks |
75 | * @ns_mount_opt: mount options | 77 | * @ns_mount_opt: mount options |
76 | * @ns_resuid: uid for reserved blocks | 78 | * @ns_resuid: uid for reserved blocks |
@@ -150,6 +152,10 @@ struct the_nilfs { | |||
150 | struct rb_root ns_cptree; | 152 | struct rb_root ns_cptree; |
151 | spinlock_t ns_cptree_lock; | 153 | spinlock_t ns_cptree_lock; |
152 | 154 | ||
155 | /* Dirty inode list */ | ||
156 | struct list_head ns_dirty_files; | ||
157 | spinlock_t ns_inode_lock; | ||
158 | |||
153 | /* GC inode list */ | 159 | /* GC inode list */ |
154 | struct list_head ns_gc_inodes; | 160 | struct list_head ns_gc_inodes; |
155 | 161 | ||