aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorGu Zheng <guz.fnst@cn.fujitsu.com>2013-12-26 05:24:19 -0500
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-12-26 06:37:52 -0500
commit0d47c1adc2a1f1e4f4673f122a8328c90c58e232 (patch)
tree21ee9e706d01f10b633036a5eea4522c509c43fc /fs/f2fs
parent944fcfc18445b22d7ad1953a6effcfbdc4ffec74 (diff)
f2fs: convert max_orphans to a field of f2fs_sb_info
Previously, we need to calculate the max orphan num when we try to acquire an orphan inode, but it's a stable value since the super block was inited. So converting it to a field of f2fs_sb_info and use it directly when needed seems a better choose. Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/checkpoint.c20
-rw-r--r--fs/f2fs/f2fs.h1
2 files changed, 11 insertions, 10 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 2fc3b6beaeb8..0d78bbe79f98 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -194,23 +194,15 @@ const struct address_space_operations f2fs_meta_aops = {
194 194
195int acquire_orphan_inode(struct f2fs_sb_info *sbi) 195int acquire_orphan_inode(struct f2fs_sb_info *sbi)
196{ 196{
197 unsigned int max_orphans;
198 int err = 0; 197 int err = 0;
199 198
200 /*
201 * considering 512 blocks in a segment 8 blocks are needed for cp
202 * and log segment summaries. Remaining blocks are used to keep
203 * orphan entries with the limitation one reserved segment
204 * for cp pack we can have max 1020*504 orphan entries
205 */
206 max_orphans = (sbi->blocks_per_seg - 2 - NR_CURSEG_TYPE)
207 * F2FS_ORPHANS_PER_BLOCK;
208 mutex_lock(&sbi->orphan_inode_mutex); 199 mutex_lock(&sbi->orphan_inode_mutex);
209 if (unlikely(sbi->n_orphans >= max_orphans)) 200 if (unlikely(sbi->n_orphans >= sbi->max_orphans))
210 err = -ENOSPC; 201 err = -ENOSPC;
211 else 202 else
212 sbi->n_orphans++; 203 sbi->n_orphans++;
213 mutex_unlock(&sbi->orphan_inode_mutex); 204 mutex_unlock(&sbi->orphan_inode_mutex);
205
214 return err; 206 return err;
215} 207}
216 208
@@ -834,6 +826,14 @@ void init_orphan_info(struct f2fs_sb_info *sbi)
834 mutex_init(&sbi->orphan_inode_mutex); 826 mutex_init(&sbi->orphan_inode_mutex);
835 INIT_LIST_HEAD(&sbi->orphan_inode_list); 827 INIT_LIST_HEAD(&sbi->orphan_inode_list);
836 sbi->n_orphans = 0; 828 sbi->n_orphans = 0;
829 /*
830 * considering 512 blocks in a segment 8 blocks are needed for cp
831 * and log segment summaries. Remaining blocks are used to keep
832 * orphan entries with the limitation one reserved segment
833 * for cp pack we can have max 1020*504 orphan entries
834 */
835 sbi->max_orphans = (sbi->blocks_per_seg - 2 - NR_CURSEG_TYPE)
836 * F2FS_ORPHANS_PER_BLOCK;
837} 837}
838 838
839int __init create_checkpoint_caches(void) 839int __init create_checkpoint_caches(void)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 1a06f0aaa7d9..36211cb16263 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -414,6 +414,7 @@ struct f2fs_sb_info {
414 struct list_head orphan_inode_list; /* orphan inode list */ 414 struct list_head orphan_inode_list; /* orphan inode list */
415 struct mutex orphan_inode_mutex; /* for orphan inode list */ 415 struct mutex orphan_inode_mutex; /* for orphan inode list */
416 unsigned int n_orphans; /* # of orphan inodes */ 416 unsigned int n_orphans; /* # of orphan inodes */
417 unsigned int max_orphans; /* max orphan inodes */
417 418
418 /* for directory inode management */ 419 /* for directory inode management */
419 struct list_head dir_inode_list; /* dir inode list */ 420 struct list_head dir_inode_list; /* dir inode list */