aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-12-31 01:35:37 -0500
committerJaegeuk Kim <jaegeuk@kernel.org>2016-01-04 00:40:04 -0500
commite0afc4d6d0d3e7e5a99f691bc64ae7c74bea790e (patch)
tree76cdea35b5c446a7b0137c1a4849f47d7d801e35
parent3a9e6433a367211a172cb7b4d5b727c720bd0de0 (diff)
f2fs: introduce max_file_blocks in sbi
Introduce max_file_blocks in sbi to store max block index of file in f2fs, it could be used to avoid unneeded calculation of max block index in runtime. Signed-off-by: Chao Yu <chao2.yu@samsung.com> [Jaegeuk Kim: fix overflow of sbi->max_file_blocks] Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/data.c2
-rw-r--r--fs/f2fs/f2fs.h2
-rw-r--r--fs/f2fs/super.c7
3 files changed, 6 insertions, 5 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 4851e84d0283..89a978c57da9 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -762,7 +762,7 @@ static int get_data_block_bmap(struct inode *inode, sector_t iblock,
762 struct buffer_head *bh_result, int create) 762 struct buffer_head *bh_result, int create)
763{ 763{
764 /* Block number less than F2FS MAX BLOCKS */ 764 /* Block number less than F2FS MAX BLOCKS */
765 if (unlikely(iblock >= max_file_size(0))) 765 if (unlikely(iblock >= F2FS_I_SB(inode)->max_file_blocks))
766 return -EFBIG; 766 return -EFBIG;
767 767
768 return __get_data_block(inode, iblock, bh_result, create, 768 return __get_data_block(inode, iblock, bh_result, create,
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e2990c978661..882babaa678e 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -783,6 +783,7 @@ struct f2fs_sb_info {
783 unsigned int total_node_count; /* total node block count */ 783 unsigned int total_node_count; /* total node block count */
784 unsigned int total_valid_node_count; /* valid node block count */ 784 unsigned int total_valid_node_count; /* valid node block count */
785 unsigned int total_valid_inode_count; /* valid inode count */ 785 unsigned int total_valid_inode_count; /* valid inode count */
786 loff_t max_file_blocks; /* max block index of file */
786 int active_logs; /* # of active logs */ 787 int active_logs; /* # of active logs */
787 int dir_level; /* directory level */ 788 int dir_level; /* directory level */
788 789
@@ -1727,7 +1728,6 @@ static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
1727 * super.c 1728 * super.c
1728 */ 1729 */
1729int f2fs_commit_super(struct f2fs_sb_info *, bool); 1730int f2fs_commit_super(struct f2fs_sb_info *, bool);
1730loff_t max_file_size(unsigned bits);
1731int f2fs_sync_fs(struct super_block *, int); 1731int f2fs_sync_fs(struct super_block *, int);
1732extern __printf(3, 4) 1732extern __printf(3, 4)
1733void f2fs_msg(struct super_block *, const char *, const char *, ...); 1733void f2fs_msg(struct super_block *, const char *, const char *, ...);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index a2e3a8f893ed..0bbd756821a7 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -907,7 +907,7 @@ static const struct export_operations f2fs_export_ops = {
907 .get_parent = f2fs_get_parent, 907 .get_parent = f2fs_get_parent,
908}; 908};
909 909
910loff_t max_file_size(unsigned bits) 910static loff_t max_file_blocks(void)
911{ 911{
912 loff_t result = (DEF_ADDRS_PER_INODE - F2FS_INLINE_XATTR_ADDRS); 912 loff_t result = (DEF_ADDRS_PER_INODE - F2FS_INLINE_XATTR_ADDRS);
913 loff_t leaf_count = ADDRS_PER_BLOCK; 913 loff_t leaf_count = ADDRS_PER_BLOCK;
@@ -923,7 +923,6 @@ loff_t max_file_size(unsigned bits)
923 leaf_count *= NIDS_PER_BLOCK; 923 leaf_count *= NIDS_PER_BLOCK;
924 result += leaf_count; 924 result += leaf_count;
925 925
926 result <<= bits;
927 return result; 926 return result;
928} 927}
929 928
@@ -1278,7 +1277,9 @@ try_onemore:
1278 if (err) 1277 if (err)
1279 goto free_options; 1278 goto free_options;
1280 1279
1281 sb->s_maxbytes = max_file_size(le32_to_cpu(raw_super->log_blocksize)); 1280 sbi->max_file_blocks = max_file_blocks();
1281 sb->s_maxbytes = sbi->max_file_blocks <<
1282 le32_to_cpu(raw_super->log_blocksize);
1282 sb->s_max_links = F2FS_LINK_MAX; 1283 sb->s_max_links = F2FS_LINK_MAX;
1283 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); 1284 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
1284 1285