Lines Matching full:sci
90 static inline void nilfs_sc_cstage_inc(struct nilfs_sc_info *sci) in nilfs_sc_cstage_inc() argument
92 sci->sc_stage.scnt++; in nilfs_sc_cstage_inc()
93 trace_nilfs2_collection_stage_transition(sci); in nilfs_sc_cstage_inc()
96 static inline void nilfs_sc_cstage_set(struct nilfs_sc_info *sci, int next_scnt) in nilfs_sc_cstage_set() argument
98 sci->sc_stage.scnt = next_scnt; in nilfs_sc_cstage_set()
99 trace_nilfs2_collection_stage_transition(sci); in nilfs_sc_cstage_set()
102 static inline int nilfs_sc_cstage_get(struct nilfs_sc_info *sci) in nilfs_sc_cstage_get() argument
104 return sci->sc_stage.scnt; in nilfs_sc_cstage_get()
271 struct nilfs_sc_info *sci = nilfs->ns_writer; in nilfs_transaction_commit() local
274 nilfs_segctor_start_timer(sci); in nilfs_transaction_commit()
275 if (atomic_read(&nilfs->ns_ndirtyblks) > sci->sc_watermark) in nilfs_transaction_commit()
276 nilfs_segctor_do_flush(sci, 0); in nilfs_transaction_commit()
318 struct nilfs_sc_info *sci = nilfs->ns_writer; in nilfs_relax_pressure_in_lock() local
320 if (sb_rdonly(sb) || unlikely(!sci) || !sci->sc_flush_request) in nilfs_relax_pressure_in_lock()
323 set_bit(NILFS_SC_PRIOR_FLUSH, &sci->sc_flags); in nilfs_relax_pressure_in_lock()
327 if (sci->sc_flush_request && in nilfs_relax_pressure_in_lock()
328 test_bit(NILFS_SC_PRIOR_FLUSH, &sci->sc_flags)) { in nilfs_relax_pressure_in_lock()
332 nilfs_segctor_do_immediate_flush(sci); in nilfs_relax_pressure_in_lock()
344 struct nilfs_sc_info *sci = nilfs->ns_writer; in nilfs_transaction_lock() local
358 if (!test_bit(NILFS_SC_PRIOR_FLUSH, &sci->sc_flags)) in nilfs_transaction_lock()
361 nilfs_segctor_do_immediate_flush(sci); in nilfs_transaction_lock()
388 static void *nilfs_segctor_map_segsum_entry(struct nilfs_sc_info *sci, in nilfs_segctor_map_segsum_entry() argument
392 struct nilfs_segment_buffer *segbuf = sci->sc_curseg; in nilfs_segctor_map_segsum_entry()
393 unsigned int blocksize = sci->sc_super->s_blocksize; in nilfs_segctor_map_segsum_entry()
409 * @sci: nilfs_sc_info
411 static int nilfs_segctor_reset_segment_buffer(struct nilfs_sc_info *sci) in nilfs_segctor_reset_segment_buffer() argument
413 struct nilfs_segment_buffer *segbuf = sci->sc_curseg; in nilfs_segctor_reset_segment_buffer()
421 err = nilfs_segbuf_reset(segbuf, flags, sci->sc_seg_ctime, sci->sc_cno); in nilfs_segctor_reset_segment_buffer()
427 sci->sc_finfo_ptr.bh = sumbh; sci->sc_finfo_ptr.offset = sumbytes; in nilfs_segctor_reset_segment_buffer()
428 sci->sc_binfo_ptr.bh = sumbh; sci->sc_binfo_ptr.offset = sumbytes; in nilfs_segctor_reset_segment_buffer()
429 sci->sc_blk_cnt = sci->sc_datablk_cnt = 0; in nilfs_segctor_reset_segment_buffer()
435 * @sci: segment constructor object
440 static void nilfs_segctor_zeropad_segsum(struct nilfs_sc_info *sci) in nilfs_segctor_zeropad_segsum() argument
444 ssp = sci->sc_blk_cnt > 0 ? &sci->sc_binfo_ptr : &sci->sc_finfo_ptr; in nilfs_segctor_zeropad_segsum()
450 static int nilfs_segctor_feed_segment(struct nilfs_sc_info *sci) in nilfs_segctor_feed_segment() argument
452 sci->sc_nblk_this_inc += sci->sc_curseg->sb_sum.nblocks; in nilfs_segctor_feed_segment()
453 if (NILFS_SEGBUF_IS_LAST(sci->sc_curseg, &sci->sc_segbufs)) in nilfs_segctor_feed_segment()
458 nilfs_segctor_zeropad_segsum(sci); in nilfs_segctor_feed_segment()
459 sci->sc_curseg = NILFS_NEXT_SEGBUF(sci->sc_curseg); in nilfs_segctor_feed_segment()
460 return nilfs_segctor_reset_segment_buffer(sci); in nilfs_segctor_feed_segment()
463 static int nilfs_segctor_add_super_root(struct nilfs_sc_info *sci) in nilfs_segctor_add_super_root() argument
465 struct nilfs_segment_buffer *segbuf = sci->sc_curseg; in nilfs_segctor_add_super_root()
469 err = nilfs_segctor_feed_segment(sci); in nilfs_segctor_add_super_root()
472 segbuf = sci->sc_curseg; in nilfs_segctor_add_super_root()
484 struct nilfs_sc_info *sci, const struct nilfs_segsum_pointer *ssp, in nilfs_segctor_segsum_block_required() argument
487 unsigned int blocksize = sci->sc_super->s_blocksize; in nilfs_segctor_segsum_block_required()
491 (!sci->sc_blk_cnt ? sizeof(struct nilfs_finfo) : 0) > in nilfs_segctor_segsum_block_required()
495 static void nilfs_segctor_begin_finfo(struct nilfs_sc_info *sci, in nilfs_segctor_begin_finfo() argument
498 sci->sc_curseg->sb_sum.nfinfo++; in nilfs_segctor_begin_finfo()
499 sci->sc_binfo_ptr = sci->sc_finfo_ptr; in nilfs_segctor_begin_finfo()
501 sci, &sci->sc_binfo_ptr, sizeof(struct nilfs_finfo)); in nilfs_segctor_begin_finfo()
504 !test_bit(NILFS_SC_HAVE_DELTA, &sci->sc_flags)) in nilfs_segctor_begin_finfo()
505 set_bit(NILFS_SC_HAVE_DELTA, &sci->sc_flags); in nilfs_segctor_begin_finfo()
509 static void nilfs_segctor_end_finfo(struct nilfs_sc_info *sci, in nilfs_segctor_end_finfo() argument
517 if (sci->sc_blk_cnt == 0) in nilfs_segctor_end_finfo()
527 cno = sci->sc_cno; in nilfs_segctor_end_finfo()
529 finfo = nilfs_segctor_map_segsum_entry(sci, &sci->sc_finfo_ptr, in nilfs_segctor_end_finfo()
532 finfo->fi_nblocks = cpu_to_le32(sci->sc_blk_cnt); in nilfs_segctor_end_finfo()
533 finfo->fi_ndatablk = cpu_to_le32(sci->sc_datablk_cnt); in nilfs_segctor_end_finfo()
536 segbuf = sci->sc_curseg; in nilfs_segctor_end_finfo()
537 segbuf->sb_sum.sumbytes = sci->sc_binfo_ptr.offset + in nilfs_segctor_end_finfo()
538 sci->sc_super->s_blocksize * (segbuf->sb_sum.nsumblk - 1); in nilfs_segctor_end_finfo()
539 sci->sc_finfo_ptr = sci->sc_binfo_ptr; in nilfs_segctor_end_finfo()
540 sci->sc_blk_cnt = sci->sc_datablk_cnt = 0; in nilfs_segctor_end_finfo()
543 static int nilfs_segctor_add_file_block(struct nilfs_sc_info *sci, in nilfs_segctor_add_file_block() argument
552 segbuf = sci->sc_curseg; in nilfs_segctor_add_file_block()
554 sci, &sci->sc_binfo_ptr, binfo_size); in nilfs_segctor_add_file_block()
556 nilfs_segctor_end_finfo(sci, inode); in nilfs_segctor_add_file_block()
557 err = nilfs_segctor_feed_segment(sci); in nilfs_segctor_add_file_block()
563 nilfs_segctor_zeropad_segsum(sci); in nilfs_segctor_add_file_block()
568 if (sci->sc_blk_cnt == 0) in nilfs_segctor_add_file_block()
569 nilfs_segctor_begin_finfo(sci, inode); in nilfs_segctor_add_file_block()
571 nilfs_segctor_map_segsum_entry(sci, &sci->sc_binfo_ptr, binfo_size); in nilfs_segctor_add_file_block()
574 sci->sc_blk_cnt++; in nilfs_segctor_add_file_block()
582 static int nilfs_collect_file_data(struct nilfs_sc_info *sci, in nilfs_collect_file_data() argument
591 err = nilfs_segctor_add_file_block(sci, bh, inode, in nilfs_collect_file_data()
594 sci->sc_datablk_cnt++; in nilfs_collect_file_data()
598 static int nilfs_collect_file_node(struct nilfs_sc_info *sci, in nilfs_collect_file_node() argument
605 static int nilfs_collect_file_bmap(struct nilfs_sc_info *sci, in nilfs_collect_file_bmap() argument
610 return nilfs_segctor_add_file_block(sci, bh, inode, sizeof(__le64)); in nilfs_collect_file_bmap()
613 static void nilfs_write_file_data_binfo(struct nilfs_sc_info *sci, in nilfs_write_file_data_binfo() argument
618 sci, ssp, sizeof(*binfo_v)); in nilfs_write_file_data_binfo()
622 static void nilfs_write_file_node_binfo(struct nilfs_sc_info *sci, in nilfs_write_file_node_binfo() argument
627 sci, ssp, sizeof(*vblocknr)); in nilfs_write_file_node_binfo()
639 static int nilfs_collect_dat_data(struct nilfs_sc_info *sci, in nilfs_collect_dat_data() argument
648 err = nilfs_segctor_add_file_block(sci, bh, inode, sizeof(__le64)); in nilfs_collect_dat_data()
650 sci->sc_datablk_cnt++; in nilfs_collect_dat_data()
654 static int nilfs_collect_dat_bmap(struct nilfs_sc_info *sci, in nilfs_collect_dat_bmap() argument
658 return nilfs_segctor_add_file_block(sci, bh, inode, in nilfs_collect_dat_bmap()
662 static void nilfs_write_dat_data_binfo(struct nilfs_sc_info *sci, in nilfs_write_dat_data_binfo() argument
666 __le64 *blkoff = nilfs_segctor_map_segsum_entry(sci, ssp, in nilfs_write_dat_data_binfo()
671 static void nilfs_write_dat_node_binfo(struct nilfs_sc_info *sci, in nilfs_write_dat_node_binfo() argument
676 nilfs_segctor_map_segsum_entry(sci, ssp, sizeof(*binfo_dat)); in nilfs_write_dat_node_binfo()
826 struct nilfs_sc_info *sci = container_of(work, struct nilfs_sc_info, in nilfs_iput_work_func() local
828 struct the_nilfs *nilfs = sci->sc_super->s_fs_info; in nilfs_iput_work_func()
830 nilfs_dispose_list(nilfs, &sci->sc_iput_queue, 0); in nilfs_iput_work_func()
849 static int nilfs_segctor_clean(struct nilfs_sc_info *sci) in nilfs_segctor_clean() argument
851 return list_empty(&sci->sc_dirty_files) && in nilfs_segctor_clean()
852 !test_bit(NILFS_SC_DIRTY, &sci->sc_flags) && in nilfs_segctor_clean()
853 sci->sc_nfreesegs == 0 && in nilfs_segctor_clean()
854 (!nilfs_doing_gc() || list_empty(&sci->sc_gc_inodes)); in nilfs_segctor_clean()
857 static int nilfs_segctor_confirm(struct nilfs_sc_info *sci) in nilfs_segctor_confirm() argument
859 struct the_nilfs *nilfs = sci->sc_super->s_fs_info; in nilfs_segctor_confirm()
862 if (nilfs_test_metadata_dirty(nilfs, sci->sc_root)) in nilfs_segctor_confirm()
863 set_bit(NILFS_SC_DIRTY, &sci->sc_flags); in nilfs_segctor_confirm()
866 if (list_empty(&nilfs->ns_dirty_files) && nilfs_segctor_clean(sci)) in nilfs_segctor_confirm()
873 static void nilfs_segctor_clear_metadata_dirty(struct nilfs_sc_info *sci) in nilfs_segctor_clear_metadata_dirty() argument
875 struct the_nilfs *nilfs = sci->sc_super->s_fs_info; in nilfs_segctor_clear_metadata_dirty()
877 nilfs_mdt_clear_dirty(sci->sc_root->ifile); in nilfs_segctor_clear_metadata_dirty()
900 static void nilfs_segctor_fill_in_file_bmap(struct nilfs_sc_info *sci) in nilfs_segctor_fill_in_file_bmap() argument
904 list_for_each_entry(ii, &sci->sc_dirty_files, i_dirty) { in nilfs_segctor_fill_in_file_bmap()
905 nilfs_fill_in_file_bmap(sci->sc_root->ifile, ii); in nilfs_segctor_fill_in_file_bmap()
937 static void nilfs_segctor_fill_in_super_root(struct nilfs_sc_info *sci, in nilfs_segctor_fill_in_super_root() argument
944 bh_sr = NILFS_LAST_SEGBUF(&sci->sc_segbufs)->sb_super_root; in nilfs_segctor_fill_in_super_root()
955 nilfs->ns_nongc_ctime : sci->sc_seg_ctime); in nilfs_segctor_fill_in_super_root()
993 static int nilfs_segctor_apply_buffers(struct nilfs_sc_info *sci, in nilfs_segctor_apply_buffers() argument
1006 err = collect(sci, bh, inode); in nilfs_segctor_apply_buffers()
1024 static size_t nilfs_segctor_buffer_rest(struct nilfs_sc_info *sci) in nilfs_segctor_buffer_rest() argument
1027 return sci->sc_segbuf_nblocks - in nilfs_segctor_buffer_rest()
1028 (sci->sc_nblk_this_inc + sci->sc_curseg->sb_sum.nblocks); in nilfs_segctor_buffer_rest()
1031 static int nilfs_segctor_scan_file(struct nilfs_sc_info *sci, in nilfs_segctor_scan_file() argument
1039 if (!(sci->sc_stage.flags & NILFS_CF_NODE)) { in nilfs_segctor_scan_file()
1040 size_t n, rest = nilfs_segctor_buffer_rest(sci); in nilfs_segctor_scan_file()
1046 sci, inode, &data_buffers, in nilfs_segctor_scan_file()
1054 if (!(sci->sc_stage.flags & NILFS_CF_NODE)) { in nilfs_segctor_scan_file()
1056 sci, inode, &data_buffers, sc_ops->collect_data); in nilfs_segctor_scan_file()
1060 sci, inode, &node_buffers, NULL); in nilfs_segctor_scan_file()
1063 sci->sc_stage.flags |= NILFS_CF_NODE; in nilfs_segctor_scan_file()
1067 sci, inode, &node_buffers, sc_ops->collect_node); in nilfs_segctor_scan_file()
1073 sci, inode, &node_buffers, sc_ops->collect_bmap); in nilfs_segctor_scan_file()
1077 nilfs_segctor_end_finfo(sci, inode); in nilfs_segctor_scan_file()
1078 sci->sc_stage.flags &= ~NILFS_CF_NODE; in nilfs_segctor_scan_file()
1084 static int nilfs_segctor_scan_file_dsync(struct nilfs_sc_info *sci, in nilfs_segctor_scan_file_dsync() argument
1088 size_t n, rest = nilfs_segctor_buffer_rest(sci); in nilfs_segctor_scan_file_dsync()
1092 sci->sc_dsync_start, in nilfs_segctor_scan_file_dsync()
1093 sci->sc_dsync_end); in nilfs_segctor_scan_file_dsync()
1095 err = nilfs_segctor_apply_buffers(sci, inode, &data_buffers, in nilfs_segctor_scan_file_dsync()
1098 nilfs_segctor_end_finfo(sci, inode); in nilfs_segctor_scan_file_dsync()
1158 static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode) in nilfs_segctor_collect_blocks() argument
1160 struct the_nilfs *nilfs = sci->sc_super->s_fs_info; in nilfs_segctor_collect_blocks()
1165 switch (nilfs_sc_cstage_get(sci)) { in nilfs_segctor_collect_blocks()
1168 sci->sc_stage.flags = 0; in nilfs_segctor_collect_blocks()
1170 if (!test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags)) { in nilfs_segctor_collect_blocks()
1171 sci->sc_nblk_inc = 0; in nilfs_segctor_collect_blocks()
1172 sci->sc_curseg->sb_sum.flags = NILFS_SS_LOGBGN; in nilfs_segctor_collect_blocks()
1174 nilfs_sc_cstage_set(sci, NILFS_ST_DSYNC); in nilfs_segctor_collect_blocks()
1179 sci->sc_stage.dirty_file_ptr = NULL; in nilfs_segctor_collect_blocks()
1180 sci->sc_stage.gc_inode_ptr = NULL; in nilfs_segctor_collect_blocks()
1182 nilfs_sc_cstage_set(sci, NILFS_ST_DAT); in nilfs_segctor_collect_blocks()
1185 nilfs_sc_cstage_inc(sci); in nilfs_segctor_collect_blocks()
1189 head = &sci->sc_gc_inodes; in nilfs_segctor_collect_blocks()
1190 ii = list_prepare_entry(sci->sc_stage.gc_inode_ptr, in nilfs_segctor_collect_blocks()
1194 sci, &ii->vfs_inode, in nilfs_segctor_collect_blocks()
1197 sci->sc_stage.gc_inode_ptr = list_entry( in nilfs_segctor_collect_blocks()
1205 sci->sc_stage.gc_inode_ptr = NULL; in nilfs_segctor_collect_blocks()
1207 nilfs_sc_cstage_inc(sci); in nilfs_segctor_collect_blocks()
1210 head = &sci->sc_dirty_files; in nilfs_segctor_collect_blocks()
1211 ii = list_prepare_entry(sci->sc_stage.dirty_file_ptr, head, in nilfs_segctor_collect_blocks()
1216 err = nilfs_segctor_scan_file(sci, &ii->vfs_inode, in nilfs_segctor_collect_blocks()
1219 sci->sc_stage.dirty_file_ptr = in nilfs_segctor_collect_blocks()
1225 /* sci->sc_stage.dirty_file_ptr = NILFS_I(inode); */ in nilfs_segctor_collect_blocks()
1228 sci->sc_stage.dirty_file_ptr = NULL; in nilfs_segctor_collect_blocks()
1230 nilfs_sc_cstage_set(sci, NILFS_ST_DONE); in nilfs_segctor_collect_blocks()
1233 nilfs_sc_cstage_inc(sci); in nilfs_segctor_collect_blocks()
1234 sci->sc_stage.flags |= NILFS_CF_IFILE_STARTED; in nilfs_segctor_collect_blocks()
1237 err = nilfs_segctor_scan_file(sci, sci->sc_root->ifile, in nilfs_segctor_collect_blocks()
1241 nilfs_sc_cstage_inc(sci); in nilfs_segctor_collect_blocks()
1249 err = nilfs_segctor_scan_file(sci, nilfs->ns_cpfile, in nilfs_segctor_collect_blocks()
1253 nilfs_sc_cstage_inc(sci); in nilfs_segctor_collect_blocks()
1256 err = nilfs_free_segments(nilfs, sci->sc_freesegs, in nilfs_segctor_collect_blocks()
1257 sci->sc_nfreesegs); in nilfs_segctor_collect_blocks()
1260 sci->sc_stage.flags |= NILFS_CF_SUFREED; in nilfs_segctor_collect_blocks()
1262 err = nilfs_segctor_scan_file(sci, nilfs->ns_sufile, in nilfs_segctor_collect_blocks()
1266 nilfs_sc_cstage_inc(sci); in nilfs_segctor_collect_blocks()
1270 err = nilfs_segctor_scan_file(sci, nilfs->ns_dat, in nilfs_segctor_collect_blocks()
1275 nilfs_sc_cstage_set(sci, NILFS_ST_DONE); in nilfs_segctor_collect_blocks()
1278 nilfs_sc_cstage_inc(sci); in nilfs_segctor_collect_blocks()
1283 err = nilfs_segctor_add_super_root(sci); in nilfs_segctor_collect_blocks()
1288 sci->sc_curseg->sb_sum.flags |= NILFS_SS_LOGEND; in nilfs_segctor_collect_blocks()
1289 nilfs_sc_cstage_set(sci, NILFS_ST_DONE); in nilfs_segctor_collect_blocks()
1293 sci->sc_curseg->sb_sum.flags |= NILFS_SS_SYNDT; in nilfs_segctor_collect_blocks()
1294 ii = sci->sc_dsync_inode; in nilfs_segctor_collect_blocks()
1298 err = nilfs_segctor_scan_file_dsync(sci, &ii->vfs_inode); in nilfs_segctor_collect_blocks()
1301 sci->sc_curseg->sb_sum.flags |= NILFS_SS_LOGEND; in nilfs_segctor_collect_blocks()
1302 nilfs_sc_cstage_set(sci, NILFS_ST_DONE); in nilfs_segctor_collect_blocks()
1316 * @sci: nilfs_sc_info
1319 static int nilfs_segctor_begin_construction(struct nilfs_sc_info *sci, in nilfs_segctor_begin_construction() argument
1326 segbuf = nilfs_segbuf_new(sci->sc_super); in nilfs_segctor_begin_construction()
1330 if (list_empty(&sci->sc_write_logs)) { in nilfs_segctor_begin_construction()
1346 prev = NILFS_LAST_SEGBUF(&sci->sc_write_logs); in nilfs_segctor_begin_construction()
1369 BUG_ON(!list_empty(&sci->sc_segbufs)); in nilfs_segctor_begin_construction()
1370 list_add_tail(&segbuf->sb_list, &sci->sc_segbufs); in nilfs_segctor_begin_construction()
1371 sci->sc_segbuf_nblocks = segbuf->sb_rest_blocks; in nilfs_segctor_begin_construction()
1379 static int nilfs_segctor_extend_segments(struct nilfs_sc_info *sci, in nilfs_segctor_extend_segments() argument
1388 prev = NILFS_LAST_SEGBUF(&sci->sc_segbufs); in nilfs_segctor_extend_segments()
1402 segbuf = nilfs_segbuf_new(sci->sc_super); in nilfs_segctor_extend_segments()
1408 sci->sc_segbuf_nblocks += segbuf->sb_rest_blocks; in nilfs_segctor_extend_segments()
1421 list_splice_tail(&list, &sci->sc_segbufs); in nilfs_segctor_extend_segments()
1474 static void nilfs_segctor_update_segusage(struct nilfs_sc_info *sci, in nilfs_segctor_update_segusage() argument
1481 list_for_each_entry(segbuf, &sci->sc_segbufs, sb_list) { in nilfs_segctor_update_segusage()
1486 sci->sc_seg_ctime); in nilfs_segctor_update_segusage()
1509 static void nilfs_segctor_truncate_segments(struct nilfs_sc_info *sci, in nilfs_segctor_truncate_segments() argument
1516 list_for_each_entry_continue(segbuf, &sci->sc_segbufs, sb_list) { in nilfs_segctor_truncate_segments()
1517 sci->sc_segbuf_nblocks -= segbuf->sb_rest_blocks; in nilfs_segctor_truncate_segments()
1521 nilfs_truncate_logs(&sci->sc_segbufs, last); in nilfs_segctor_truncate_segments()
1525 static int nilfs_segctor_collect(struct nilfs_sc_info *sci, in nilfs_segctor_collect() argument
1528 struct nilfs_cstage prev_stage = sci->sc_stage; in nilfs_segctor_collect()
1533 sci->sc_nblk_this_inc = 0; in nilfs_segctor_collect()
1534 sci->sc_curseg = NILFS_FIRST_SEGBUF(&sci->sc_segbufs); in nilfs_segctor_collect()
1536 err = nilfs_segctor_reset_segment_buffer(sci); in nilfs_segctor_collect()
1540 err = nilfs_segctor_collect_blocks(sci, mode); in nilfs_segctor_collect()
1541 sci->sc_nblk_this_inc += sci->sc_curseg->sb_sum.nblocks; in nilfs_segctor_collect()
1550 nilfs_sc_cstage_get(sci) < NILFS_ST_CPFILE) in nilfs_segctor_collect()
1553 nilfs_clear_logs(&sci->sc_segbufs); in nilfs_segctor_collect()
1555 if (sci->sc_stage.flags & NILFS_CF_SUFREED) { in nilfs_segctor_collect()
1557 sci->sc_freesegs, in nilfs_segctor_collect()
1558 sci->sc_nfreesegs, in nilfs_segctor_collect()
1561 sci->sc_stage.flags &= ~NILFS_CF_SUFREED; in nilfs_segctor_collect()
1564 err = nilfs_segctor_extend_segments(sci, nilfs, nadd); in nilfs_segctor_collect()
1569 sci->sc_stage = prev_stage; in nilfs_segctor_collect()
1571 nilfs_segctor_zeropad_segsum(sci); in nilfs_segctor_collect()
1572 nilfs_segctor_truncate_segments(sci, sci->sc_curseg, nilfs->ns_sufile); in nilfs_segctor_collect()
1589 nilfs_segctor_update_payload_blocknr(struct nilfs_sc_info *sci, in nilfs_segctor_update_payload_blocknr() argument
1617 sci, &ssp, sizeof(*finfo)); in nilfs_segctor_update_payload_blocknr()
1642 sc_op->write_data_binfo(sci, &ssp, &binfo); in nilfs_segctor_update_payload_blocknr()
1644 sc_op->write_node_binfo(sci, &ssp, &binfo); in nilfs_segctor_update_payload_blocknr()
1661 static int nilfs_segctor_assign(struct nilfs_sc_info *sci, int mode) in nilfs_segctor_assign() argument
1666 list_for_each_entry(segbuf, &sci->sc_segbufs, sb_list) { in nilfs_segctor_assign()
1667 err = nilfs_segctor_update_payload_blocknr(sci, segbuf, mode); in nilfs_segctor_assign()
1766 static int nilfs_segctor_write(struct nilfs_sc_info *sci, in nilfs_segctor_write() argument
1771 ret = nilfs_write_logs(&sci->sc_segbufs, nilfs); in nilfs_segctor_write()
1772 list_splice_tail_init(&sci->sc_segbufs, &sci->sc_write_logs); in nilfs_segctor_write()
1852 static void nilfs_segctor_abort_construction(struct nilfs_sc_info *sci, in nilfs_segctor_abort_construction() argument
1858 list_splice_tail_init(&sci->sc_write_logs, &logs); in nilfs_segctor_abort_construction()
1862 list_splice_tail_init(&sci->sc_segbufs, &logs); in nilfs_segctor_abort_construction()
1869 if (sci->sc_stage.flags & NILFS_CF_SUFREED) { in nilfs_segctor_abort_construction()
1871 sci->sc_freesegs, in nilfs_segctor_abort_construction()
1872 sci->sc_nfreesegs, in nilfs_segctor_abort_construction()
1891 static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci) in nilfs_segctor_complete_write() argument
1895 struct the_nilfs *nilfs = sci->sc_super->s_fs_info; in nilfs_segctor_complete_write()
1898 list_for_each_entry(segbuf, &sci->sc_write_logs, sb_list) { in nilfs_segctor_complete_write()
1949 set_bit(NILFS_SC_UNCLOSED, &sci->sc_flags); in nilfs_segctor_complete_write()
1950 sci->sc_lseg_stime = jiffies; in nilfs_segctor_complete_write()
1953 clear_bit(NILFS_SC_UNCLOSED, &sci->sc_flags); in nilfs_segctor_complete_write()
1965 nilfs_drop_collected_inodes(&sci->sc_dirty_files); in nilfs_segctor_complete_write()
1968 nilfs_drop_collected_inodes(&sci->sc_gc_inodes); in nilfs_segctor_complete_write()
1970 nilfs->ns_nongc_ctime = sci->sc_seg_ctime; in nilfs_segctor_complete_write()
1972 sci->sc_nblk_inc += sci->sc_nblk_this_inc; in nilfs_segctor_complete_write()
1974 segbuf = NILFS_LAST_SEGBUF(&sci->sc_write_logs); in nilfs_segctor_complete_write()
1982 clear_bit(NILFS_SC_HAVE_DELTA, &sci->sc_flags); in nilfs_segctor_complete_write()
1983 clear_bit(NILFS_SC_DIRTY, &sci->sc_flags); in nilfs_segctor_complete_write()
1984 set_bit(NILFS_SC_SUPER_ROOT, &sci->sc_flags); in nilfs_segctor_complete_write()
1985 nilfs_segctor_clear_metadata_dirty(sci); in nilfs_segctor_complete_write()
1987 clear_bit(NILFS_SC_SUPER_ROOT, &sci->sc_flags); in nilfs_segctor_complete_write()
1990 static int nilfs_segctor_wait(struct nilfs_sc_info *sci) in nilfs_segctor_wait() argument
1994 ret = nilfs_wait_on_logs(&sci->sc_write_logs); in nilfs_segctor_wait()
1996 nilfs_segctor_complete_write(sci); in nilfs_segctor_wait()
1997 nilfs_destroy_logs(&sci->sc_write_logs); in nilfs_segctor_wait()
2002 static int nilfs_segctor_collect_dirty_files(struct nilfs_sc_info *sci, in nilfs_segctor_collect_dirty_files() argument
2006 struct inode *ifile = sci->sc_root->ifile; in nilfs_segctor_collect_dirty_files()
2019 nilfs_warn(sci->sc_super, in nilfs_segctor_collect_dirty_files()
2038 list_move_tail(&ii->i_dirty, &sci->sc_dirty_files); in nilfs_segctor_collect_dirty_files()
2045 static void nilfs_segctor_drop_written_files(struct nilfs_sc_info *sci, in nilfs_segctor_drop_written_files() argument
2049 int during_mount = !(sci->sc_super->s_flags & SB_ACTIVE); in nilfs_segctor_drop_written_files()
2053 list_for_each_entry_safe(ii, n, &sci->sc_dirty_files, i_dirty) { in nilfs_segctor_drop_written_files()
2067 list_add_tail(&ii->i_dirty, &sci->sc_iput_queue); in nilfs_segctor_drop_written_files()
2078 schedule_work(&sci->sc_iput_work); in nilfs_segctor_drop_written_files()
2084 static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) in nilfs_segctor_do_construct() argument
2086 struct the_nilfs *nilfs = sci->sc_super->s_fs_info; in nilfs_segctor_do_construct()
2089 if (sb_rdonly(sci->sc_super)) in nilfs_segctor_do_construct()
2092 nilfs_sc_cstage_set(sci, NILFS_ST_INIT); in nilfs_segctor_do_construct()
2093 sci->sc_cno = nilfs->ns_cno; in nilfs_segctor_do_construct()
2095 err = nilfs_segctor_collect_dirty_files(sci, nilfs); in nilfs_segctor_do_construct()
2099 if (nilfs_test_metadata_dirty(nilfs, sci->sc_root)) in nilfs_segctor_do_construct()
2100 set_bit(NILFS_SC_DIRTY, &sci->sc_flags); in nilfs_segctor_do_construct()
2102 if (nilfs_segctor_clean(sci)) in nilfs_segctor_do_construct()
2106 sci->sc_stage.flags &= ~NILFS_CF_HISTORY_MASK; in nilfs_segctor_do_construct()
2108 err = nilfs_segctor_begin_construction(sci, nilfs); in nilfs_segctor_do_construct()
2113 sci->sc_seg_ctime = ktime_get_real_seconds(); in nilfs_segctor_do_construct()
2115 err = nilfs_segctor_collect(sci, nilfs, mode); in nilfs_segctor_do_construct()
2120 if (nilfs_sc_cstage_get(sci) == NILFS_ST_DONE && in nilfs_segctor_do_construct()
2121 nilfs_segbuf_empty(sci->sc_curseg)) { in nilfs_segctor_do_construct()
2122 nilfs_segctor_abort_construction(sci, nilfs, 1); in nilfs_segctor_do_construct()
2126 err = nilfs_segctor_assign(sci, mode); in nilfs_segctor_do_construct()
2130 if (sci->sc_stage.flags & NILFS_CF_IFILE_STARTED) in nilfs_segctor_do_construct()
2131 nilfs_segctor_fill_in_file_bmap(sci); in nilfs_segctor_do_construct()
2134 nilfs_sc_cstage_get(sci) >= NILFS_ST_CPFILE) { in nilfs_segctor_do_construct()
2136 nilfs->ns_cpfile, nilfs->ns_cno, sci->sc_root, in nilfs_segctor_do_construct()
2137 sci->sc_nblk_inc + sci->sc_nblk_this_inc, in nilfs_segctor_do_construct()
2138 sci->sc_seg_ctime, in nilfs_segctor_do_construct()
2139 !test_bit(NILFS_SC_HAVE_DELTA, &sci->sc_flags)); in nilfs_segctor_do_construct()
2143 nilfs_segctor_fill_in_super_root(sci, nilfs); in nilfs_segctor_do_construct()
2145 nilfs_segctor_update_segusage(sci, nilfs->ns_sufile); in nilfs_segctor_do_construct()
2148 nilfs_prepare_write_logs(&sci->sc_segbufs, nilfs->ns_crc_seed); in nilfs_segctor_do_construct()
2150 err = nilfs_segctor_write(sci, nilfs); in nilfs_segctor_do_construct()
2154 if (nilfs_sc_cstage_get(sci) == NILFS_ST_DONE || in nilfs_segctor_do_construct()
2163 err = nilfs_segctor_wait(sci); in nilfs_segctor_do_construct()
2167 } while (nilfs_sc_cstage_get(sci) != NILFS_ST_DONE); in nilfs_segctor_do_construct()
2170 nilfs_segctor_drop_written_files(sci, nilfs); in nilfs_segctor_do_construct()
2175 if (mode == SC_LSEG_SR && nilfs_sc_cstage_get(sci) >= NILFS_ST_IFILE) in nilfs_segctor_do_construct()
2176 nilfs_redirty_inodes(&sci->sc_dirty_files); in nilfs_segctor_do_construct()
2178 nilfs_redirty_inodes(&sci->sc_gc_inodes); in nilfs_segctor_do_construct()
2179 nilfs_segctor_abort_construction(sci, nilfs, err); in nilfs_segctor_do_construct()
2185 * @sci: nilfs_sc_info
2191 static void nilfs_segctor_start_timer(struct nilfs_sc_info *sci) in nilfs_segctor_start_timer() argument
2193 spin_lock(&sci->sc_state_lock); in nilfs_segctor_start_timer()
2194 if (!(sci->sc_state & NILFS_SEGCTOR_COMMIT)) { in nilfs_segctor_start_timer()
2195 if (sci->sc_task) { in nilfs_segctor_start_timer()
2196 sci->sc_timer.expires = jiffies + sci->sc_interval; in nilfs_segctor_start_timer()
2197 add_timer(&sci->sc_timer); in nilfs_segctor_start_timer()
2199 sci->sc_state |= NILFS_SEGCTOR_COMMIT; in nilfs_segctor_start_timer()
2201 spin_unlock(&sci->sc_state_lock); in nilfs_segctor_start_timer()
2204 static void nilfs_segctor_do_flush(struct nilfs_sc_info *sci, int bn) in nilfs_segctor_do_flush() argument
2206 spin_lock(&sci->sc_state_lock); in nilfs_segctor_do_flush()
2207 if (!(sci->sc_flush_request & BIT(bn))) { in nilfs_segctor_do_flush()
2208 unsigned long prev_req = sci->sc_flush_request; in nilfs_segctor_do_flush()
2210 sci->sc_flush_request |= BIT(bn); in nilfs_segctor_do_flush()
2212 wake_up(&sci->sc_wait_daemon); in nilfs_segctor_do_flush()
2214 spin_unlock(&sci->sc_state_lock); in nilfs_segctor_do_flush()
2225 struct nilfs_sc_info *sci = nilfs->ns_writer; in nilfs_flush_segment() local
2227 if (!sci || nilfs_doing_construction()) in nilfs_flush_segment()
2229 nilfs_segctor_do_flush(sci, NILFS_MDT_INODE(sb, ino) ? ino : 0); in nilfs_flush_segment()
2240 static int nilfs_segctor_sync(struct nilfs_sc_info *sci) in nilfs_segctor_sync() argument
2257 spin_lock(&sci->sc_state_lock); in nilfs_segctor_sync()
2258 wait_req.seq = ++sci->sc_seq_request; in nilfs_segctor_sync()
2259 add_wait_queue(&sci->sc_wait_request, &wait_req.wq); in nilfs_segctor_sync()
2260 spin_unlock(&sci->sc_state_lock); in nilfs_segctor_sync()
2262 wake_up(&sci->sc_wait_daemon); in nilfs_segctor_sync()
2272 if (!sci->sc_task) in nilfs_segctor_sync()
2286 finish_wait(&sci->sc_wait_request, &wait_req.wq); in nilfs_segctor_sync()
2290 static void nilfs_segctor_wakeup(struct nilfs_sc_info *sci, int err, bool force) in nilfs_segctor_wakeup() argument
2295 spin_lock_irqsave(&sci->sc_wait_request.lock, flags); in nilfs_segctor_wakeup()
2296 list_for_each_entry_safe(wrq, n, &sci->sc_wait_request.head, wq.entry) { in nilfs_segctor_wakeup()
2298 (force || nilfs_cnt32_ge(sci->sc_seq_done, wrq->seq))) { in nilfs_segctor_wakeup()
2308 spin_unlock_irqrestore(&sci->sc_wait_request.lock, flags); in nilfs_segctor_wakeup()
2331 struct nilfs_sc_info *sci = nilfs->ns_writer; in nilfs_construct_segment() local
2334 if (sb_rdonly(sb) || unlikely(!sci)) in nilfs_construct_segment()
2340 return nilfs_segctor_sync(sci); in nilfs_construct_segment()
2367 struct nilfs_sc_info *sci = nilfs->ns_writer; in nilfs_construct_dsync_segment() local
2372 if (sb_rdonly(sb) || unlikely(!sci)) in nilfs_construct_dsync_segment()
2380 test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) || in nilfs_construct_dsync_segment()
2383 err = nilfs_segctor_sync(sci); in nilfs_construct_dsync_segment()
2395 sci->sc_dsync_inode = ii; in nilfs_construct_dsync_segment()
2396 sci->sc_dsync_start = start; in nilfs_construct_dsync_segment()
2397 sci->sc_dsync_end = end; in nilfs_construct_dsync_segment()
2399 err = nilfs_segctor_do_construct(sci, SC_LSEG_DSYNC); in nilfs_construct_dsync_segment()
2412 * @sci: segment constructor object
2414 static void nilfs_segctor_accept(struct nilfs_sc_info *sci) in nilfs_segctor_accept() argument
2418 spin_lock(&sci->sc_state_lock); in nilfs_segctor_accept()
2419 sci->sc_seq_accepted = sci->sc_seq_request; in nilfs_segctor_accept()
2420 thread_is_alive = (bool)sci->sc_task; in nilfs_segctor_accept()
2421 spin_unlock(&sci->sc_state_lock); in nilfs_segctor_accept()
2430 del_timer_sync(&sci->sc_timer); in nilfs_segctor_accept()
2435 * @sci: segment constructor object
2439 static void nilfs_segctor_notify(struct nilfs_sc_info *sci, int mode, int err) in nilfs_segctor_notify() argument
2442 spin_lock(&sci->sc_state_lock); in nilfs_segctor_notify()
2445 sci->sc_state &= ~NILFS_SEGCTOR_COMMIT; in nilfs_segctor_notify()
2446 sci->sc_seq_done = sci->sc_seq_accepted; in nilfs_segctor_notify()
2447 nilfs_segctor_wakeup(sci, err, false); in nilfs_segctor_notify()
2448 sci->sc_flush_request = 0; in nilfs_segctor_notify()
2451 sci->sc_flush_request &= ~FLUSH_FILE_BIT; in nilfs_segctor_notify()
2453 sci->sc_flush_request &= ~FLUSH_DAT_BIT; in nilfs_segctor_notify()
2456 if ((sci->sc_state & NILFS_SEGCTOR_COMMIT) && sci->sc_task && in nilfs_segctor_notify()
2457 time_before(jiffies, sci->sc_timer.expires)) in nilfs_segctor_notify()
2458 add_timer(&sci->sc_timer); in nilfs_segctor_notify()
2460 spin_unlock(&sci->sc_state_lock); in nilfs_segctor_notify()
2465 * @sci: segment constructor object
2468 static int nilfs_segctor_construct(struct nilfs_sc_info *sci, int mode) in nilfs_segctor_construct() argument
2470 struct the_nilfs *nilfs = sci->sc_super->s_fs_info; in nilfs_segctor_construct()
2474 nilfs_segctor_accept(sci); in nilfs_segctor_construct()
2478 if (!nilfs_segctor_confirm(sci)) in nilfs_segctor_construct()
2479 err = nilfs_segctor_do_construct(sci, mode); in nilfs_segctor_construct()
2484 if (test_bit(NILFS_SC_SUPER_ROOT, &sci->sc_flags) && in nilfs_segctor_construct()
2488 sbp = nilfs_prepare_super(sci->sc_super, in nilfs_segctor_construct()
2492 err = nilfs_commit_super(sci->sc_super, in nilfs_segctor_construct()
2499 nilfs_segctor_notify(sci, mode, err); in nilfs_segctor_construct()
2505 struct nilfs_sc_info *sci = from_timer(sci, t, sc_timer); in nilfs_construction_timeout() local
2507 wake_up_process(sci->sc_task); in nilfs_construction_timeout()
2529 struct nilfs_sc_info *sci = nilfs->ns_writer; in nilfs_clean_segments() local
2533 if (unlikely(!sci)) in nilfs_clean_segments()
2548 sci->sc_freesegs = kbufs[4]; in nilfs_clean_segments()
2549 sci->sc_nfreesegs = argv[4].v_nmembs; in nilfs_clean_segments()
2550 list_splice_tail_init(&nilfs->ns_gc_inodes, &sci->sc_gc_inodes); in nilfs_clean_segments()
2553 err = nilfs_segctor_construct(sci, SC_LSEG_SR); in nilfs_clean_segments()
2554 nilfs_remove_written_gcinodes(nilfs, &sci->sc_gc_inodes); in nilfs_clean_segments()
2561 schedule_timeout(sci->sc_interval); in nilfs_clean_segments()
2564 int ret = nilfs_discard_segments(nilfs, sci->sc_freesegs, in nilfs_clean_segments()
2565 sci->sc_nfreesegs); in nilfs_clean_segments()
2575 sci->sc_freesegs = NULL; in nilfs_clean_segments()
2576 sci->sc_nfreesegs = 0; in nilfs_clean_segments()
2582 static void nilfs_segctor_thread_construct(struct nilfs_sc_info *sci, int mode) in nilfs_segctor_thread_construct() argument
2586 nilfs_transaction_lock(sci->sc_super, &ti, 0); in nilfs_segctor_thread_construct()
2587 nilfs_segctor_construct(sci, mode); in nilfs_segctor_thread_construct()
2594 if (test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags)) in nilfs_segctor_thread_construct()
2595 nilfs_segctor_start_timer(sci); in nilfs_segctor_thread_construct()
2597 nilfs_transaction_unlock(sci->sc_super); in nilfs_segctor_thread_construct()
2600 static void nilfs_segctor_do_immediate_flush(struct nilfs_sc_info *sci) in nilfs_segctor_do_immediate_flush() argument
2604 spin_lock(&sci->sc_state_lock); in nilfs_segctor_do_immediate_flush()
2605 mode = (sci->sc_flush_request & FLUSH_DAT_BIT) ? in nilfs_segctor_do_immediate_flush()
2607 spin_unlock(&sci->sc_state_lock); in nilfs_segctor_do_immediate_flush()
2610 nilfs_segctor_do_construct(sci, mode); in nilfs_segctor_do_immediate_flush()
2612 spin_lock(&sci->sc_state_lock); in nilfs_segctor_do_immediate_flush()
2613 sci->sc_flush_request &= (mode == SC_FLUSH_FILE) ? in nilfs_segctor_do_immediate_flush()
2615 spin_unlock(&sci->sc_state_lock); in nilfs_segctor_do_immediate_flush()
2617 clear_bit(NILFS_SC_PRIOR_FLUSH, &sci->sc_flags); in nilfs_segctor_do_immediate_flush()
2620 static int nilfs_segctor_flush_mode(struct nilfs_sc_info *sci) in nilfs_segctor_flush_mode() argument
2622 if (!test_bit(NILFS_SC_UNCLOSED, &sci->sc_flags) || in nilfs_segctor_flush_mode()
2623 time_before(jiffies, sci->sc_lseg_stime + sci->sc_mjcp_freq)) { in nilfs_segctor_flush_mode()
2624 if (!(sci->sc_flush_request & ~FLUSH_FILE_BIT)) in nilfs_segctor_flush_mode()
2626 else if (!(sci->sc_flush_request & ~FLUSH_DAT_BIT)) in nilfs_segctor_flush_mode()
2634 * @sci: nilfs_sc_info struct
2640 static bool nilfs_log_write_required(struct nilfs_sc_info *sci, int *modep) in nilfs_log_write_required() argument
2644 spin_lock(&sci->sc_state_lock); in nilfs_log_write_required()
2645 timedout = ((sci->sc_state & NILFS_SEGCTOR_COMMIT) && in nilfs_log_write_required()
2646 time_after_eq(jiffies, sci->sc_timer.expires)); in nilfs_log_write_required()
2647 if (timedout || sci->sc_seq_request != sci->sc_seq_done) in nilfs_log_write_required()
2649 else if (sci->sc_flush_request) in nilfs_log_write_required()
2650 *modep = nilfs_segctor_flush_mode(sci); in nilfs_log_write_required()
2654 spin_unlock(&sci->sc_state_lock); in nilfs_log_write_required()
2671 struct nilfs_sc_info *sci = (struct nilfs_sc_info *)arg; in nilfs_segctor_thread() local
2672 struct the_nilfs *nilfs = sci->sc_super->s_fs_info; in nilfs_segctor_thread()
2674 nilfs_info(sci->sc_super, in nilfs_segctor_thread()
2676 sci->sc_interval / HZ, sci->sc_mjcp_freq / HZ); in nilfs_segctor_thread()
2690 prepare_to_wait(&sci->sc_wait_daemon, &wait, in nilfs_segctor_thread()
2692 should_write = nilfs_log_write_required(sci, &mode); in nilfs_segctor_thread()
2695 finish_wait(&sci->sc_wait_daemon, &wait); in nilfs_segctor_thread()
2701 nilfs_segctor_thread_construct(sci, mode); in nilfs_segctor_thread()
2705 spin_lock(&sci->sc_state_lock); in nilfs_segctor_thread()
2706 sci->sc_task = NULL; in nilfs_segctor_thread()
2707 timer_shutdown_sync(&sci->sc_timer); in nilfs_segctor_thread()
2708 spin_unlock(&sci->sc_state_lock); in nilfs_segctor_thread()
2719 struct nilfs_sc_info *sci; in nilfs_segctor_new() local
2721 sci = kzalloc(sizeof(*sci), GFP_KERNEL); in nilfs_segctor_new()
2722 if (!sci) in nilfs_segctor_new()
2725 sci->sc_super = sb; in nilfs_segctor_new()
2728 sci->sc_root = root; in nilfs_segctor_new()
2730 init_waitqueue_head(&sci->sc_wait_request); in nilfs_segctor_new()
2731 init_waitqueue_head(&sci->sc_wait_daemon); in nilfs_segctor_new()
2732 spin_lock_init(&sci->sc_state_lock); in nilfs_segctor_new()
2733 INIT_LIST_HEAD(&sci->sc_dirty_files); in nilfs_segctor_new()
2734 INIT_LIST_HEAD(&sci->sc_segbufs); in nilfs_segctor_new()
2735 INIT_LIST_HEAD(&sci->sc_write_logs); in nilfs_segctor_new()
2736 INIT_LIST_HEAD(&sci->sc_gc_inodes); in nilfs_segctor_new()
2737 INIT_LIST_HEAD(&sci->sc_iput_queue); in nilfs_segctor_new()
2738 INIT_WORK(&sci->sc_iput_work, nilfs_iput_work_func); in nilfs_segctor_new()
2740 sci->sc_interval = HZ * NILFS_SC_DEFAULT_TIMEOUT; in nilfs_segctor_new()
2741 sci->sc_mjcp_freq = HZ * NILFS_SC_DEFAULT_SR_FREQ; in nilfs_segctor_new()
2742 sci->sc_watermark = NILFS_SC_DEFAULT_WATERMARK; in nilfs_segctor_new()
2745 sci->sc_interval = HZ * nilfs->ns_interval; in nilfs_segctor_new()
2747 sci->sc_watermark = nilfs->ns_watermark; in nilfs_segctor_new()
2748 return sci; in nilfs_segctor_new()
2751 static void nilfs_segctor_write_out(struct nilfs_sc_info *sci) in nilfs_segctor_write_out() argument
2762 nilfs_transaction_lock(sci->sc_super, &ti, 0); in nilfs_segctor_write_out()
2763 ret = nilfs_segctor_construct(sci, SC_LSEG_SR); in nilfs_segctor_write_out()
2764 nilfs_transaction_unlock(sci->sc_super); in nilfs_segctor_write_out()
2766 flush_work(&sci->sc_iput_work); in nilfs_segctor_write_out()
2773 * @sci: nilfs_sc_info
2779 static void nilfs_segctor_destroy(struct nilfs_sc_info *sci) in nilfs_segctor_destroy() argument
2781 struct the_nilfs *nilfs = sci->sc_super->s_fs_info; in nilfs_segctor_destroy()
2786 if (sci->sc_task) { in nilfs_segctor_destroy()
2787 wake_up(&sci->sc_wait_daemon); in nilfs_segctor_destroy()
2788 kthread_stop(sci->sc_task); in nilfs_segctor_destroy()
2791 spin_lock(&sci->sc_state_lock); in nilfs_segctor_destroy()
2792 flag = ((sci->sc_state & NILFS_SEGCTOR_COMMIT) || sci->sc_flush_request in nilfs_segctor_destroy()
2793 || sci->sc_seq_request != sci->sc_seq_done); in nilfs_segctor_destroy()
2794 spin_unlock(&sci->sc_state_lock); in nilfs_segctor_destroy()
2801 nilfs_segctor_wakeup(sci, 0, true); in nilfs_segctor_destroy()
2803 if (flush_work(&sci->sc_iput_work)) in nilfs_segctor_destroy()
2806 if (flag || !nilfs_segctor_confirm(sci)) in nilfs_segctor_destroy()
2807 nilfs_segctor_write_out(sci); in nilfs_segctor_destroy()
2809 if (!list_empty(&sci->sc_dirty_files)) { in nilfs_segctor_destroy()
2810 nilfs_warn(sci->sc_super, in nilfs_segctor_destroy()
2812 nilfs_dispose_list(nilfs, &sci->sc_dirty_files, 1); in nilfs_segctor_destroy()
2815 if (!list_empty(&sci->sc_iput_queue)) { in nilfs_segctor_destroy()
2816 nilfs_warn(sci->sc_super, in nilfs_segctor_destroy()
2818 nilfs_dispose_list(nilfs, &sci->sc_iput_queue, 1); in nilfs_segctor_destroy()
2821 WARN_ON(!list_empty(&sci->sc_segbufs)); in nilfs_segctor_destroy()
2822 WARN_ON(!list_empty(&sci->sc_write_logs)); in nilfs_segctor_destroy()
2824 nilfs_put_root(sci->sc_root); in nilfs_segctor_destroy()
2828 kfree(sci); in nilfs_segctor_destroy()
2846 struct nilfs_sc_info *sci; in nilfs_attach_log_writer() local
2860 sci = nilfs_segctor_new(sb, root); in nilfs_attach_log_writer()
2861 if (unlikely(!sci)) in nilfs_attach_log_writer()
2864 nilfs->ns_writer = sci; in nilfs_attach_log_writer()
2865 t = kthread_create(nilfs_segctor_thread, sci, "segctord"); in nilfs_attach_log_writer()
2872 sci->sc_task = t; in nilfs_attach_log_writer()
2873 timer_setup(&sci->sc_timer, nilfs_construction_timeout, 0); in nilfs_attach_log_writer()
2875 wake_up_process(sci->sc_task); in nilfs_attach_log_writer()