aboutsummaryrefslogtreecommitdiff
path: root/fs/f2fs/file.c
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2013-12-27 12:28:59 +0900
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2014-01-06 16:42:19 +0900
commit9e09fc855dd6f6ed510b3db7f3c3c1dd73631ac7 (patch)
tree85c3dddd41255d4ba8d83583f0550b1693338209 /fs/f2fs/file.c
parent26f466f4a948ddc765f9b474ad6e0bdb94fb1a66 (diff)
f2fs: refactor f2fs_convert_inline_data
Change log from v1: o handle NULL pointer of grab_cache_page_write_begin() pointed by Chao Yu. This patch refactors f2fs_convert_inline_data to check a couple of conditions internally for deciding whether it needs to convert inline_data or not. So, the new f2fs_convert_inline_data initially checks: 1) f2fs_has_inline_data(), and 2) the data size to be changed. If the inode has inline_data but the size to fill is less than MAX_INLINE_DATA, then we don't need to convert the inline_data with data allocation. Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r--fs/f2fs/file.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index f64a1c8291a..68dd7bfce1a 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -370,17 +370,12 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
if ((attr->ia_valid & ATTR_SIZE) &&
attr->ia_size != i_size_read(inode)) {
- if (f2fs_has_inline_data(inode) &&
- (attr->ia_size > MAX_INLINE_DATA)) {
- unsigned flags = AOP_FLAG_NOFS;
- err = f2fs_convert_inline_data(inode, NULL, flags);
- if (err)
- return err;
- }
+ err = f2fs_convert_inline_data(inode, attr->ia_size);
+ if (err)
+ return err;
truncate_setsize(inode, attr->ia_size);
- if (!f2fs_has_inline_data(inode))
- f2fs_truncate(inode);
+ f2fs_truncate(inode);
f2fs_balance_fs(F2FS_SB(inode->i_sb));
}
@@ -462,7 +457,7 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
loff_t off_start, off_end;
int ret = 0;
- ret = f2fs_convert_inline_data(inode, NULL, AOP_FLAG_NOFS);
+ ret = f2fs_convert_inline_data(inode, MAX_INLINE_DATA + 1);
if (ret)
return ret;
@@ -512,16 +507,14 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
loff_t off_start, off_end;
int ret = 0;
- if (f2fs_has_inline_data(inode) && (offset + len > MAX_INLINE_DATA)) {
- ret = f2fs_convert_inline_data(inode, NULL, AOP_FLAG_NOFS);
- if (ret)
- return ret;
- }
-
ret = inode_newsize_ok(inode, (len + offset));
if (ret)
return ret;
+ ret = f2fs_convert_inline_data(inode, offset + len);
+ if (ret)
+ return ret;
+
pg_start = ((unsigned long long) offset) >> PAGE_CACHE_SHIFT;
pg_end = ((unsigned long long) offset + len) >> PAGE_CACHE_SHIFT;