diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-11-18 04:23:34 -0500 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-11-19 20:05:51 -0500 |
commit | 071ec54dd730307ee0e703a105872b9a1c6fd2aa (patch) | |
tree | fb6629e471adf24d432487e0641549fd38d20ef3 /fs/nilfs2/segment.c | |
parent | 61a189e9c62359cd12b2aa3bd6ab9cffa6cf2745 (diff) |
nilfs2: move routine to set segment usage into sufile
This adds nilfs_sufile_set_segment_usage() function in sufile to
replace direct access to the sufile metadata in log writer code.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/segment.c')
-rw-r--r-- | fs/nilfs2/segment.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 3ae4a3849f81..097f9c467fef 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c | |||
@@ -1457,21 +1457,16 @@ static void nilfs_segctor_update_segusage(struct nilfs_sc_info *sci, | |||
1457 | struct inode *sufile) | 1457 | struct inode *sufile) |
1458 | { | 1458 | { |
1459 | struct nilfs_segment_buffer *segbuf; | 1459 | struct nilfs_segment_buffer *segbuf; |
1460 | struct buffer_head *bh_su; | ||
1461 | struct nilfs_segment_usage *raw_su; | ||
1462 | unsigned long live_blocks; | 1460 | unsigned long live_blocks; |
1463 | int ret; | 1461 | int ret; |
1464 | 1462 | ||
1465 | list_for_each_entry(segbuf, &sci->sc_segbufs, sb_list) { | 1463 | list_for_each_entry(segbuf, &sci->sc_segbufs, sb_list) { |
1466 | ret = nilfs_sufile_get_segment_usage(sufile, segbuf->sb_segnum, | ||
1467 | &raw_su, &bh_su); | ||
1468 | WARN_ON(ret); /* always succeed because bh_su is dirty */ | ||
1469 | live_blocks = segbuf->sb_sum.nblocks + | 1464 | live_blocks = segbuf->sb_sum.nblocks + |
1470 | (segbuf->sb_pseg_start - segbuf->sb_fseg_start); | 1465 | (segbuf->sb_pseg_start - segbuf->sb_fseg_start); |
1471 | raw_su->su_lastmod = cpu_to_le64(sci->sc_seg_ctime); | 1466 | ret = nilfs_sufile_set_segment_usage(sufile, segbuf->sb_segnum, |
1472 | raw_su->su_nblocks = cpu_to_le32(live_blocks); | 1467 | live_blocks, |
1473 | nilfs_sufile_put_segment_usage(sufile, segbuf->sb_segnum, | 1468 | sci->sc_seg_ctime); |
1474 | bh_su); | 1469 | WARN_ON(ret); /* always succeed because the segusage is dirty */ |
1475 | } | 1470 | } |
1476 | } | 1471 | } |
1477 | 1472 | ||
@@ -1479,25 +1474,18 @@ static void nilfs_segctor_cancel_segusage(struct nilfs_sc_info *sci, | |||
1479 | struct inode *sufile) | 1474 | struct inode *sufile) |
1480 | { | 1475 | { |
1481 | struct nilfs_segment_buffer *segbuf; | 1476 | struct nilfs_segment_buffer *segbuf; |
1482 | struct buffer_head *bh_su; | ||
1483 | struct nilfs_segment_usage *raw_su; | ||
1484 | int ret; | 1477 | int ret; |
1485 | 1478 | ||
1486 | segbuf = NILFS_FIRST_SEGBUF(&sci->sc_segbufs); | 1479 | segbuf = NILFS_FIRST_SEGBUF(&sci->sc_segbufs); |
1487 | ret = nilfs_sufile_get_segment_usage(sufile, segbuf->sb_segnum, | 1480 | ret = nilfs_sufile_set_segment_usage(sufile, segbuf->sb_segnum, |
1488 | &raw_su, &bh_su); | 1481 | segbuf->sb_pseg_start - |
1489 | WARN_ON(ret); /* always succeed because bh_su is dirty */ | 1482 | segbuf->sb_fseg_start, 0); |
1490 | raw_su->su_nblocks = cpu_to_le32(segbuf->sb_pseg_start - | 1483 | WARN_ON(ret); /* always succeed because the segusage is dirty */ |
1491 | segbuf->sb_fseg_start); | ||
1492 | nilfs_sufile_put_segment_usage(sufile, segbuf->sb_segnum, bh_su); | ||
1493 | 1484 | ||
1494 | list_for_each_entry_continue(segbuf, &sci->sc_segbufs, sb_list) { | 1485 | list_for_each_entry_continue(segbuf, &sci->sc_segbufs, sb_list) { |
1495 | ret = nilfs_sufile_get_segment_usage(sufile, segbuf->sb_segnum, | 1486 | ret = nilfs_sufile_set_segment_usage(sufile, segbuf->sb_segnum, |
1496 | &raw_su, &bh_su); | 1487 | 0, 0); |
1497 | WARN_ON(ret); /* always succeed */ | 1488 | WARN_ON(ret); /* always succeed */ |
1498 | raw_su->su_nblocks = 0; | ||
1499 | nilfs_sufile_put_segment_usage(sufile, segbuf->sb_segnum, | ||
1500 | bh_su); | ||
1501 | } | 1489 | } |
1502 | } | 1490 | } |
1503 | 1491 | ||