From 9e09fc855dd6f6ed510b3db7f3c3c1dd73631ac7 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Fri, 27 Dec 2013 12:28:59 +0900 Subject: 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 --- fs/f2fs/inline.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'fs/f2fs/inline.c') diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index 62c72aa84acc..e8891aa3ab8c 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -101,6 +101,7 @@ static int __f2fs_convert_inline_data(struct inode *inode, struct page *page) 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); @@ -120,25 +121,22 @@ static int __f2fs_convert_inline_data(struct inode *inode, struct page *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; } -- cgit v1.2.2