aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/sufile.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-11-18 04:23:34 -0500
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-11-19 20:05:51 -0500
commit071ec54dd730307ee0e703a105872b9a1c6fd2aa (patch)
treefb6629e471adf24d432487e0641549fd38d20ef3 /fs/nilfs2/sufile.c
parent61a189e9c62359cd12b2aa3bd6ab9cffa6cf2745 (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/sufile.c')
-rw-r--r--fs/nilfs2/sufile.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c
index d560f882a868..3eed998df1c8 100644
--- a/fs/nilfs2/sufile.c
+++ b/fs/nilfs2/sufile.c
@@ -521,6 +521,43 @@ int nilfs_sufile_mark_dirty(struct inode *sufile, __u64 segnum)
521} 521}
522 522
523/** 523/**
524 * nilfs_sufile_set_segment_usage - set usage of a segment
525 * @sufile: inode of segment usage file
526 * @segnum: segment number
527 * @nblocks: number of live blocks in the segment
528 * @modtime: modification time (option)
529 */
530int nilfs_sufile_set_segment_usage(struct inode *sufile, __u64 segnum,
531 unsigned long nblocks, time_t modtime)
532{
533 struct buffer_head *bh;
534 struct nilfs_segment_usage *su;
535 void *kaddr;
536 int ret;
537
538 down_write(&NILFS_MDT(sufile)->mi_sem);
539 ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 0, &bh);
540 if (ret < 0)
541 goto out_sem;
542
543 kaddr = kmap_atomic(bh->b_page, KM_USER0);
544 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, bh, kaddr);
545 WARN_ON(nilfs_segment_usage_error(su));
546 if (modtime)
547 su->su_lastmod = cpu_to_le64(modtime);
548 su->su_nblocks = cpu_to_le32(nblocks);
549 kunmap_atomic(kaddr, KM_USER0);
550
551 nilfs_mdt_mark_buffer_dirty(bh);
552 nilfs_mdt_mark_dirty(sufile);
553 brelse(bh);
554
555 out_sem:
556 up_write(&NILFS_MDT(sufile)->mi_sem);
557 return ret;
558}
559
560/**
524 * nilfs_sufile_get_stat - get segment usage statistics 561 * nilfs_sufile_get_stat - get segment usage statistics
525 * @sufile: inode of segment usage file 562 * @sufile: inode of segment usage file
526 * @stat: pointer to a structure of segment usage statistics 563 * @stat: pointer to a structure of segment usage statistics