diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2011-03-08 21:05:07 -0500 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2011-03-08 21:05:07 -0500 |
commit | 693dd321222f03b17668f88ceb0f7d518900191e (patch) | |
tree | b0088ee73f3499e0b3301fc5dcf44c677cfd092d /fs/nilfs2/segment.c | |
parent | 574e6c3145c5754141361c695b58736c294a8ae1 (diff) |
nilfs2: move s_inode_lock and s_dirty_files into nilfs object
Moves s_inode_lock spinlock and s_dirty_files list to nilfs object
from nilfs_sb_info structure.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/segment.c')
-rw-r--r-- | fs/nilfs2/segment.c | 80 |
1 files changed, 40 insertions, 40 deletions
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 | } |