diff options
Diffstat (limited to 'fs/nilfs2/segment.c')
-rw-r--r-- | fs/nilfs2/segment.c | 258 |
1 files changed, 124 insertions, 134 deletions
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 2de9f636792a..afe4f2183454 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) && \ |
@@ -182,7 +181,6 @@ int nilfs_transaction_begin(struct super_block *sb, | |||
182 | struct nilfs_transaction_info *ti, | 181 | struct nilfs_transaction_info *ti, |
183 | int vacancy_check) | 182 | int vacancy_check) |
184 | { | 183 | { |
185 | struct nilfs_sb_info *sbi; | ||
186 | struct the_nilfs *nilfs; | 184 | struct the_nilfs *nilfs; |
187 | int ret = nilfs_prepare_segment_lock(ti); | 185 | int ret = nilfs_prepare_segment_lock(ti); |
188 | 186 | ||
@@ -193,8 +191,7 @@ int nilfs_transaction_begin(struct super_block *sb, | |||
193 | 191 | ||
194 | vfs_check_frozen(sb, SB_FREEZE_WRITE); | 192 | vfs_check_frozen(sb, SB_FREEZE_WRITE); |
195 | 193 | ||
196 | sbi = NILFS_SB(sb); | 194 | nilfs = sb->s_fs_info; |
197 | nilfs = sbi->s_nilfs; | ||
198 | down_read(&nilfs->ns_segctor_sem); | 195 | down_read(&nilfs->ns_segctor_sem); |
199 | if (vacancy_check && nilfs_near_disk_full(nilfs)) { | 196 | if (vacancy_check && nilfs_near_disk_full(nilfs)) { |
200 | up_read(&nilfs->ns_segctor_sem); | 197 | up_read(&nilfs->ns_segctor_sem); |
@@ -225,8 +222,7 @@ int nilfs_transaction_begin(struct super_block *sb, | |||
225 | int nilfs_transaction_commit(struct super_block *sb) | 222 | int nilfs_transaction_commit(struct super_block *sb) |
226 | { | 223 | { |
227 | struct nilfs_transaction_info *ti = current->journal_info; | 224 | struct nilfs_transaction_info *ti = current->journal_info; |
228 | struct nilfs_sb_info *sbi; | 225 | struct the_nilfs *nilfs = sb->s_fs_info; |
229 | struct nilfs_sc_info *sci; | ||
230 | int err = 0; | 226 | int err = 0; |
231 | 227 | ||
232 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); | 228 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); |
@@ -235,16 +231,15 @@ int nilfs_transaction_commit(struct super_block *sb) | |||
235 | ti->ti_count--; | 231 | ti->ti_count--; |
236 | return 0; | 232 | return 0; |
237 | } | 233 | } |
238 | sbi = NILFS_SB(sb); | 234 | if (nilfs->ns_writer) { |
239 | sci = NILFS_SC(sbi); | 235 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
240 | if (sci != NULL) { | 236 | |
241 | if (ti->ti_flags & NILFS_TI_COMMIT) | 237 | if (ti->ti_flags & NILFS_TI_COMMIT) |
242 | nilfs_segctor_start_timer(sci); | 238 | nilfs_segctor_start_timer(sci); |
243 | if (atomic_read(&sbi->s_nilfs->ns_ndirtyblks) > | 239 | if (atomic_read(&nilfs->ns_ndirtyblks) > sci->sc_watermark) |
244 | sci->sc_watermark) | ||
245 | nilfs_segctor_do_flush(sci, 0); | 240 | nilfs_segctor_do_flush(sci, 0); |
246 | } | 241 | } |
247 | up_read(&sbi->s_nilfs->ns_segctor_sem); | 242 | up_read(&nilfs->ns_segctor_sem); |
248 | current->journal_info = ti->ti_save; | 243 | current->journal_info = ti->ti_save; |
249 | 244 | ||
250 | if (ti->ti_flags & NILFS_TI_SYNC) | 245 | if (ti->ti_flags & NILFS_TI_SYNC) |
@@ -257,13 +252,14 @@ int nilfs_transaction_commit(struct super_block *sb) | |||
257 | void nilfs_transaction_abort(struct super_block *sb) | 252 | void nilfs_transaction_abort(struct super_block *sb) |
258 | { | 253 | { |
259 | struct nilfs_transaction_info *ti = current->journal_info; | 254 | struct nilfs_transaction_info *ti = current->journal_info; |
255 | struct the_nilfs *nilfs = sb->s_fs_info; | ||
260 | 256 | ||
261 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); | 257 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); |
262 | if (ti->ti_count > 0) { | 258 | if (ti->ti_count > 0) { |
263 | ti->ti_count--; | 259 | ti->ti_count--; |
264 | return; | 260 | return; |
265 | } | 261 | } |
266 | up_read(&NILFS_SB(sb)->s_nilfs->ns_segctor_sem); | 262 | up_read(&nilfs->ns_segctor_sem); |
267 | 263 | ||
268 | current->journal_info = ti->ti_save; | 264 | current->journal_info = ti->ti_save; |
269 | if (ti->ti_flags & NILFS_TI_DYNAMIC_ALLOC) | 265 | if (ti->ti_flags & NILFS_TI_DYNAMIC_ALLOC) |
@@ -272,9 +268,8 @@ void nilfs_transaction_abort(struct super_block *sb) | |||
272 | 268 | ||
273 | void nilfs_relax_pressure_in_lock(struct super_block *sb) | 269 | void nilfs_relax_pressure_in_lock(struct super_block *sb) |
274 | { | 270 | { |
275 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 271 | struct the_nilfs *nilfs = sb->s_fs_info; |
276 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 272 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
277 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
278 | 273 | ||
279 | if (!sci || !sci->sc_flush_request) | 274 | if (!sci || !sci->sc_flush_request) |
280 | return; | 275 | return; |
@@ -294,11 +289,13 @@ void nilfs_relax_pressure_in_lock(struct super_block *sb) | |||
294 | downgrade_write(&nilfs->ns_segctor_sem); | 289 | downgrade_write(&nilfs->ns_segctor_sem); |
295 | } | 290 | } |
296 | 291 | ||
297 | static void nilfs_transaction_lock(struct nilfs_sb_info *sbi, | 292 | static void nilfs_transaction_lock(struct super_block *sb, |
298 | struct nilfs_transaction_info *ti, | 293 | struct nilfs_transaction_info *ti, |
299 | int gcflag) | 294 | int gcflag) |
300 | { | 295 | { |
301 | struct nilfs_transaction_info *cur_ti = current->journal_info; | 296 | struct nilfs_transaction_info *cur_ti = current->journal_info; |
297 | struct the_nilfs *nilfs = sb->s_fs_info; | ||
298 | struct nilfs_sc_info *sci = nilfs->ns_writer; | ||
302 | 299 | ||
303 | WARN_ON(cur_ti); | 300 | WARN_ON(cur_ti); |
304 | ti->ti_flags = NILFS_TI_WRITER; | 301 | ti->ti_flags = NILFS_TI_WRITER; |
@@ -309,30 +306,31 @@ static void nilfs_transaction_lock(struct nilfs_sb_info *sbi, | |||
309 | current->journal_info = ti; | 306 | current->journal_info = ti; |
310 | 307 | ||
311 | for (;;) { | 308 | for (;;) { |
312 | down_write(&sbi->s_nilfs->ns_segctor_sem); | 309 | down_write(&nilfs->ns_segctor_sem); |
313 | if (!test_bit(NILFS_SC_PRIOR_FLUSH, &NILFS_SC(sbi)->sc_flags)) | 310 | if (!test_bit(NILFS_SC_PRIOR_FLUSH, &sci->sc_flags)) |
314 | break; | 311 | break; |
315 | 312 | ||
316 | nilfs_segctor_do_immediate_flush(NILFS_SC(sbi)); | 313 | nilfs_segctor_do_immediate_flush(sci); |
317 | 314 | ||
318 | up_write(&sbi->s_nilfs->ns_segctor_sem); | 315 | up_write(&nilfs->ns_segctor_sem); |
319 | yield(); | 316 | yield(); |
320 | } | 317 | } |
321 | if (gcflag) | 318 | if (gcflag) |
322 | ti->ti_flags |= NILFS_TI_GC; | 319 | ti->ti_flags |= NILFS_TI_GC; |
323 | } | 320 | } |
324 | 321 | ||
325 | static void nilfs_transaction_unlock(struct nilfs_sb_info *sbi) | 322 | static void nilfs_transaction_unlock(struct super_block *sb) |
326 | { | 323 | { |
327 | struct nilfs_transaction_info *ti = current->journal_info; | 324 | struct nilfs_transaction_info *ti = current->journal_info; |
325 | struct the_nilfs *nilfs = sb->s_fs_info; | ||
328 | 326 | ||
329 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); | 327 | BUG_ON(ti == NULL || ti->ti_magic != NILFS_TI_MAGIC); |
330 | BUG_ON(ti->ti_count > 0); | 328 | BUG_ON(ti->ti_count > 0); |
331 | 329 | ||
332 | up_write(&sbi->s_nilfs->ns_segctor_sem); | 330 | up_write(&nilfs->ns_segctor_sem); |
333 | current->journal_info = ti->ti_save; | 331 | current->journal_info = ti->ti_save; |
334 | if (!list_empty(&ti->ti_garbage)) | 332 | if (!list_empty(&ti->ti_garbage)) |
335 | nilfs_dispose_list(sbi, &ti->ti_garbage, 0); | 333 | nilfs_dispose_list(nilfs, &ti->ti_garbage, 0); |
336 | } | 334 | } |
337 | 335 | ||
338 | static void *nilfs_segctor_map_segsum_entry(struct nilfs_sc_info *sci, | 336 | static void *nilfs_segctor_map_segsum_entry(struct nilfs_sc_info *sci, |
@@ -714,7 +712,7 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode, | |||
714 | } | 712 | } |
715 | } | 713 | } |
716 | 714 | ||
717 | static void nilfs_dispose_list(struct nilfs_sb_info *sbi, | 715 | static void nilfs_dispose_list(struct the_nilfs *nilfs, |
718 | struct list_head *head, int force) | 716 | struct list_head *head, int force) |
719 | { | 717 | { |
720 | struct nilfs_inode_info *ii, *n; | 718 | struct nilfs_inode_info *ii, *n; |
@@ -722,7 +720,7 @@ static void nilfs_dispose_list(struct nilfs_sb_info *sbi, | |||
722 | unsigned nv = 0; | 720 | unsigned nv = 0; |
723 | 721 | ||
724 | while (!list_empty(head)) { | 722 | while (!list_empty(head)) { |
725 | spin_lock(&sbi->s_inode_lock); | 723 | spin_lock(&nilfs->ns_inode_lock); |
726 | list_for_each_entry_safe(ii, n, head, i_dirty) { | 724 | list_for_each_entry_safe(ii, n, head, i_dirty) { |
727 | list_del_init(&ii->i_dirty); | 725 | list_del_init(&ii->i_dirty); |
728 | if (force) { | 726 | if (force) { |
@@ -733,14 +731,14 @@ static void nilfs_dispose_list(struct nilfs_sb_info *sbi, | |||
733 | } else if (test_bit(NILFS_I_DIRTY, &ii->i_state)) { | 731 | } else if (test_bit(NILFS_I_DIRTY, &ii->i_state)) { |
734 | set_bit(NILFS_I_QUEUED, &ii->i_state); | 732 | set_bit(NILFS_I_QUEUED, &ii->i_state); |
735 | list_add_tail(&ii->i_dirty, | 733 | list_add_tail(&ii->i_dirty, |
736 | &sbi->s_dirty_files); | 734 | &nilfs->ns_dirty_files); |
737 | continue; | 735 | continue; |
738 | } | 736 | } |
739 | ivec[nv++] = ii; | 737 | ivec[nv++] = ii; |
740 | if (nv == SC_N_INODEVEC) | 738 | if (nv == SC_N_INODEVEC) |
741 | break; | 739 | break; |
742 | } | 740 | } |
743 | spin_unlock(&sbi->s_inode_lock); | 741 | spin_unlock(&nilfs->ns_inode_lock); |
744 | 742 | ||
745 | for (pii = ivec; nv > 0; pii++, nv--) | 743 | for (pii = ivec; nv > 0; pii++, nv--) |
746 | iput(&(*pii)->vfs_inode); | 744 | iput(&(*pii)->vfs_inode); |
@@ -773,24 +771,23 @@ static int nilfs_segctor_clean(struct nilfs_sc_info *sci) | |||
773 | 771 | ||
774 | static int nilfs_segctor_confirm(struct nilfs_sc_info *sci) | 772 | static int nilfs_segctor_confirm(struct nilfs_sc_info *sci) |
775 | { | 773 | { |
776 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 774 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
777 | int ret = 0; | 775 | int ret = 0; |
778 | 776 | ||
779 | if (nilfs_test_metadata_dirty(sbi->s_nilfs, sci->sc_root)) | 777 | if (nilfs_test_metadata_dirty(nilfs, sci->sc_root)) |
780 | set_bit(NILFS_SC_DIRTY, &sci->sc_flags); | 778 | set_bit(NILFS_SC_DIRTY, &sci->sc_flags); |
781 | 779 | ||
782 | spin_lock(&sbi->s_inode_lock); | 780 | spin_lock(&nilfs->ns_inode_lock); |
783 | if (list_empty(&sbi->s_dirty_files) && nilfs_segctor_clean(sci)) | 781 | if (list_empty(&nilfs->ns_dirty_files) && nilfs_segctor_clean(sci)) |
784 | ret++; | 782 | ret++; |
785 | 783 | ||
786 | spin_unlock(&sbi->s_inode_lock); | 784 | spin_unlock(&nilfs->ns_inode_lock); |
787 | return ret; | 785 | return ret; |
788 | } | 786 | } |
789 | 787 | ||
790 | static void nilfs_segctor_clear_metadata_dirty(struct nilfs_sc_info *sci) | 788 | static void nilfs_segctor_clear_metadata_dirty(struct nilfs_sc_info *sci) |
791 | { | 789 | { |
792 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 790 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
793 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
794 | 791 | ||
795 | nilfs_mdt_clear_dirty(sci->sc_root->ifile); | 792 | nilfs_mdt_clear_dirty(sci->sc_root->ifile); |
796 | nilfs_mdt_clear_dirty(nilfs->ns_cpfile); | 793 | nilfs_mdt_clear_dirty(nilfs->ns_cpfile); |
@@ -800,7 +797,7 @@ static void nilfs_segctor_clear_metadata_dirty(struct nilfs_sc_info *sci) | |||
800 | 797 | ||
801 | static int nilfs_segctor_create_checkpoint(struct nilfs_sc_info *sci) | 798 | static int nilfs_segctor_create_checkpoint(struct nilfs_sc_info *sci) |
802 | { | 799 | { |
803 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; | 800 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
804 | struct buffer_head *bh_cp; | 801 | struct buffer_head *bh_cp; |
805 | struct nilfs_checkpoint *raw_cp; | 802 | struct nilfs_checkpoint *raw_cp; |
806 | int err; | 803 | int err; |
@@ -824,8 +821,7 @@ static int nilfs_segctor_create_checkpoint(struct nilfs_sc_info *sci) | |||
824 | 821 | ||
825 | static int nilfs_segctor_fill_in_checkpoint(struct nilfs_sc_info *sci) | 822 | static int nilfs_segctor_fill_in_checkpoint(struct nilfs_sc_info *sci) |
826 | { | 823 | { |
827 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 824 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
828 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
829 | struct buffer_head *bh_cp; | 825 | struct buffer_head *bh_cp; |
830 | struct nilfs_checkpoint *raw_cp; | 826 | struct nilfs_checkpoint *raw_cp; |
831 | int err; | 827 | int err; |
@@ -1049,8 +1045,7 @@ static int nilfs_segctor_scan_file_dsync(struct nilfs_sc_info *sci, | |||
1049 | 1045 | ||
1050 | static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode) | 1046 | static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode) |
1051 | { | 1047 | { |
1052 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 1048 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
1053 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
1054 | struct list_head *head; | 1049 | struct list_head *head; |
1055 | struct nilfs_inode_info *ii; | 1050 | struct nilfs_inode_info *ii; |
1056 | size_t ndone; | 1051 | size_t ndone; |
@@ -1859,7 +1854,7 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci) | |||
1859 | { | 1854 | { |
1860 | struct nilfs_segment_buffer *segbuf; | 1855 | struct nilfs_segment_buffer *segbuf; |
1861 | struct page *bd_page = NULL, *fs_page = NULL; | 1856 | struct page *bd_page = NULL, *fs_page = NULL; |
1862 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; | 1857 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
1863 | int update_sr = false; | 1858 | int update_sr = false; |
1864 | 1859 | ||
1865 | list_for_each_entry(segbuf, &sci->sc_write_logs, sb_list) { | 1860 | list_for_each_entry(segbuf, &sci->sc_write_logs, sb_list) { |
@@ -1963,30 +1958,30 @@ static int nilfs_segctor_wait(struct nilfs_sc_info *sci) | |||
1963 | return ret; | 1958 | return ret; |
1964 | } | 1959 | } |
1965 | 1960 | ||
1966 | static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, | 1961 | static int nilfs_segctor_collect_dirty_files(struct nilfs_sc_info *sci, |
1967 | struct nilfs_sb_info *sbi) | 1962 | struct the_nilfs *nilfs) |
1968 | { | 1963 | { |
1969 | struct nilfs_inode_info *ii, *n; | 1964 | struct nilfs_inode_info *ii, *n; |
1970 | struct inode *ifile = sci->sc_root->ifile; | 1965 | struct inode *ifile = sci->sc_root->ifile; |
1971 | 1966 | ||
1972 | spin_lock(&sbi->s_inode_lock); | 1967 | spin_lock(&nilfs->ns_inode_lock); |
1973 | retry: | 1968 | retry: |
1974 | list_for_each_entry_safe(ii, n, &sbi->s_dirty_files, i_dirty) { | 1969 | list_for_each_entry_safe(ii, n, &nilfs->ns_dirty_files, i_dirty) { |
1975 | if (!ii->i_bh) { | 1970 | if (!ii->i_bh) { |
1976 | struct buffer_head *ibh; | 1971 | struct buffer_head *ibh; |
1977 | int err; | 1972 | int err; |
1978 | 1973 | ||
1979 | spin_unlock(&sbi->s_inode_lock); | 1974 | spin_unlock(&nilfs->ns_inode_lock); |
1980 | err = nilfs_ifile_get_inode_block( | 1975 | err = nilfs_ifile_get_inode_block( |
1981 | ifile, ii->vfs_inode.i_ino, &ibh); | 1976 | ifile, ii->vfs_inode.i_ino, &ibh); |
1982 | if (unlikely(err)) { | 1977 | if (unlikely(err)) { |
1983 | nilfs_warning(sbi->s_super, __func__, | 1978 | nilfs_warning(sci->sc_super, __func__, |
1984 | "failed to get inode block.\n"); | 1979 | "failed to get inode block.\n"); |
1985 | return err; | 1980 | return err; |
1986 | } | 1981 | } |
1987 | nilfs_mdt_mark_buffer_dirty(ibh); | 1982 | nilfs_mdt_mark_buffer_dirty(ibh); |
1988 | nilfs_mdt_mark_dirty(ifile); | 1983 | nilfs_mdt_mark_dirty(ifile); |
1989 | spin_lock(&sbi->s_inode_lock); | 1984 | spin_lock(&nilfs->ns_inode_lock); |
1990 | if (likely(!ii->i_bh)) | 1985 | if (likely(!ii->i_bh)) |
1991 | ii->i_bh = ibh; | 1986 | ii->i_bh = ibh; |
1992 | else | 1987 | else |
@@ -1999,18 +1994,18 @@ static int nilfs_segctor_check_in_files(struct nilfs_sc_info *sci, | |||
1999 | list_del(&ii->i_dirty); | 1994 | list_del(&ii->i_dirty); |
2000 | list_add_tail(&ii->i_dirty, &sci->sc_dirty_files); | 1995 | list_add_tail(&ii->i_dirty, &sci->sc_dirty_files); |
2001 | } | 1996 | } |
2002 | spin_unlock(&sbi->s_inode_lock); | 1997 | spin_unlock(&nilfs->ns_inode_lock); |
2003 | 1998 | ||
2004 | return 0; | 1999 | return 0; |
2005 | } | 2000 | } |
2006 | 2001 | ||
2007 | static void nilfs_segctor_check_out_files(struct nilfs_sc_info *sci, | 2002 | static void nilfs_segctor_drop_written_files(struct nilfs_sc_info *sci, |
2008 | struct nilfs_sb_info *sbi) | 2003 | struct the_nilfs *nilfs) |
2009 | { | 2004 | { |
2010 | struct nilfs_transaction_info *ti = current->journal_info; | 2005 | struct nilfs_transaction_info *ti = current->journal_info; |
2011 | struct nilfs_inode_info *ii, *n; | 2006 | struct nilfs_inode_info *ii, *n; |
2012 | 2007 | ||
2013 | spin_lock(&sbi->s_inode_lock); | 2008 | spin_lock(&nilfs->ns_inode_lock); |
2014 | list_for_each_entry_safe(ii, n, &sci->sc_dirty_files, i_dirty) { | 2009 | 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) || | 2010 | if (!test_and_clear_bit(NILFS_I_UPDATED, &ii->i_state) || |
2016 | test_bit(NILFS_I_DIRTY, &ii->i_state)) | 2011 | test_bit(NILFS_I_DIRTY, &ii->i_state)) |
@@ -2022,7 +2017,7 @@ static void nilfs_segctor_check_out_files(struct nilfs_sc_info *sci, | |||
2022 | list_del(&ii->i_dirty); | 2017 | list_del(&ii->i_dirty); |
2023 | list_add_tail(&ii->i_dirty, &ti->ti_garbage); | 2018 | list_add_tail(&ii->i_dirty, &ti->ti_garbage); |
2024 | } | 2019 | } |
2025 | spin_unlock(&sbi->s_inode_lock); | 2020 | spin_unlock(&nilfs->ns_inode_lock); |
2026 | } | 2021 | } |
2027 | 2022 | ||
2028 | /* | 2023 | /* |
@@ -2030,15 +2025,14 @@ static void nilfs_segctor_check_out_files(struct nilfs_sc_info *sci, | |||
2030 | */ | 2025 | */ |
2031 | static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | 2026 | static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) |
2032 | { | 2027 | { |
2033 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 2028 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
2034 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
2035 | struct page *failed_page; | 2029 | struct page *failed_page; |
2036 | int err; | 2030 | int err; |
2037 | 2031 | ||
2038 | sci->sc_stage.scnt = NILFS_ST_INIT; | 2032 | sci->sc_stage.scnt = NILFS_ST_INIT; |
2039 | sci->sc_cno = nilfs->ns_cno; | 2033 | sci->sc_cno = nilfs->ns_cno; |
2040 | 2034 | ||
2041 | err = nilfs_segctor_check_in_files(sci, sbi); | 2035 | err = nilfs_segctor_collect_dirty_files(sci, nilfs); |
2042 | if (unlikely(err)) | 2036 | if (unlikely(err)) |
2043 | goto out; | 2037 | goto out; |
2044 | 2038 | ||
@@ -2116,7 +2110,7 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) | |||
2116 | } while (sci->sc_stage.scnt != NILFS_ST_DONE); | 2110 | } while (sci->sc_stage.scnt != NILFS_ST_DONE); |
2117 | 2111 | ||
2118 | out: | 2112 | out: |
2119 | nilfs_segctor_check_out_files(sci, sbi); | 2113 | nilfs_segctor_drop_written_files(sci, nilfs); |
2120 | return err; | 2114 | return err; |
2121 | 2115 | ||
2122 | failed_to_write: | 2116 | failed_to_write: |
@@ -2169,8 +2163,8 @@ static void nilfs_segctor_do_flush(struct nilfs_sc_info *sci, int bn) | |||
2169 | */ | 2163 | */ |
2170 | void nilfs_flush_segment(struct super_block *sb, ino_t ino) | 2164 | void nilfs_flush_segment(struct super_block *sb, ino_t ino) |
2171 | { | 2165 | { |
2172 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2166 | struct the_nilfs *nilfs = sb->s_fs_info; |
2173 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 2167 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
2174 | 2168 | ||
2175 | if (!sci || nilfs_doing_construction()) | 2169 | if (!sci || nilfs_doing_construction()) |
2176 | return; | 2170 | return; |
@@ -2259,8 +2253,8 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info *sci, int err) | |||
2259 | */ | 2253 | */ |
2260 | int nilfs_construct_segment(struct super_block *sb) | 2254 | int nilfs_construct_segment(struct super_block *sb) |
2261 | { | 2255 | { |
2262 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2256 | struct the_nilfs *nilfs = sb->s_fs_info; |
2263 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 2257 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
2264 | struct nilfs_transaction_info *ti; | 2258 | struct nilfs_transaction_info *ti; |
2265 | int err; | 2259 | int err; |
2266 | 2260 | ||
@@ -2297,8 +2291,8 @@ int nilfs_construct_segment(struct super_block *sb) | |||
2297 | int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, | 2291 | int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, |
2298 | loff_t start, loff_t end) | 2292 | loff_t start, loff_t end) |
2299 | { | 2293 | { |
2300 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2294 | struct the_nilfs *nilfs = sb->s_fs_info; |
2301 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 2295 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
2302 | struct nilfs_inode_info *ii; | 2296 | struct nilfs_inode_info *ii; |
2303 | struct nilfs_transaction_info ti; | 2297 | struct nilfs_transaction_info ti; |
2304 | int err = 0; | 2298 | int err = 0; |
@@ -2306,33 +2300,33 @@ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode, | |||
2306 | if (!sci) | 2300 | if (!sci) |
2307 | return -EROFS; | 2301 | return -EROFS; |
2308 | 2302 | ||
2309 | nilfs_transaction_lock(sbi, &ti, 0); | 2303 | nilfs_transaction_lock(sb, &ti, 0); |
2310 | 2304 | ||
2311 | ii = NILFS_I(inode); | 2305 | ii = NILFS_I(inode); |
2312 | if (test_bit(NILFS_I_INODE_DIRTY, &ii->i_state) || | 2306 | if (test_bit(NILFS_I_INODE_DIRTY, &ii->i_state) || |
2313 | nilfs_test_opt(sbi, STRICT_ORDER) || | 2307 | nilfs_test_opt(nilfs, STRICT_ORDER) || |
2314 | test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) || | 2308 | test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) || |
2315 | nilfs_discontinued(sbi->s_nilfs)) { | 2309 | nilfs_discontinued(nilfs)) { |
2316 | nilfs_transaction_unlock(sbi); | 2310 | nilfs_transaction_unlock(sb); |
2317 | err = nilfs_segctor_sync(sci); | 2311 | err = nilfs_segctor_sync(sci); |
2318 | return err; | 2312 | return err; |
2319 | } | 2313 | } |
2320 | 2314 | ||
2321 | spin_lock(&sbi->s_inode_lock); | 2315 | spin_lock(&nilfs->ns_inode_lock); |
2322 | if (!test_bit(NILFS_I_QUEUED, &ii->i_state) && | 2316 | if (!test_bit(NILFS_I_QUEUED, &ii->i_state) && |
2323 | !test_bit(NILFS_I_BUSY, &ii->i_state)) { | 2317 | !test_bit(NILFS_I_BUSY, &ii->i_state)) { |
2324 | spin_unlock(&sbi->s_inode_lock); | 2318 | spin_unlock(&nilfs->ns_inode_lock); |
2325 | nilfs_transaction_unlock(sbi); | 2319 | nilfs_transaction_unlock(sb); |
2326 | return 0; | 2320 | return 0; |
2327 | } | 2321 | } |
2328 | spin_unlock(&sbi->s_inode_lock); | 2322 | spin_unlock(&nilfs->ns_inode_lock); |
2329 | sci->sc_dsync_inode = ii; | 2323 | sci->sc_dsync_inode = ii; |
2330 | sci->sc_dsync_start = start; | 2324 | sci->sc_dsync_start = start; |
2331 | sci->sc_dsync_end = end; | 2325 | sci->sc_dsync_end = end; |
2332 | 2326 | ||
2333 | err = nilfs_segctor_do_construct(sci, SC_LSEG_DSYNC); | 2327 | err = nilfs_segctor_do_construct(sci, SC_LSEG_DSYNC); |
2334 | 2328 | ||
2335 | nilfs_transaction_unlock(sbi); | 2329 | nilfs_transaction_unlock(sb); |
2336 | return err; | 2330 | return err; |
2337 | } | 2331 | } |
2338 | 2332 | ||
@@ -2388,8 +2382,7 @@ static void nilfs_segctor_notify(struct nilfs_sc_info *sci, int mode, int err) | |||
2388 | */ | 2382 | */ |
2389 | static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode) | 2383 | static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode) |
2390 | { | 2384 | { |
2391 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 2385 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
2392 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
2393 | struct nilfs_super_block **sbp; | 2386 | struct nilfs_super_block **sbp; |
2394 | int err = 0; | 2387 | int err = 0; |
2395 | 2388 | ||
@@ -2407,11 +2400,12 @@ static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode) | |||
2407 | nilfs_discontinued(nilfs)) { | 2400 | nilfs_discontinued(nilfs)) { |
2408 | down_write(&nilfs->ns_sem); | 2401 | down_write(&nilfs->ns_sem); |
2409 | err = -EIO; | 2402 | err = -EIO; |
2410 | sbp = nilfs_prepare_super(sbi, | 2403 | sbp = nilfs_prepare_super(sci->sc_super, |
2411 | nilfs_sb_will_flip(nilfs)); | 2404 | nilfs_sb_will_flip(nilfs)); |
2412 | if (likely(sbp)) { | 2405 | if (likely(sbp)) { |
2413 | nilfs_set_log_cursor(sbp[0], nilfs); | 2406 | nilfs_set_log_cursor(sbp[0], nilfs); |
2414 | err = nilfs_commit_super(sbi, NILFS_SB_COMMIT); | 2407 | err = nilfs_commit_super(sci->sc_super, |
2408 | NILFS_SB_COMMIT); | ||
2415 | } | 2409 | } |
2416 | up_write(&nilfs->ns_sem); | 2410 | up_write(&nilfs->ns_sem); |
2417 | } | 2411 | } |
@@ -2443,16 +2437,15 @@ nilfs_remove_written_gcinodes(struct the_nilfs *nilfs, struct list_head *head) | |||
2443 | int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, | 2437 | int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, |
2444 | void **kbufs) | 2438 | void **kbufs) |
2445 | { | 2439 | { |
2446 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 2440 | struct the_nilfs *nilfs = sb->s_fs_info; |
2447 | struct nilfs_sc_info *sci = NILFS_SC(sbi); | 2441 | struct nilfs_sc_info *sci = nilfs->ns_writer; |
2448 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
2449 | struct nilfs_transaction_info ti; | 2442 | struct nilfs_transaction_info ti; |
2450 | int err; | 2443 | int err; |
2451 | 2444 | ||
2452 | if (unlikely(!sci)) | 2445 | if (unlikely(!sci)) |
2453 | return -EROFS; | 2446 | return -EROFS; |
2454 | 2447 | ||
2455 | nilfs_transaction_lock(sbi, &ti, 1); | 2448 | nilfs_transaction_lock(sb, &ti, 1); |
2456 | 2449 | ||
2457 | err = nilfs_mdt_save_to_shadow_map(nilfs->ns_dat); | 2450 | err = nilfs_mdt_save_to_shadow_map(nilfs->ns_dat); |
2458 | if (unlikely(err)) | 2451 | if (unlikely(err)) |
@@ -2480,14 +2473,14 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, | |||
2480 | set_current_state(TASK_INTERRUPTIBLE); | 2473 | set_current_state(TASK_INTERRUPTIBLE); |
2481 | schedule_timeout(sci->sc_interval); | 2474 | schedule_timeout(sci->sc_interval); |
2482 | } | 2475 | } |
2483 | if (nilfs_test_opt(sbi, DISCARD)) { | 2476 | if (nilfs_test_opt(nilfs, DISCARD)) { |
2484 | int ret = nilfs_discard_segments(nilfs, sci->sc_freesegs, | 2477 | int ret = nilfs_discard_segments(nilfs, sci->sc_freesegs, |
2485 | sci->sc_nfreesegs); | 2478 | sci->sc_nfreesegs); |
2486 | if (ret) { | 2479 | if (ret) { |
2487 | printk(KERN_WARNING | 2480 | printk(KERN_WARNING |
2488 | "NILFS warning: error %d on discard request, " | 2481 | "NILFS warning: error %d on discard request, " |
2489 | "turning discards off for the device\n", ret); | 2482 | "turning discards off for the device\n", ret); |
2490 | nilfs_clear_opt(sbi, DISCARD); | 2483 | nilfs_clear_opt(nilfs, DISCARD); |
2491 | } | 2484 | } |
2492 | } | 2485 | } |
2493 | 2486 | ||
@@ -2495,16 +2488,15 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv, | |||
2495 | sci->sc_freesegs = NULL; | 2488 | sci->sc_freesegs = NULL; |
2496 | sci->sc_nfreesegs = 0; | 2489 | sci->sc_nfreesegs = 0; |
2497 | nilfs_mdt_clear_shadow_map(nilfs->ns_dat); | 2490 | nilfs_mdt_clear_shadow_map(nilfs->ns_dat); |
2498 | nilfs_transaction_unlock(sbi); | 2491 | nilfs_transaction_unlock(sb); |
2499 | return err; | 2492 | return err; |
2500 | } | 2493 | } |
2501 | 2494 | ||
2502 | static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode) | 2495 | static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode) |
2503 | { | 2496 | { |
2504 | struct nilfs_sb_info *sbi = sci->sc_sbi; | ||
2505 | struct nilfs_transaction_info ti; | 2497 | struct nilfs_transaction_info ti; |
2506 | 2498 | ||
2507 | nilfs_transaction_lock(sbi, &ti, 0); | 2499 | nilfs_transaction_lock(sci->sc_super, &ti, 0); |
2508 | nilfs_segctor_construct(sci, mode); | 2500 | nilfs_segctor_construct(sci, mode); |
2509 | 2501 | ||
2510 | /* | 2502 | /* |
@@ -2515,7 +2507,7 @@ static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode) | |||
2515 | if (test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags)) | 2507 | if (test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags)) |
2516 | nilfs_segctor_start_timer(sci); | 2508 | nilfs_segctor_start_timer(sci); |
2517 | 2509 | ||
2518 | nilfs_transaction_unlock(sbi); | 2510 | nilfs_transaction_unlock(sci->sc_super); |
2519 | } | 2511 | } |
2520 | 2512 | ||
2521 | static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *sci) | 2513 | static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *sci) |
@@ -2561,7 +2553,7 @@ static int nilfs_segctor_flush_mode(struct nilfs_sc_info *sci) | |||
2561 | static int nilfs_segctor_thread(void *arg) | 2553 | static int nilfs_segctor_thread(void *arg) |
2562 | { | 2554 | { |
2563 | struct nilfs_sc_info *sci = (struct nilfs_sc_info *)arg; | 2555 | struct nilfs_sc_info *sci = (struct nilfs_sc_info *)arg; |
2564 | struct the_nilfs *nilfs = sci->sc_sbi->s_nilfs; | 2556 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
2565 | int timeout = 0; | 2557 | int timeout = 0; |
2566 | 2558 | ||
2567 | sci->sc_timer.data = (unsigned long)current; | 2559 | sci->sc_timer.data = (unsigned long)current; |
@@ -2672,17 +2664,17 @@ static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci) | |||
2672 | /* | 2664 | /* |
2673 | * Setup & clean-up functions | 2665 | * Setup & clean-up functions |
2674 | */ | 2666 | */ |
2675 | static struct nilfs_sc_info *nilfs_segctor_new(struct nilfs_sb_info *sbi, | 2667 | static struct nilfs_sc_info *nilfs_segctor_new(struct super_block *sb, |
2676 | struct nilfs_root *root) | 2668 | struct nilfs_root *root) |
2677 | { | 2669 | { |
2670 | struct the_nilfs *nilfs = sb->s_fs_info; | ||
2678 | struct nilfs_sc_info *sci; | 2671 | struct nilfs_sc_info *sci; |
2679 | 2672 | ||
2680 | sci = kzalloc(sizeof(*sci), GFP_KERNEL); | 2673 | sci = kzalloc(sizeof(*sci), GFP_KERNEL); |
2681 | if (!sci) | 2674 | if (!sci) |
2682 | return NULL; | 2675 | return NULL; |
2683 | 2676 | ||
2684 | sci->sc_sbi = sbi; | 2677 | sci->sc_super = sb; |
2685 | sci->sc_super = sbi->s_super; | ||
2686 | 2678 | ||
2687 | nilfs_get_root(root); | 2679 | nilfs_get_root(root); |
2688 | sci->sc_root = root; | 2680 | sci->sc_root = root; |
@@ -2702,10 +2694,10 @@ static struct nilfs_sc_info *nilfs_segctor_new(struct nilfs_sb_info *sbi, | |||
2702 | sci->sc_mjcp_freq = HZ * NILFS_SC_DEFAULT_SR_FREQ; | 2694 | sci->sc_mjcp_freq = HZ * NILFS_SC_DEFAULT_SR_FREQ; |
2703 | sci->sc_watermark = NILFS_SC_DEFAULT_WATERMARK; | 2695 | sci->sc_watermark = NILFS_SC_DEFAULT_WATERMARK; |
2704 | 2696 | ||
2705 | if (sbi->s_interval) | 2697 | if (nilfs->ns_interval) |
2706 | sci->sc_interval = sbi->s_interval; | 2698 | sci->sc_interval = nilfs->ns_interval; |
2707 | if (sbi->s_watermark) | 2699 | if (nilfs->ns_watermark) |
2708 | sci->sc_watermark = sbi->s_watermark; | 2700 | sci->sc_watermark = nilfs->ns_watermark; |
2709 | return sci; | 2701 | return sci; |
2710 | } | 2702 | } |
2711 | 2703 | ||
@@ -2716,12 +2708,11 @@ static void nilfs_segctor_write_out(struct nilfs_sc_info *sci) | |||
2716 | /* The segctord thread was stopped and its timer was removed. | 2708 | /* The segctord thread was stopped and its timer was removed. |
2717 | But some tasks remain. */ | 2709 | But some tasks remain. */ |
2718 | do { | 2710 | do { |
2719 | struct nilfs_sb_info *sbi = sci->sc_sbi; | ||
2720 | struct nilfs_transaction_info ti; | 2711 | struct nilfs_transaction_info ti; |
2721 | 2712 | ||
2722 | nilfs_transaction_lock(sbi, &ti, 0); | 2713 | nilfs_transaction_lock(sci->sc_super, &ti, 0); |
2723 | ret = nilfs_segctor_construct(sci, SC_LSEG_SR); | 2714 | ret = nilfs_segctor_construct(sci, SC_LSEG_SR); |
2724 | nilfs_transaction_unlock(sbi); | 2715 | nilfs_transaction_unlock(sci->sc_super); |
2725 | 2716 | ||
2726 | } while (ret && retrycount-- > 0); | 2717 | } while (ret && retrycount-- > 0); |
2727 | } | 2718 | } |
@@ -2736,10 +2727,10 @@ static void nilfs_segctor_write_out(struct nilfs_sc_info *sci) | |||
2736 | */ | 2727 | */ |
2737 | static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | 2728 | static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) |
2738 | { | 2729 | { |
2739 | struct nilfs_sb_info *sbi = sci->sc_sbi; | 2730 | struct the_nilfs *nilfs = sci->sc_super->s_fs_info; |
2740 | int flag; | 2731 | int flag; |
2741 | 2732 | ||
2742 | up_write(&sbi->s_nilfs->ns_segctor_sem); | 2733 | up_write(&nilfs->ns_segctor_sem); |
2743 | 2734 | ||
2744 | spin_lock(&sci->sc_state_lock); | 2735 | spin_lock(&sci->sc_state_lock); |
2745 | nilfs_segctor_kill_thread(sci); | 2736 | nilfs_segctor_kill_thread(sci); |
@@ -2753,9 +2744,9 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2753 | WARN_ON(!list_empty(&sci->sc_copied_buffers)); | 2744 | WARN_ON(!list_empty(&sci->sc_copied_buffers)); |
2754 | 2745 | ||
2755 | if (!list_empty(&sci->sc_dirty_files)) { | 2746 | if (!list_empty(&sci->sc_dirty_files)) { |
2756 | nilfs_warning(sbi->s_super, __func__, | 2747 | nilfs_warning(sci->sc_super, __func__, |
2757 | "dirty file(s) after the final construction\n"); | 2748 | "dirty file(s) after the final construction\n"); |
2758 | nilfs_dispose_list(sbi, &sci->sc_dirty_files, 1); | 2749 | nilfs_dispose_list(nilfs, &sci->sc_dirty_files, 1); |
2759 | } | 2750 | } |
2760 | 2751 | ||
2761 | WARN_ON(!list_empty(&sci->sc_segbufs)); | 2752 | WARN_ON(!list_empty(&sci->sc_segbufs)); |
@@ -2763,79 +2754,78 @@ static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) | |||
2763 | 2754 | ||
2764 | nilfs_put_root(sci->sc_root); | 2755 | nilfs_put_root(sci->sc_root); |
2765 | 2756 | ||
2766 | down_write(&sbi->s_nilfs->ns_segctor_sem); | 2757 | down_write(&nilfs->ns_segctor_sem); |
2767 | 2758 | ||
2768 | del_timer_sync(&sci->sc_timer); | 2759 | del_timer_sync(&sci->sc_timer); |
2769 | kfree(sci); | 2760 | kfree(sci); |
2770 | } | 2761 | } |
2771 | 2762 | ||
2772 | /** | 2763 | /** |
2773 | * nilfs_attach_segment_constructor - attach a segment constructor | 2764 | * nilfs_attach_log_writer - attach log writer |
2774 | * @sbi: nilfs_sb_info | 2765 | * @sb: super block instance |
2775 | * @root: root object of the current filesystem tree | 2766 | * @root: root object of the current filesystem tree |
2776 | * | 2767 | * |
2777 | * nilfs_attach_segment_constructor() allocates a struct nilfs_sc_info, | 2768 | * This allocates a log writer object, initializes it, and starts the |
2778 | * initializes it, and starts the segment constructor. | 2769 | * log writer. |
2779 | * | 2770 | * |
2780 | * Return Value: On success, 0 is returned. On error, one of the following | 2771 | * Return Value: On success, 0 is returned. On error, one of the following |
2781 | * negative error code is returned. | 2772 | * negative error code is returned. |
2782 | * | 2773 | * |
2783 | * %-ENOMEM - Insufficient memory available. | 2774 | * %-ENOMEM - Insufficient memory available. |
2784 | */ | 2775 | */ |
2785 | int nilfs_attach_segment_constructor(struct nilfs_sb_info *sbi, | 2776 | int nilfs_attach_log_writer(struct super_block *sb, struct nilfs_root *root) |
2786 | struct nilfs_root *root) | ||
2787 | { | 2777 | { |
2778 | struct the_nilfs *nilfs = sb->s_fs_info; | ||
2788 | int err; | 2779 | int err; |
2789 | 2780 | ||
2790 | if (NILFS_SC(sbi)) { | 2781 | if (nilfs->ns_writer) { |
2791 | /* | 2782 | /* |
2792 | * This happens if the filesystem was remounted | 2783 | * This happens if the filesystem was remounted |
2793 | * read/write after nilfs_error degenerated it into a | 2784 | * read/write after nilfs_error degenerated it into a |
2794 | * read-only mount. | 2785 | * read-only mount. |
2795 | */ | 2786 | */ |
2796 | nilfs_detach_segment_constructor(sbi); | 2787 | nilfs_detach_log_writer(sb); |
2797 | } | 2788 | } |
2798 | 2789 | ||
2799 | sbi->s_sc_info = nilfs_segctor_new(sbi, root); | 2790 | nilfs->ns_writer = nilfs_segctor_new(sb, root); |
2800 | if (!sbi->s_sc_info) | 2791 | if (!nilfs->ns_writer) |
2801 | return -ENOMEM; | 2792 | return -ENOMEM; |
2802 | 2793 | ||
2803 | err = nilfs_segctor_start_thread(NILFS_SC(sbi)); | 2794 | err = nilfs_segctor_start_thread(nilfs->ns_writer); |
2804 | if (err) { | 2795 | if (err) { |
2805 | kfree(sbi->s_sc_info); | 2796 | kfree(nilfs->ns_writer); |
2806 | sbi->s_sc_info = NULL; | 2797 | nilfs->ns_writer = NULL; |
2807 | } | 2798 | } |
2808 | return err; | 2799 | return err; |
2809 | } | 2800 | } |
2810 | 2801 | ||
2811 | /** | 2802 | /** |
2812 | * nilfs_detach_segment_constructor - destroy the segment constructor | 2803 | * nilfs_detach_log_writer - destroy log writer |
2813 | * @sbi: nilfs_sb_info | 2804 | * @sb: super block instance |
2814 | * | 2805 | * |
2815 | * nilfs_detach_segment_constructor() kills the segment constructor daemon, | 2806 | * This kills log writer daemon, frees the log writer object, and |
2816 | * frees the struct nilfs_sc_info, and destroy the dirty file list. | 2807 | * destroys list of dirty files. |
2817 | */ | 2808 | */ |
2818 | void nilfs_detach_segment_constructor(struct nilfs_sb_info *sbi) | 2809 | void nilfs_detach_log_writer(struct super_block *sb) |
2819 | { | 2810 | { |
2820 | struct the_nilfs *nilfs = sbi->s_nilfs; | 2811 | struct the_nilfs *nilfs = sb->s_fs_info; |
2821 | LIST_HEAD(garbage_list); | 2812 | LIST_HEAD(garbage_list); |
2822 | 2813 | ||
2823 | down_write(&nilfs->ns_segctor_sem); | 2814 | down_write(&nilfs->ns_segctor_sem); |
2824 | if (NILFS_SC(sbi)) { | 2815 | if (nilfs->ns_writer) { |
2825 | nilfs_segctor_destroy(NILFS_SC(sbi)); | 2816 | nilfs_segctor_destroy(nilfs->ns_writer); |
2826 | sbi->s_sc_info = NULL; | 2817 | nilfs->ns_writer = NULL; |
2827 | } | 2818 | } |
2828 | 2819 | ||
2829 | /* Force to free the list of dirty files */ | 2820 | /* Force to free the list of dirty files */ |
2830 | spin_lock(&sbi->s_inode_lock); | 2821 | spin_lock(&nilfs->ns_inode_lock); |
2831 | if (!list_empty(&sbi->s_dirty_files)) { | 2822 | if (!list_empty(&nilfs->ns_dirty_files)) { |
2832 | list_splice_init(&sbi->s_dirty_files, &garbage_list); | 2823 | list_splice_init(&nilfs->ns_dirty_files, &garbage_list); |
2833 | nilfs_warning(sbi->s_super, __func__, | 2824 | nilfs_warning(sb, __func__, |
2834 | "Non empty dirty list after the last " | 2825 | "Hit dirty file after stopped log writer\n"); |
2835 | "segment construction\n"); | 2826 | } |
2836 | } | 2827 | spin_unlock(&nilfs->ns_inode_lock); |
2837 | spin_unlock(&sbi->s_inode_lock); | ||
2838 | up_write(&nilfs->ns_segctor_sem); | 2828 | up_write(&nilfs->ns_segctor_sem); |
2839 | 2829 | ||
2840 | nilfs_dispose_list(sbi, &garbage_list, 1); | 2830 | nilfs_dispose_list(nilfs, &garbage_list, 1); |
2841 | } | 2831 | } |