aboutsummaryrefslogtreecommitdiff
path: root/fs/nilfs2/segment.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nilfs2/segment.c')
-rw-r--r--fs/nilfs2/segment.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 5db12d774a0..24d0fbd4271 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -2229,13 +2229,6 @@ static void nilfs_segctor_reactivate_segments(struct nilfs_sc_info *sci,
nilfs_segment_usage_set_active(ent->raw_su);
nilfs_close_segment_entry(ent, sufile);
}
-
- down_write(&nilfs->ns_sem);
- head = &nilfs->ns_used_segments;
- list_for_each_entry(ent, head, list) {
- nilfs_segment_usage_set_volatile_active(ent->raw_su);
- }
- up_write(&nilfs->ns_sem);
}
static int nilfs_segctor_deactivate_segments(struct nilfs_sc_info *sci,
@@ -2244,7 +2237,6 @@ static int nilfs_segctor_deactivate_segments(struct nilfs_sc_info *sci,
struct nilfs_segment_buffer *segbuf, *last;
struct nilfs_segment_entry *ent;
struct inode *sufile = nilfs->ns_sufile;
- struct list_head *head;
int err;
last = NILFS_LAST_SEGBUF(&sci->sc_segbufs);
@@ -2265,22 +2257,13 @@ static int nilfs_segctor_deactivate_segments(struct nilfs_sc_info *sci,
BUG_ON(!buffer_dirty(ent->bh_su));
}
- head = &sci->sc_active_segments;
- list_for_each_entry(ent, head, list) {
+ 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);
BUG_ON(!buffer_dirty(ent->bh_su));
}
-
- down_write(&nilfs->ns_sem);
- head = &nilfs->ns_used_segments;
- list_for_each_entry(ent, head, list) {
- /* clear volatile active for segments of older generations */
- nilfs_segment_usage_clear_volatile_active(ent->raw_su);
- }
- up_write(&nilfs->ns_sem);
return 0;
failed:
@@ -2304,19 +2287,15 @@ static void nilfs_segctor_bead_completed_segments(struct nilfs_sc_info *sci)
}
}
-static void
-__nilfs_segctor_commit_deactivate_segments(struct nilfs_sc_info *sci,
- struct the_nilfs *nilfs)
-
+static void nilfs_segctor_commit_deactivate_segments(struct nilfs_sc_info *sci,
+ struct the_nilfs *nilfs)
{
- struct nilfs_segment_entry *ent;
-
- list_splice_init(&sci->sc_active_segments,
- nilfs->ns_used_segments.prev);
+ struct nilfs_segment_entry *ent, *n;
- list_for_each_entry(ent, &nilfs->ns_used_segments, list) {
- nilfs_segment_usage_set_volatile_active(ent->raw_su);
- /* These segments are kept open */
+ 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);
}
}
@@ -2405,8 +2384,8 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode)
if (has_sr) {
down_write(&nilfs->ns_sem);
nilfs_update_last_segment(sbi, 1);
- __nilfs_segctor_commit_deactivate_segments(sci, nilfs);
up_write(&nilfs->ns_sem);
+ nilfs_segctor_commit_deactivate_segments(sci, nilfs);
nilfs_segctor_commit_free_segments(sci);
nilfs_segctor_clear_metadata_dirty(sci);
}