aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/segbuf.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-11-29 02:51:16 -0500
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-11-30 07:06:35 -0500
commite29df395bc6d2d0c89b3d8a5939a24b1b43c2fb6 (patch)
tree6d6f570d8158d7a18570492d9f5f5edf843ed28c /fs/nilfs2/segbuf.c
parent9c965bac169f786cc6cca8ff81d3b636e923c960 (diff)
nilfs2: add iterator for segment buffers
This adds a few iterator functions for segment buffers to make it easy to handle multiple series of logs. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/segbuf.c')
-rw-r--r--fs/nilfs2/segbuf.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c
index 636590c92c8b..d856d62bf886 100644
--- a/fs/nilfs2/segbuf.c
+++ b/fs/nilfs2/segbuf.c
@@ -234,7 +234,7 @@ void nilfs_segbuf_fill_in_data_crc(struct nilfs_segment_buffer *segbuf,
234 raw_sum->ss_datasum = cpu_to_le32(crc); 234 raw_sum->ss_datasum = cpu_to_le32(crc);
235} 235}
236 236
237void nilfs_release_buffers(struct list_head *list) 237static void nilfs_release_buffers(struct list_head *list)
238{ 238{
239 struct buffer_head *bh, *n; 239 struct buffer_head *bh, *n;
240 240
@@ -256,6 +256,49 @@ void nilfs_release_buffers(struct list_head *list)
256 } 256 }
257} 257}
258 258
259static void nilfs_segbuf_clear(struct nilfs_segment_buffer *segbuf)
260{
261 nilfs_release_buffers(&segbuf->sb_segsum_buffers);
262 nilfs_release_buffers(&segbuf->sb_payload_buffers);
263}
264
265/*
266 * Iterators for segment buffers
267 */
268void nilfs_clear_logs(struct list_head *logs)
269{
270 struct nilfs_segment_buffer *segbuf;
271
272 list_for_each_entry(segbuf, logs, sb_list)
273 nilfs_segbuf_clear(segbuf);
274}
275
276void nilfs_truncate_logs(struct list_head *logs,
277 struct nilfs_segment_buffer *last)
278{
279 struct nilfs_segment_buffer *n, *segbuf;
280
281 segbuf = list_prepare_entry(last, logs, sb_list);
282 list_for_each_entry_safe_continue(segbuf, n, logs, sb_list) {
283 list_del_init(&segbuf->sb_list);
284 nilfs_segbuf_clear(segbuf);
285 nilfs_segbuf_free(segbuf);
286 }
287}
288
289int nilfs_wait_on_logs(struct list_head *logs)
290{
291 struct nilfs_segment_buffer *segbuf;
292 int err;
293
294 list_for_each_entry(segbuf, logs, sb_list) {
295 err = nilfs_segbuf_wait(segbuf);
296 if (err)
297 return err;
298 }
299 return 0;
300}
301
259/* 302/*
260 * BIO operations 303 * BIO operations
261 */ 304 */