aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-11-12 18:45:32 -0500
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-11-19 20:05:49 -0500
commitef7d4757a5b7b07a3a0d30d3ba6b587e574b28b9 (patch)
tree5f1f1cad0c9bb755cd332017f66fe502d1286a94
parentaa474a220180d997caafcee372770d6ed6bf798a (diff)
nilfs2: simplify nilfs_sufile_get_ncleansegs function
Previously, this function took an status code to return possible error codes. The ("nilfs2: add local variable to cache the number of clean segments") patch removed the possibility to return errors. So, this simplifies the function definition to make it directly return the number of clean segments. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
-rw-r--r--fs/nilfs2/sufile.c31
-rw-r--r--fs/nilfs2/sufile.h3
-rw-r--r--fs/nilfs2/the_nilfs.c23
3 files changed, 19 insertions, 38 deletions
diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c
index e9b4cec0d3ef..5f18acab9dd4 100644
--- a/fs/nilfs2/sufile.c
+++ b/fs/nilfs2/sufile.c
@@ -112,6 +112,15 @@ static void nilfs_sufile_mod_counter(struct buffer_head *header_bh,
112} 112}
113 113
114/** 114/**
115 * nilfs_sufile_get_ncleansegs - return the number of clean segments
116 * @sufile: inode of segment usage file
117 */
118unsigned long nilfs_sufile_get_ncleansegs(struct inode *sufile)
119{
120 return NILFS_SUI(sufile)->ncleansegs;
121}
122
123/**
115 * nilfs_sufile_updatev - modify multiple segment usages at a time 124 * nilfs_sufile_updatev - modify multiple segment usages at a time
116 * @sufile: inode of segment usage file 125 * @sufile: inode of segment usage file
117 * @segnumv: array of segment numbers 126 * @segnumv: array of segment numbers
@@ -540,28 +549,6 @@ int nilfs_sufile_get_stat(struct inode *sufile, struct nilfs_sustat *sustat)
540 return ret; 549 return ret;
541} 550}
542 551
543/**
544 * nilfs_sufile_get_ncleansegs - get the number of clean segments
545 * @sufile: inode of segment usage file
546 * @nsegsp: pointer to the number of clean segments
547 *
548 * Description: nilfs_sufile_get_ncleansegs() acquires the number of clean
549 * segments.
550 *
551 * Return Value: On success, 0 is returned and the number of clean segments is
552 * stored in the place pointed by @nsegsp. On error, one of the following
553 * negative error codes is returned.
554 *
555 * %-EIO - I/O error.
556 *
557 * %-ENOMEM - Insufficient amount of memory available.
558 */
559int nilfs_sufile_get_ncleansegs(struct inode *sufile, unsigned long *nsegsp)
560{
561 *nsegsp = NILFS_SUI(sufile)->ncleansegs;
562 return 0;
563}
564
565void nilfs_sufile_do_set_error(struct inode *sufile, __u64 segnum, 552void nilfs_sufile_do_set_error(struct inode *sufile, __u64 segnum,
566 struct buffer_head *header_bh, 553 struct buffer_head *header_bh,
567 struct buffer_head *su_bh) 554 struct buffer_head *su_bh)
diff --git a/fs/nilfs2/sufile.h b/fs/nilfs2/sufile.h
index b303a80ac3b1..c339ad5b5326 100644
--- a/fs/nilfs2/sufile.h
+++ b/fs/nilfs2/sufile.h
@@ -34,6 +34,8 @@ static inline unsigned long nilfs_sufile_get_nsegments(struct inode *sufile)
34 return NILFS_MDT(sufile)->mi_nilfs->ns_nsegments; 34 return NILFS_MDT(sufile)->mi_nilfs->ns_nsegments;
35} 35}
36 36
37unsigned long nilfs_sufile_get_ncleansegs(struct inode *sufile);
38
37int nilfs_sufile_alloc(struct inode *, __u64 *); 39int nilfs_sufile_alloc(struct inode *, __u64 *);
38int nilfs_sufile_get_segment_usage(struct inode *, __u64, 40int nilfs_sufile_get_segment_usage(struct inode *, __u64,
39 struct nilfs_segment_usage **, 41 struct nilfs_segment_usage **,
@@ -41,7 +43,6 @@ int nilfs_sufile_get_segment_usage(struct inode *, __u64,
41void nilfs_sufile_put_segment_usage(struct inode *, __u64, 43void nilfs_sufile_put_segment_usage(struct inode *, __u64,
42 struct buffer_head *); 44 struct buffer_head *);
43int nilfs_sufile_get_stat(struct inode *, struct nilfs_sustat *); 45int nilfs_sufile_get_stat(struct inode *, struct nilfs_sustat *);
44int nilfs_sufile_get_ncleansegs(struct inode *, unsigned long *);
45ssize_t nilfs_sufile_get_suinfo(struct inode *, __u64, void *, unsigned, 46ssize_t nilfs_sufile_get_suinfo(struct inode *, __u64, void *, unsigned,
46 size_t); 47 size_t);
47 48
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 75095edec2fc..4d4d35c6fbef 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -612,30 +612,23 @@ int nilfs_count_free_blocks(struct the_nilfs *nilfs, sector_t *nblocks)
612{ 612{
613 struct inode *dat = nilfs_dat_inode(nilfs); 613 struct inode *dat = nilfs_dat_inode(nilfs);
614 unsigned long ncleansegs; 614 unsigned long ncleansegs;
615 int err;
616 615
617 down_read(&NILFS_MDT(dat)->mi_sem); /* XXX */ 616 down_read(&NILFS_MDT(dat)->mi_sem); /* XXX */
618 err = nilfs_sufile_get_ncleansegs(nilfs->ns_sufile, &ncleansegs); 617 ncleansegs = nilfs_sufile_get_ncleansegs(nilfs->ns_sufile);
619 up_read(&NILFS_MDT(dat)->mi_sem); /* XXX */ 618 up_read(&NILFS_MDT(dat)->mi_sem); /* XXX */
620 if (likely(!err)) 619 *nblocks = (sector_t)ncleansegs * nilfs->ns_blocks_per_segment;
621 *nblocks = (sector_t)ncleansegs * nilfs->ns_blocks_per_segment; 620 return 0;
622 return err;
623} 621}
624 622
625int nilfs_near_disk_full(struct the_nilfs *nilfs) 623int nilfs_near_disk_full(struct the_nilfs *nilfs)
626{ 624{
627 struct inode *sufile = nilfs->ns_sufile;
628 unsigned long ncleansegs, nincsegs; 625 unsigned long ncleansegs, nincsegs;
629 int ret;
630 626
631 ret = nilfs_sufile_get_ncleansegs(sufile, &ncleansegs); 627 ncleansegs = nilfs_sufile_get_ncleansegs(nilfs->ns_sufile);
632 if (likely(!ret)) { 628 nincsegs = atomic_read(&nilfs->ns_ndirtyblks) /
633 nincsegs = atomic_read(&nilfs->ns_ndirtyblks) / 629 nilfs->ns_blocks_per_segment + 1;
634 nilfs->ns_blocks_per_segment + 1; 630
635 if (ncleansegs <= nilfs->ns_nrsvsegs + nincsegs) 631 return ncleansegs <= nilfs->ns_nrsvsegs + nincsegs;
636 ret++;
637 }
638 return ret;
639} 632}
640 633
641/** 634/**