Commit b9d777b8 authored by Jaegeuk Kim's avatar Jaegeuk Kim
Browse files

f2fs: check inline_data flag at converting time



We can check inode's inline_data flag  when calling to convert it.
Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 74fd8d99
...@@ -1573,11 +1573,9 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter, ...@@ -1573,11 +1573,9 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
int err; int err;
/* we don't need to use inline_data strictly */ /* we don't need to use inline_data strictly */
if (f2fs_has_inline_data(inode)) { err = f2fs_convert_inline_inode(inode);
err = f2fs_convert_inline_inode(inode); if (err)
if (err) return err;
return err;
}
if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode))
return 0; return 0;
......
...@@ -418,19 +418,18 @@ static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence) ...@@ -418,19 +418,18 @@ static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma) static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
{ {
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
int err;
if (f2fs_encrypted_inode(inode)) { if (f2fs_encrypted_inode(inode)) {
int err = f2fs_get_encryption_info(inode); err = f2fs_get_encryption_info(inode);
if (err) if (err)
return 0; return 0;
} }
/* we don't need to use inline_data strictly */ /* we don't need to use inline_data strictly */
if (f2fs_has_inline_data(inode)) { err = f2fs_convert_inline_inode(inode);
int err = f2fs_convert_inline_inode(inode); if (err)
if (err) return err;
return err;
}
file_accessed(file); file_accessed(file);
vma->vm_ops = &f2fs_file_vm_ops; vma->vm_ops = &f2fs_file_vm_ops;
...@@ -604,7 +603,7 @@ int f2fs_truncate(struct inode *inode, bool lock) ...@@ -604,7 +603,7 @@ int f2fs_truncate(struct inode *inode, bool lock)
trace_f2fs_truncate(inode); trace_f2fs_truncate(inode);
/* we should check inline_data size */ /* we should check inline_data size */
if (f2fs_has_inline_data(inode) && !f2fs_may_inline_data(inode)) { if (!f2fs_may_inline_data(inode)) {
err = f2fs_convert_inline_inode(inode); err = f2fs_convert_inline_inode(inode);
if (err) if (err)
return err; return err;
...@@ -688,8 +687,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -688,8 +687,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
truncate_setsize(inode, attr->ia_size); truncate_setsize(inode, attr->ia_size);
/* should convert inline inode here */ /* should convert inline inode here */
if (f2fs_has_inline_data(inode) && if (!f2fs_may_inline_data(inode)) {
!f2fs_may_inline_data(inode)) {
err = f2fs_convert_inline_inode(inode); err = f2fs_convert_inline_inode(inode);
if (err) if (err)
return err; return err;
...@@ -786,13 +784,11 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len) ...@@ -786,13 +784,11 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
{ {
pgoff_t pg_start, pg_end; pgoff_t pg_start, pg_end;
loff_t off_start, off_end; loff_t off_start, off_end;
int ret = 0; int ret;
if (f2fs_has_inline_data(inode)) { ret = f2fs_convert_inline_inode(inode);
ret = f2fs_convert_inline_inode(inode); if (ret)
if (ret) return ret;
return ret;
}
pg_start = ((unsigned long long) offset) >> PAGE_CACHE_SHIFT; pg_start = ((unsigned long long) offset) >> PAGE_CACHE_SHIFT;
pg_end = ((unsigned long long) offset + len) >> PAGE_CACHE_SHIFT; pg_end = ((unsigned long long) offset + len) >> PAGE_CACHE_SHIFT;
...@@ -951,11 +947,9 @@ static int f2fs_collapse_range(struct inode *inode, loff_t offset, loff_t len) ...@@ -951,11 +947,9 @@ static int f2fs_collapse_range(struct inode *inode, loff_t offset, loff_t len)
f2fs_balance_fs(F2FS_I_SB(inode)); f2fs_balance_fs(F2FS_I_SB(inode));
if (f2fs_has_inline_data(inode)) { ret = f2fs_convert_inline_inode(inode);
ret = f2fs_convert_inline_inode(inode); if (ret)
if (ret) return ret;
return ret;
}
pg_start = offset >> PAGE_CACHE_SHIFT; pg_start = offset >> PAGE_CACHE_SHIFT;
pg_end = (offset + len) >> PAGE_CACHE_SHIFT; pg_end = (offset + len) >> PAGE_CACHE_SHIFT;
...@@ -1001,11 +995,9 @@ static int f2fs_zero_range(struct inode *inode, loff_t offset, loff_t len, ...@@ -1001,11 +995,9 @@ static int f2fs_zero_range(struct inode *inode, loff_t offset, loff_t len,
f2fs_balance_fs(sbi); f2fs_balance_fs(sbi);
if (f2fs_has_inline_data(inode)) { ret = f2fs_convert_inline_inode(inode);
ret = f2fs_convert_inline_inode(inode); if (ret)
if (ret) return ret;
return ret;
}
ret = filemap_write_and_wait_range(mapping, offset, offset + len - 1); ret = filemap_write_and_wait_range(mapping, offset, offset + len - 1);
if (ret) if (ret)
...@@ -1114,11 +1106,9 @@ static int f2fs_insert_range(struct inode *inode, loff_t offset, loff_t len) ...@@ -1114,11 +1106,9 @@ static int f2fs_insert_range(struct inode *inode, loff_t offset, loff_t len)
f2fs_balance_fs(sbi); f2fs_balance_fs(sbi);
if (f2fs_has_inline_data(inode)) { ret = f2fs_convert_inline_inode(inode);
ret = f2fs_convert_inline_inode(inode); if (ret)
if (ret) return ret;
return ret;
}
ret = truncate_blocks(inode, i_size_read(inode), true); ret = truncate_blocks(inode, i_size_read(inode), true);
if (ret) if (ret)
...@@ -1168,11 +1158,9 @@ static int expand_inode_data(struct inode *inode, loff_t offset, ...@@ -1168,11 +1158,9 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
if (ret) if (ret)
return ret; return ret;
if (f2fs_has_inline_data(inode)) { ret = f2fs_convert_inline_inode(inode);
ret = f2fs_convert_inline_inode(inode); if (ret)
if (ret) return ret;
return ret;
}
pg_start = ((unsigned long long) offset) >> PAGE_CACHE_SHIFT; pg_start = ((unsigned long long) offset) >> PAGE_CACHE_SHIFT;
pg_end = ((unsigned long long) offset + len) >> PAGE_CACHE_SHIFT; pg_end = ((unsigned long long) offset + len) >> PAGE_CACHE_SHIFT;
......
...@@ -177,6 +177,9 @@ int f2fs_convert_inline_inode(struct inode *inode) ...@@ -177,6 +177,9 @@ int f2fs_convert_inline_inode(struct inode *inode)
struct page *ipage, *page; struct page *ipage, *page;
int err = 0; int err = 0;
if (!f2fs_has_inline_data(inode))
return 0;
page = grab_cache_page(inode->i_mapping, 0); page = grab_cache_page(inode->i_mapping, 0);
if (!page) if (!page)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment