diff options
Diffstat (limited to 'fs/nilfs2/segment.c')
-rw-r--r-- | fs/nilfs2/segment.c | 157 |
1 files changed, 40 insertions, 117 deletions
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 6a7dbd8451db..c9201649cc49 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
@@ -116,42 +116,6 @@ static void nilfs_dispose_list(struct nilfs_sb_info *, struct list_head *, | |||
116 | #define nilfs_cnt32_lt(a, b) nilfs_cnt32_gt(b, a) | 116 | #define nilfs_cnt32_lt(a, b) nilfs_cnt32_gt(b, a) |
117 | #define nilfs_cnt32_le(a, b) nilfs_cnt32_ge(b, a) | 117 | #define nilfs_cnt32_le(a, b) nilfs_cnt32_ge(b, a) |
118 | 118 | ||
119 | /* | ||
120 | * Transaction | ||
121 | */ | ||
122 | static struct kmem_cache *nilfs_transaction_cachep; | ||
123 | |||
124 | /** | ||
125 | * nilfs_init_transaction_cache - create a cache for nilfs_transaction_info | ||
126 | * | ||
127 | * nilfs_init_transaction_cache() creates a slab cache for the struct | ||
128 | * nilfs_transaction_info. | ||
129 | * | ||
130 | * Return Value: On success, it returns 0. On error, one of the following | ||
131 | * negative error code is returned. | ||
132 | * | ||
133 | * %-ENOMEM - Insufficient memory available. | ||
134 | */ | ||
135 | int nilfs_init_transaction_cache(void) | ||
136 | { | ||
137 | nilfs_transaction_cachep = | ||
138 | kmem_cache_create("nilfs2_transaction_cache", | ||
139 | sizeof(struct nilfs_transaction_info), | ||
140 | 0, SLAB_RECLAIM_ACCOUNT, NULL); | ||
141 | return (nilfs_transaction_cachep == NULL) ? -ENOMEM : 0; | ||
142 | } | ||
143 | |||
144 | /** | ||
145 | * nilfs_destroy_transaction_cache - destroy the cache for transaction info | ||
146 | * | ||
147 | * nilfs_destroy_transaction_cache() frees the slab cache for the struct | ||
148 | * nilfs_transaction_info. | ||
149 | */ | ||
150 | void nilfs_destroy_transaction_cache(void) | ||
151 | { | ||
152 | kmem_cache_destroy(nilfs_transaction_cachep); | ||
153 | } | ||
154 | |||
155 | static int nilfs_prepare_segment_lock(struct nilfs_transaction_info *ti) | 119 | static int nilfs_prepare_segment_lock(struct nilfs_transaction_info *ti) |
156 | { | 120 | { |
157 | struct nilfs_transaction_info *cur_ti = current->journal_info; | 121 | struct nilfs_transaction_info *cur_ti = current->journal_info; |
@@ -402,7 +366,8 @@ static int nilfs_segctor_reset_segment_buffer(struct nilfs_sc_info *sci) | |||
402 | 366 | ||
403 | if (nilfs_doing_gc()) | 367 | if (nilfs_doing_gc()) |
404 | flags = NILFS_SS_GC; | 368 | flags = NILFS_SS_GC; |
405 | err = nilfs_segbuf_reset(segbuf, flags, sci->sc_seg_ctime); | 369 | err = nilfs_segbuf_reset(segbuf, flags, sci->sc_seg_ctime, |
370 | sci->sc_sbi->s_nilfs->ns_cno); | ||
406 | if (unlikely(err)) | 371 | if (unlikely(err)) |
407 | return err; | 372 | return err; |
408 | 373 | ||
@@ -435,7 +400,7 @@ static int nilfs_segctor_add_super_root(struct nilfs_sc_info *sci) | |||
435 | return err; | 400 | return err; |
436 | segbuf = sci->sc_curseg; | 401 | segbuf = sci->sc_curseg; |
437 | } | 402 | } |
438 | err = nilfs_segbuf_extend_payload(segbuf, &sci->sc_super_root); | 403 | err = nilfs_segbuf_extend_payload(segbuf, &segbuf->sb_super_root); |
439 | if (likely(!err)) | 404 | if (likely(!err)) |
440 | segbuf->sb_sum.flags |= NILFS_SS_SR; | 405 | segbuf->sb_sum.flags |= NILFS_SS_SR; |
441 | return err; | 406 | return err; |
@@ -599,7 +564,7 @@ static void nilfs_write_file_node_binfo(struct nilfs_sc_info *sci, | |||
599 | *vblocknr = binfo->bi_v.bi_vblocknr; | 564 | *vblocknr = binfo->bi_v.bi_vblocknr; |
600 | } | 565 | } |
601 | 566 | ||
602 | struct nilfs_sc_operations nilfs_sc_file_ops = { | 567 | static struct nilfs_sc_operations nilfs_sc_file_ops = { |
603 | .collect_data = nilfs_collect_file_data, | 568 | .collect_data = nilfs_collect_file_data, |
604 | .collect_node = nilfs_collect_file_node, | 569 | .collect_node = nilfs_collect_file_node, |
605 | .collect_bmap = nilfs_collect_file_bmap, | 570 | .collect_bmap = nilfs_collect_file_bmap, |
@@ -649,7 +614,7 @@ static void nilfs_write_dat_node_binfo(struct nilfs_sc_info *sci, | |||
649 | *binfo_dat = binfo->bi_dat; | 614 | *binfo_dat = binfo->bi_dat; |
650 | } | 615 | } |
651 | 616 | ||
652 | struct nilfs_sc_operations nilfs_sc_dat_ops = { | 617 | static struct nilfs_sc_operations nilfs_sc_dat_ops = { |
653 | .collect_data = nilfs_collect_dat_data, | 618 | .collect_data = nilfs_collect_dat_data, |
654 | .collect_node = nilfs_collect_file_node, | 619 | .collect_node = nilfs_collect_file_node, |
655 | .collect_bmap = nilfs_collect_dat_bmap, | 620 | .collect_bmap = nilfs_collect_dat_bmap, |
@@ -657,7 +622,7 @@ struct nilfs_sc_operations nilfs_sc_dat_ops = { | |||
657 | .write_node_binfo = nilfs_write_dat_node_binfo, | 622 | .write_node_binfo = nilfs_write_dat_node_binfo, |
658 | }; | 623 | }; |
659 | 624 | ||
660 | struct nilfs_sc_operations nilfs_sc_dsync_ops = { | 625 | static struct nilfs_sc_operations nilfs_sc_dsync_ops = { |
661 | .collect_data = nilfs_collect_file_data, | 626 | .collect_data = nilfs_collect_file_data, |
662 | .collect_node = NULL, | 627 | .collect_node = NULL, |
663 | .collect_bmap = NULL, | 628 | .collect_bmap = NULL, |
@@ -932,43 +897,16 @@ static void nilfs_segctor_fill_in_file_bmap(struct nilfs_sc_info *sci, | |||
932 | } | 897 | } |
933 | } | 898 | } |
934 | 899 | ||
935 | /* | ||
936 | * CRC calculation routines | ||
937 | */ | ||
938 | static void nilfs_fill_in_super_root_crc(struct buffer_head *bh_sr, u32 seed) | ||
939 | { | ||
940 | struct nilfs_super_root *raw_sr = | ||
941 | (struct nilfs_super_root *)bh_sr->b_data; | ||
942 | u32 crc; | ||
943 | |||
944 | crc = crc32_le(seed, | ||
945 | (unsigned char *)raw_sr + sizeof(raw_sr->sr_sum), | ||
946 | NILFS_SR_BYTES - sizeof(raw_sr->sr_sum)); | ||
947 | raw_sr->sr_sum = cpu_to_le32(crc); | ||
948 | } | ||
949 | |||
950 | static void nilfs_segctor_fill_in_checksums(struct nilfs_sc_info *sci, | ||
951 | u32 seed) | ||
952 | { | ||
953 | struct nilfs_segment_buffer *segbuf; | ||
954 | |||
955 | if (sci->sc_super_root) | ||
956 | nilfs_fill_in_super_root_crc(sci->sc_super_root, seed); | ||
957 | |||
958 | list_for_each_entry(segbuf, &sci->sc_segbufs, sb_list) { | ||
959 | nilfs_segbuf_fill_in_segsum_crc(segbuf, seed); | ||
960 | nilfs_segbuf_fill_in_data_crc(segbuf, seed); | ||
961 | } | ||
962 | } | ||
963 | |||
964 | static void nilfs_segctor_fill_in_super_root(struct nilfs_sc_info *sci, | 900 | static void nilfs_segctor_fill_in_super_root(struct nilfs_sc_info *sci, |
965 | struct the_nilfs *nilfs) | 901 | struct the_nilfs *nilfs) |
966 | { | 902 | { |
967 | struct buffer_head *bh_sr = sci->sc_super_root; | 903 | struct buffer_head *bh_sr; |
968 | struct nilfs_super_root *raw_sr = | 904 | struct nilfs_super_root *raw_sr; |
969 | (struct nilfs_super_root *)bh_sr->b_data; | ||
970 | unsigned isz = nilfs->ns_inode_size; | 905 | unsigned isz = nilfs->ns_inode_size; |
971 | 906 | ||
907 | bh_sr = NILFS_LAST_SEGBUF(&sci->sc_segbufs)->sb_super_root; | ||
908 | raw_sr = (struct nilfs_super_root *)bh_sr->b_data; | ||
909 | |||
972 | raw_sr->sr_bytes = cpu_to_le16(NILFS_SR_BYTES); | 910 | raw_sr->sr_bytes = cpu_to_le16(NILFS_SR_BYTES); |
973 | raw_sr->sr_nongc_ctime | 911 | raw_sr->sr_nongc_ctime |
974 | = cpu_to_le64(nilfs_doing_gc() ? | 912 | = cpu_to_le64(nilfs_doing_gc() ? |
@@ -1491,7 +1429,6 @@ static int nilfs_segctor_collect(struct nilfs_sc_info *sci, | |||
1491 | 1429 | ||
1492 | /* Collection retry loop */ | 1430 | /* Collection retry loop */ |
1493 | for (;;) { | 1431 | for (;;) { |
1494 | sci->sc_super_root = NULL; | ||
1495 | sci->sc_nblk_this_inc = 0; | 1432 | sci->sc_nblk_this_inc = 0; |
1496 | sci->sc_curseg = NILFS_FIRST_SEGBUF(&sci->sc_segbufs); | 1433 | sci->sc_curseg = NILFS_FIRST_SEGBUF(&sci->sc_segbufs); |
1497 | 1434 | ||
@@ -1568,7 +1505,7 @@ nilfs_segctor_update_payload_blocknr(struct nilfs_sc_info *sci, | |||
1568 | ssp.offset = sizeof(struct nilfs_segment_summary); | 1505 | ssp.offset = sizeof(struct nilfs_segment_summary); |
1569 | 1506 | ||
1570 | list_for_each_entry(bh, &segbuf->sb_payload_buffers, b_assoc_buffers) { | 1507 | list_for_each_entry(bh, &segbuf->sb_payload_buffers, b_assoc_buffers) { |
1571 | if (bh == sci->sc_super_root) | 1508 | if (bh == segbuf->sb_super_root) |
1572 | break; | 1509 | break; |
1573 | if (!finfo) { | 1510 | if (!finfo) { |
1574 | finfo = nilfs_segctor_map_segsum_entry( | 1511 | finfo = nilfs_segctor_map_segsum_entry( |
@@ -1729,7 +1666,7 @@ static int nilfs_segctor_prepare_write(struct nilfs_sc_info *sci, | |||
1729 | 1666 | ||
1730 | list_for_each_entry(bh, &segbuf->sb_payload_buffers, | 1667 | list_for_each_entry(bh, &segbuf->sb_payload_buffers, |
1731 | b_assoc_buffers) { | 1668 | b_assoc_buffers) { |
1732 | if (bh == sci->sc_super_root) { | 1669 | if (bh == segbuf->sb_super_root) { |
1733 | if (bh->b_page != bd_page) { | 1670 | if (bh->b_page != bd_page) { |
1734 | lock_page(bd_page); | 1671 | lock_page(bd_page); |
1735 | clear_page_dirty_for_io(bd_page); | 1672 | clear_page_dirty_for_io(bd_page); |
@@ -1848,7 +1785,7 @@ static void nilfs_clear_copied_buffers(struct list_head *list, int err) | |||
1848 | } | 1785 | } |
1849 | 1786 | ||
1850 | static void nilfs_abort_logs(struct list_head *logs, struct page *failed_page, | 1787 | static void nilfs_abort_logs(struct list_head *logs, struct page *failed_page, |
1851 | struct buffer_head *bh_sr, int err) | 1788 | int err) |
1852 | { | 1789 | { |
1853 | struct nilfs_segment_buffer *segbuf; | 1790 | struct nilfs_segment_buffer *segbuf; |
1854 | struct page *bd_page = NULL, *fs_page = NULL; | 1791 | struct page *bd_page = NULL, *fs_page = NULL; |
@@ -1869,7 +1806,7 @@ static void nilfs_abort_logs(struct list_head *logs, struct page *failed_page, | |||
1869 | 1806 | ||
1870 | list_for_each_entry(bh, &segbuf->sb_payload_buffers, | 1807 | list_for_each_entry(bh, &segbuf->sb_payload_buffers, |
1871 | b_assoc_buffers) { | 1808 | b_assoc_buffers) { |
1872 | if (bh == bh_sr) { | 1809 | if (bh == segbuf->sb_super_root) { |
1873 | if (bh->b_page != bd_page) { | 1810 | if (bh->b_page != bd_page) { |
1874 | end_page_writeback(bd_page); | 1811 | end_page_writeback(bd_page); |
1875 | bd_page = bh->b_page; | 1812 | bd_page = bh->b_page; |
@@ -1898,7 +1835,7 @@ static void nilfs_segctor_abort_construction(struct nilfs_sc_info *sci, | |||
1898 | 1835 | ||
1899 | list_splice_tail_init(&sci->sc_write_logs, &logs); | 1836 | list_splice_tail_init(&sci->sc_write_logs, &logs); |
1900 | ret = nilfs_wait_on_logs(&logs); | 1837 | ret = nilfs_wait_on_logs(&logs); |
1901 | nilfs_abort_logs(&logs, NULL, sci->sc_super_root, ret ? : err); | 1838 | nilfs_abort_logs(&logs, NULL, ret ? : err); |
1902 | 1839 | ||
1903 | list_splice_tail_init(&sci->sc_segbufs, &logs); | 1840 | list_splice_tail_init(&sci->sc_segbufs, &logs); |
1904 | nilfs_cancel_segusage(&logs, nilfs->ns_sufile); | 1841 | nilfs_cancel_segusage(&logs, nilfs->ns_sufile); |
@@ -1914,7 +1851,6 @@ static void nilfs_segctor_abort_construction(struct nilfs_sc_info *sci, | |||
1914 | } | 1851 | } |
1915 | 1852 | ||
1916 | nilfs_destroy_logs(&logs); | 1853 | nilfs_destroy_logs(&logs); |
1917 | sci->sc_super_root = NULL; | ||
1918 | } | 1854 | } |
1919 | 1855 | ||
1920 | static void nilfs_set_next_segment(struct the_nilfs *nilfs, | 1856 | static void nilfs_set_next_segment(struct the_nilfs *nilfs, |
@@ -1933,7 +1869,7 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci) | |||
1933 | struct nilfs_segment_buffer *segbuf; | 1869 | struct nilfs_segment_buffer *segbuf; |
1934 | struct page *bd_page = NULL, *fs_page = NULL; | 1870 | struct page *bd_page = NULL, *fs_page = NULL; |
1935 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; | 1871 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; |
1936 | int update_sr = (sci->sc_super_root != NULL); | 1872 | int update_sr = false; |
1937 | 1873 | ||
1938 | list_for_each_entry(segbuf, &sci->sc_write_logs, sb_list) { | 1874 | list_for_each_entry(segbuf, &sci->sc_write_logs, sb_list) { |
1939 | struct buffer_head *bh; | 1875 | struct buffer_head *bh; |
@@ -1964,11 +1900,12 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci) | |||
1964 | set_buffer_uptodate(bh); | 1900 | set_buffer_uptodate(bh); |
1965 | clear_buffer_dirty(bh); | 1901 | clear_buffer_dirty(bh); |
1966 | clear_buffer_nilfs_volatile(bh); | 1902 | clear_buffer_nilfs_volatile(bh); |
1967 | if (bh == sci->sc_super_root) { | 1903 | if (bh == segbuf->sb_super_root) { |
1968 | if (bh->b_page != bd_page) { | 1904 | if (bh->b_page != bd_page) { |
1969 | end_page_writeback(bd_page); | 1905 | end_page_writeback(bd_page); |
1970 | bd_page = bh->b_page; | 1906 | bd_page = bh->b_page; |
1971 | } | 1907 | } |
1908 | update_sr = true; | ||
1972 | break; | 1909 | break; |
1973 | } | 1910 | } |
1974 | if (bh->b_page != fs_page) { | 1911 | if (bh->b_page != fs_page) { |
@@ -2115,7 +2052,7 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2115 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 2052 | struct nilfs_sb_info *sbi = sci->sc_sbi; |
2116 | struct the_nilfs *nilfs = sbi->s_nilfs; | 2053 | struct the_nilfs *nilfs = sbi->s_nilfs; |
2117 | struct page *failed_page; | 2054 | struct page *failed_page; |
2118 | int err, has_sr = 0; | 2055 | int err; |
2119 | 2056 | ||
2120 | sci->sc_stage.scnt = NILFS_ST_INIT; | 2057 | sci->sc_stage.scnt = NILFS_ST_INIT; |
2121 | 2058 | ||
@@ -2143,8 +2080,6 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2143 | if (unlikely(err)) | 2080 | if (unlikely(err)) |
2144 | goto failed; | 2081 | goto failed; |
2145 | 2082 | ||
2146 | has_sr = (sci->sc_super_root != NULL); | ||
2147 | |||
2148 | /* Avoid empty segment */ | 2083 | /* Avoid empty segment */ |
2149 | if (sci->sc_stage.scnt == NILFS_ST_DONE && | 2084 | if (sci->sc_stage.scnt == NILFS_ST_DONE && |
2150 | NILFS_SEG_EMPTY(&sci->sc_curseg->sb_sum)) { | 2085 | NILFS_SEG_EMPTY(&sci->sc_curseg->sb_sum)) { |
@@ -2159,7 +2094,8 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2159 | if (sci->sc_stage.flags & NILFS_CF_IFILE_STARTED) | 2094 | if (sci->sc_stage.flags & NILFS_CF_IFILE_STARTED) |
2160 | nilfs_segctor_fill_in_file_bmap(sci, sbi->s_ifile); | 2095 | nilfs_segctor_fill_in_file_bmap(sci, sbi->s_ifile); |
2161 | 2096 | ||
2162 | if (has_sr) { | 2097 | if (mode == SC_LSEG_SR && |
2098 | sci->sc_stage.scnt >= NILFS_ST_CPFILE) { | ||
2163 | err = nilfs_segctor_fill_in_checkpoint(sci); | 2099 | err = nilfs_segctor_fill_in_checkpoint(sci); |
2164 | if (unlikely(err)) | 2100 | if (unlikely(err)) |
2165 | goto failed_to_write; | 2101 | goto failed_to_write; |
@@ -2171,11 +2107,12 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2171 | /* Write partial segments */ | 2107 | /* Write partial segments */ |
2172 | err = nilfs_segctor_prepare_write(sci, &failed_page); | 2108 | err = nilfs_segctor_prepare_write(sci, &failed_page); |
2173 | if (err) { | 2109 | if (err) { |
2174 | nilfs_abort_logs(&sci->sc_segbufs, failed_page, | 2110 | nilfs_abort_logs(&sci->sc_segbufs, failed_page, err); |
2175 | sci->sc_super_root, err); | ||
2176 | goto failed_to_write; | 2111 | goto failed_to_write; |
2177 | } | 2112 | } |
2178 | nilfs_segctor_fill_in_checksums(sci, nilfs->ns_crc_seed); | 2113 | |
2114 | nilfs_add_checksums_on_logs(&sci->sc_segbufs, | ||
2115 | nilfs->ns_crc_seed); | ||
2179 | 2116 | ||
2180 | err = nilfs_segctor_write(sci, nilfs); | 2117 | err = nilfs_segctor_write(sci, nilfs); |
2181 | if (unlikely(err)) | 2118 | if (unlikely(err)) |
@@ -2196,8 +2133,6 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2196 | } | 2133 | } |
2197 | } while (sci->sc_stage.scnt != NILFS_ST_DONE); | 2134 | } while (sci->sc_stage.scnt != NILFS_ST_DONE); |
2198 | 2135 | ||
2199 | sci->sc_super_root = NULL; | ||
2200 | |||
2201 | out: | 2136 | out: |
2202 | nilfs_segctor_check_out_files(sci, sbi); | 2137 | nilfs_segctor_check_out_files(sci, sbi); |
2203 | return err; | 2138 | return err; |
@@ -2224,9 +2159,9 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2224 | static void nilfs_segctor_start_timer(struct nilfs_sc_info *sci) | 2159 | static void nilfs_segctor_start_timer(struct nilfs_sc_info *sci) |
2225 | { | 2160 | { |
2226 | spin_lock(&sci->sc_state_lock); | 2161 | spin_lock(&sci->sc_state_lock); |
2227 | if (sci->sc_timer && !(sci->sc_state & NILFS_SEGCTOR_COMMIT)) { | 2162 | if (!(sci->sc_state & NILFS_SEGCTOR_COMMIT)) { |
2228 | sci->sc_timer->expires = jiffies + sci->sc_interval; | 2163 | sci->sc_timer.expires = jiffies + sci->sc_interval; |
2229 | add_timer(sci->sc_timer); | 2164 | add_timer(&sci->sc_timer); |
2230 | sci->sc_state |= NILFS_SEGCTOR_COMMIT; | 2165 | sci->sc_state |= NILFS_SEGCTOR_COMMIT; |
2231 | } | 2166 | } |
2232 | spin_unlock(&sci->sc_state_lock); | 2167 | spin_unlock(&sci->sc_state_lock); |
@@ -2431,9 +2366,7 @@ static void nilfs_segctor_accept(struct nilfs_sc_info *sci) | |||
2431 | spin_lock(&sci->sc_state_lock); | 2366 | spin_lock(&sci->sc_state_lock); |
2432 | sci->sc_seq_accepted = sci->sc_seq_request; | 2367 | sci->sc_seq_accepted = sci->sc_seq_request; |
2433 | spin_unlock(&sci->sc_state_lock); | 2368 | spin_unlock(&sci->sc_state_lock); |
2434 | 2369 | del_timer_sync(&sci->sc_timer); | |
2435 | if (sci->sc_timer) | ||
2436 | del_timer_sync(sci->sc_timer); | ||
2437 | } | 2370 | } |
2438 | 2371 | ||
2439 | /** | 2372 | /** |
@@ -2459,9 +2392,9 @@ static void nilfs_segctor_notify(struct nilfs_sc_info *sci, int mode, int err) | |||
2459 | sci->sc_flush_request &= ~FLUSH_DAT_BIT; | 2392 | sci->sc_flush_request &= ~FLUSH_DAT_BIT; |
2460 | 2393 | ||
2461 | /* re-enable timer if checkpoint creation was not done */ | 2394 | /* re-enable timer if checkpoint creation was not done */ |
2462 | if (sci->sc_timer && (sci->sc_state & NILFS_SEGCTOR_COMMIT) && | 2395 | if ((sci->sc_state & NILFS_SEGCTOR_COMMIT) && |
2463 | time_before(jiffies, sci->sc_timer->expires)) | 2396 | time_before(jiffies, sci->sc_timer.expires)) |
2464 | add_timer(sci->sc_timer); | 2397 | add_timer(&sci->sc_timer); |
2465 | } | 2398 | } |
2466 | spin_unlock(&sci->sc_state_lock); | 2399 | spin_unlock(&sci->sc_state_lock); |
2467 | } | 2400 | } |
@@ -2640,13 +2573,10 @@ static int nilfs_segctor_thread(void *arg) | |||
2640 | { | 2573 | { |
2641 | struct nilfs_sc_info *sci = (struct nilfs_sc_info *)arg; | 2574 | struct nilfs_sc_info *sci = (struct nilfs_sc_info *)arg; |
2642 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; | 2575 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; |
2643 | struct timer_list timer; | ||
2644 | int timeout = 0; | 2576 | int timeout = 0; |
2645 | 2577 | ||
2646 | init_timer(&timer); | 2578 | sci->sc_timer.data = (unsigned long)current; |
2647 | timer.data = (unsigned long)current; | 2579 | sci->sc_timer.function = nilfs_construction_timeout; |
2648 | timer.function = nilfs_construction_timeout; | ||
2649 | sci->sc_timer = &timer; | ||
2650 | 2580 | ||
2651 | /* start sync. */ | 2581 | /* start sync. */ |
2652 | sci->sc_task = current; | 2582 | sci->sc_task = current; |
@@ -2695,7 +2625,7 @@ static int nilfs_segctor_thread(void *arg) | |||
2695 | should_sleep = 0; | 2625 | should_sleep = 0; |
2696 | else if (sci->sc_state & NILFS_SEGCTOR_COMMIT) | 2626 | else if (sci->sc_state & NILFS_SEGCTOR_COMMIT) |
2697 | should_sleep = time_before(jiffies, | 2627 | should_sleep = time_before(jiffies, |
2698 | sci->sc_timer->expires); | 2628 | sci->sc_timer.expires); |
2699 | 2629 | ||
2700 | if (should_sleep) { | 2630 | if (should_sleep) { |
2701 | spin_unlock(&sci->sc_state_lock); | 2631 | spin_unlock(&sci->sc_state_lock); |
@@ -2704,7 +2634,7 @@ static int nilfs_segctor_thread(void *arg) | |||
2704 | } | 2634 | } |
2705 | finish_wait(&sci->sc_wait_daemon, &wait); | 2635 | finish_wait(&sci->sc_wait_daemon, &wait); |
2706 | timeout = ((sci->sc_state & NILFS_SEGCTOR_COMMIT) && | 2636 | timeout = ((sci->sc_state & NILFS_SEGCTOR_COMMIT) && |
2707 | time_after_eq(jiffies, sci->sc_timer->expires)); | 2637 | time_after_eq(jiffies, sci->sc_timer.expires)); |
2708 | 2638 | ||
2709 | if (nilfs_sb_dirty(nilfs) && nilfs_sb_need_update(nilfs)) | 2639 | if (nilfs_sb_dirty(nilfs) && nilfs_sb_need_update(nilfs)) |
2710 | set_nilfs_discontinued(nilfs); | 2640 | set_nilfs_discontinued(nilfs); |
@@ -2713,8 +2643,6 @@ static int nilfs_segctor_thread(void *arg) | |||
2713 | 2643 | ||
2714 | end_thread: | 2644 | end_thread: |
2715 | spin_unlock(&sci->sc_state_lock); | 2645 | spin_unlock(&sci->sc_state_lock); |
2716 | del_timer_sync(sci->sc_timer); | ||
2717 | sci->sc_timer = NULL; | ||
2718 | 2646 | ||
2719 | /* end sync. */ | 2647 | /* end sync. */ |
2720 | sci->sc_task = NULL; | 2648 | sci->sc_task = NULL; |
@@ -2750,13 +2678,6 @@ static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci) | |||
2750 | } | 2678 | } |
2751 | } | 2679 | } |
2752 | 2680 | ||
2753 | static int nilfs_segctor_init(struct nilfs_sc_info *sci) | ||
2754 | { | ||
2755 | sci->sc_seq_done = sci->sc_seq_request; | ||
2756 | |||
2757 | return nilfs_segctor_start_thread(sci); | ||
2758 | } | ||
2759 | |||
2760 | /* | 2681 | /* |
2761 | * Setup & clean-up functions | 2682 | * Setup & clean-up functions |
2762 | */ | 2683 | */ |
@@ -2780,6 +2701,7 @@ static struct nilfs_sc_info *nilfs_segctor_new(struct nilfs_sb_info *sbi) | |||
2780 | INIT_LIST_HEAD(&sci->sc_write_logs); | 2701 | INIT_LIST_HEAD(&sci->sc_write_logs); |
2781 | INIT_LIST_HEAD(&sci->sc_gc_inodes); | 2702 | INIT_LIST_HEAD(&sci->sc_gc_inodes); |
2782 | INIT_LIST_HEAD(&sci->sc_copied_buffers); | 2703 | INIT_LIST_HEAD(&sci->sc_copied_buffers); |
2704 | init_timer(&sci->sc_timer); | ||
2783 | 2705 | ||
2784 | sci->sc_interval = HZ * NILFS_SC_DEFAULT_TIMEOUT; | 2706 | sci->sc_interval = HZ * NILFS_SC_DEFAULT_TIMEOUT; |
2785 | sci->sc_mjcp_freq = HZ * NILFS_SC_DEFAULT_SR_FREQ; | 2707 | sci->sc_mjcp_freq = HZ * NILFS_SC_DEFAULT_SR_FREQ; |
@@ -2846,6 +2768,7 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2846 | 2768 | ||
2847 | down_write(&sbi->s_nilfs->ns_segctor_sem); | 2769 | down_write(&sbi->s_nilfs->ns_segctor_sem); |
2848 | 2770 | ||
2771 | del_timer_sync(&sci->sc_timer); | ||
2849 | kfree(sci); | 2772 | kfree(sci); |
2850 | } | 2773 | } |
2851 | 2774 | ||
@@ -2880,7 +2803,7 @@ int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi) | |||
2880 | return -ENOMEM; | 2803 | return -ENOMEM; |
2881 | 2804 | ||
2882 | nilfs_attach_writer(nilfs, sbi); | 2805 | nilfs_attach_writer(nilfs, sbi); |
2883 | err = nilfs_segctor_init(NILFS_SC(sbi)); | 2806 | err = nilfs_segctor_start_thread(NILFS_SC(sbi)); |
2884 | if (err) { | 2807 | if (err) { |
2885 | nilfs_detach_writer(nilfs, sbi); | 2808 | nilfs_detach_writer(nilfs, sbi); |
2886 | kfree(sbi->s_sc_info); | 2809 | kfree(sbi->s_sc_info); |