nilfs2: extend nilfs_sustat ioctl struct

This adds a new argument to the nilfs_sustat structure.

The extended field allows to delete volatile active state of segments,
which was needed to protect freshly-created segments from garbage
collection but has confused code dealing with segments.  This
extension alleviates the mess and gives room for further
simplifications.

The volatile active flag is not persistent, so it's eliminable on this
occasion without affecting compatibility other than the ioctl change.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Ryusuke Konishi
2009-04-06 19:01:54 -07:00
committed by Linus Torvalds
parent 7a9461939a
commit 2c2e52fc4f
7 changed files with 41 additions and 75 deletions

View File

@@ -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;
struct nilfs_segment_entry *ent, *n;
list_splice_init(&sci->sc_active_segments,
nilfs->ns_used_segments.prev);
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);
}