-/*
- * Nasty routines to manipulate active flags on sufile.
- * These would be removed in a future release.
- */
-static void nilfs_segctor_reactivate_segments(struct nilfs_sc_info *sci,
- struct the_nilfs *nilfs)
-{
- struct nilfs_segment_buffer *segbuf, *last;
- struct nilfs_segment_entry *ent, *n;
- struct inode *sufile = nilfs->ns_sufile;
- struct list_head *head;
-
- last = NILFS_LAST_SEGBUF(&sci->sc_segbufs);
- nilfs_for_each_segbuf_before(segbuf, last, &sci->sc_segbufs) {
- ent = segbuf->sb_segent;
- if (!ent)
- break; /* ignore unmapped segments (should check it?)*/
- nilfs_segment_usage_set_active(ent->raw_su);
- nilfs_close_segment_entry(ent, sufile);
- }
-
- head = &sci->sc_active_segments;
- list_for_each_entry_safe(ent, n, head, list) {
- nilfs_segment_usage_set_active(ent->raw_su);
- nilfs_close_segment_entry(ent, sufile);
- }
-}
-
-static int nilfs_segctor_deactivate_segments(struct nilfs_sc_info *sci,
- struct the_nilfs *nilfs)
-{
- struct nilfs_segment_buffer *segbuf, *last;
- struct nilfs_segment_entry *ent;
- struct inode *sufile = nilfs->ns_sufile;
- int err;
-
- last = NILFS_LAST_SEGBUF(&sci->sc_segbufs);
- nilfs_for_each_segbuf_before(segbuf, last, &sci->sc_segbufs) {
- /*
- * Deactivate ongoing full segments. The last segment is kept
- * active because it is a start point of recovery, and is not
- * relocatable until the super block points to a newer
- * checkpoint.
- */
- ent = segbuf->sb_segent;
- if (!ent)
- break; /* ignore unmapped segments (should check it?)*/
- err = nilfs_open_segment_entry(ent, sufile);
- if (unlikely(err))
- goto failed;
- nilfs_segment_usage_clear_active(ent->raw_su);
- BUG_ON(!buffer_dirty(ent->bh_su));
- }
-
- list_for_each_entry(ent, &sci->sc_active_segments, list) {
- err = nilfs_open_segment_entry(ent, sufile);
- if (unlikely(err))
- goto failed;
- nilfs_segment_usage_clear_active(ent->raw_su);
- WARN_ON(!buffer_dirty(ent->bh_su));
- }
- return 0;
-
- failed:
- nilfs_segctor_reactivate_segments(sci, nilfs);
- return err;
-}
-
-static void nilfs_segctor_bead_completed_segments(struct nilfs_sc_info *sci)
-{
- struct nilfs_segment_buffer *segbuf, *last;
- struct nilfs_segment_entry *ent;
-
- /* move each segbuf->sb_segent to the list of used active segments */
- last = NILFS_LAST_SEGBUF(&sci->sc_segbufs);
- nilfs_for_each_segbuf_before(segbuf, last, &sci->sc_segbufs) {
- ent = segbuf->sb_segent;
- if (!ent)
- break; /* ignore unmapped segments (should check it?)*/
- list_add_tail(&ent->list, &sci->sc_active_segments);
- segbuf->sb_segent = NULL;
- }
-}
-
-static void nilfs_segctor_commit_deactivate_segments(struct nilfs_sc_info *sci,
- struct the_nilfs *nilfs)
-{
- struct nilfs_segment_entry *ent, *n;
-
- list_for_each_entry_safe(ent, n, &sci->sc_active_segments, list) {
- list_del(&ent->list);
- nilfs_close_segment_entry(ent, nilfs->ns_sufile);
- nilfs_free_segment_entry(ent);
- }
-}
-