aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/segment.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-04-06 22:01:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-07 11:31:19 -0400
commit2c2e52fc4fca251e68f90821c9ff5cb18be4df58 (patch)
treefb0b86203bb5f4dda4d5907e29bd2b1b6cc0be90 /fs/nilfs2/segment.c
parent7a9461939a46345860622ea36ff267ee4446f00f (diff)
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>
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 5db12d774a03..24d0fbd4271c 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,
2229 nilfs_segment_usage_set_active(ent->raw_su); 2229 nilfs_segment_usage_set_active(ent->raw_su);
2230 nilfs_close_segment_entry(ent, sufile); 2230 nilfs_close_segment_entry(ent, sufile);
2231 } 2231 }
2232
2233 down_write(&nilfs->ns_sem);
2234 head = &nilfs->ns_used_segments;
2235 list_for_each_entry(ent, head, list) {
2236 nilfs_segment_usage_set_volatile_active(ent->raw_su);
2237 }
2238 up_write(&nilfs->ns_sem);
2239} 2232}
2240 2233
2241static int nilfs_segctor_deactivate_segments(struct nilfs_sc_info *sci, 2234static 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,
2244 struct nilfs_segment_buffer *segbuf, *last; 2237 struct nilfs_segment_buffer *segbuf, *last;
2245 struct nilfs_segment_entry *ent; 2238 struct nilfs_segment_entry *ent;
2246 struct inode *sufile = nilfs->ns_sufile; 2239 struct inode *sufile = nilfs->ns_sufile;
2247 struct list_head *head;
2248 int err; 2240 int err;
2249 2241
2250 last = NILFS_LAST_SEGBUF(&sci->sc_segbufs); 2242 last = NILFS_LAST_SEGBUF(&sci->sc_segbufs);
@@ -2265,22 +2257,13 @@ static int nilfs_segctor_deactivate_segments(struct nilfs_sc_info *sci,
2265 BUG_ON(!buffer_dirty(ent->bh_su)); 2257 BUG_ON(!buffer_dirty(ent->bh_su));
2266 } 2258 }
2267 2259
2268 head = &sci->sc_active_segments; 2260 list_for_each_entry(ent, &sci->sc_active_segments, list) {
2269 list_for_each_entry(ent, head, list) {
2270 err = nilfs_open_segment_entry(ent, sufile); 2261 err = nilfs_open_segment_entry(ent, sufile);
2271 if (unlikely(err)) 2262 if (unlikely(err))
2272 goto failed; 2263 goto failed;
2273 nilfs_segment_usage_clear_active(ent->raw_su); 2264 nilfs_segment_usage_clear_active(ent->raw_su);
2274 BUG_ON(!buffer_dirty(ent->bh_su)); 2265 BUG_ON(!buffer_dirty(ent->bh_su));
2275 } 2266 }
2276
2277 down_write(&nilfs->ns_sem);
2278 head = &nilfs->ns_used_segments;
2279 list_for_each_entry(ent, head, list) {
2280 /* clear volatile active for segments of older generations */
2281 nilfs_segment_usage_clear_volatile_active(ent->raw_su);
2282 }
2283 up_write(&nilfs->ns_sem);
2284 return 0; 2267 return 0;
2285 2268
2286 failed: 2269 failed:
@@ -2304,19 +2287,15 @@ static void nilfs_segctor_bead_completed_segments(struct nilfs_sc_info *sci)
2304 } 2287 }
2305} 2288}
2306 2289
2307static void 2290static void nilfs_segctor_commit_deactivate_segments(struct nilfs_sc_info *sci,
2308__nilfs_segctor_commit_deactivate_segments(struct nilfs_sc_info *sci, 2291 struct the_nilfs *nilfs)
2309 struct the_nilfs *nilfs)
2310
2311{ 2292{
2312 struct nilfs_segment_entry *ent; 2293 struct nilfs_segment_entry *ent, *n;
2313
2314 list_splice_init(&sci->sc_active_segments,
2315 nilfs->ns_used_segments.prev);
2316 2294
2317 list_for_each_entry(ent, &nilfs->ns_used_segments, list) { 2295 list_for_each_entry_safe(ent, n, &sci->sc_active_segments, list) {
2318 nilfs_segment_usage_set_volatile_active(ent->raw_su); 2296 list_del(&ent->list);
2319 /* These segments are kept open */ 2297 nilfs_close_segment_entry(ent, nilfs->ns_sufile);
2298 nilfs_free_segment_entry(ent);
2320 } 2299 }
2321} 2300}
2322 2301
@@ -2405,8 +2384,8 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode)
2405 if (has_sr) { 2384 if (has_sr) {
2406 down_write(&nilfs->ns_sem); 2385 down_write(&nilfs->ns_sem);
2407 nilfs_update_last_segment(sbi, 1); 2386 nilfs_update_last_segment(sbi, 1);
2408 __nilfs_segctor_commit_deactivate_segments(sci, nilfs);
2409 up_write(&nilfs->ns_sem); 2387 up_write(&nilfs->ns_sem);
2388 nilfs_segctor_commit_deactivate_segments(sci, nilfs);
2410 nilfs_segctor_commit_free_segments(sci); 2389 nilfs_segctor_commit_free_segments(sci);
2411 nilfs_segctor_clear_metadata_dirty(sci); 2390 nilfs_segctor_clear_metadata_dirty(sci);
2412 } 2391 }