f2fs_balance_fs(sbi);
repeat:
+ err = f2fs_convert_inline_data(inode, pos + len);
+ if (err)
+ return err;
+
page = grab_cache_page_write_begin(mapping, index, flags);
if (!page)
return -ENOMEM;
*pagep = page;
- if ((pos + len) < MAX_INLINE_DATA) {
- if (f2fs_has_inline_data(inode))
- goto inline_data;
- } else if (f2fs_has_inline_data(inode)) {
- err = f2fs_convert_inline_data(inode, page, flags);
- if (err) {
- f2fs_put_page(page, 1);
- return err;
- }
- }
+ if (f2fs_has_inline_data(inode) && (pos + len) <= MAX_INLINE_DATA)
+ goto inline_data;
f2fs_lock_op(sbi);
set_new_dnode(&dn, inode, NULL, NULL, 0);
inline int f2fs_has_inline_data(struct inode *);
bool f2fs_may_inline(struct inode *);
int f2fs_read_inline_data(struct inode *, struct page *);
-int f2fs_convert_inline_data(struct inode *, struct page *, unsigned);
+int f2fs_convert_inline_data(struct inode *, pgoff_t);
int f2fs_write_inline_data(struct inode *, struct page *, unsigned int);
#endif
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));
}
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;
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;
dst_addr = kmap(page);
memcpy(dst_addr, src_addr, MAX_INLINE_DATA);
kunmap(page);
+ SetPageUptodate(page);
/* write data page to try to make data consistent */
set_page_writeback(page);
return err;
}
-int f2fs_convert_inline_data(struct inode *inode,
- struct page *p, unsigned flags)
+int f2fs_convert_inline_data(struct inode *inode, pgoff_t to_size)
{
- int err;
struct page *page;
+ int err;
- if (!p || p->index) {
- page = grab_cache_page_write_begin(inode->i_mapping, 0, flags);
- if (IS_ERR(page))
- return PTR_ERR(page);
- } else {
- page = p;
- }
-
- err = __f2fs_convert_inline_data(inode, page);
+ if (!f2fs_has_inline_data(inode))
+ return 0;
+ else if (to_size <= MAX_INLINE_DATA)
+ return 0;
- if (!p || p->index)
- f2fs_put_page(page, 1);
+ page = grab_cache_page_write_begin(inode->i_mapping, 0, AOP_FLAG_NOFS);
+ if (!page)
+ return -ENOMEM;
+ err = __f2fs_convert_inline_data(inode, page);
+ f2fs_put_page(page, 1);
return err;
}