From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756908AbcBSHrK (ORCPT ); Fri, 19 Feb 2016 02:47:10 -0500 Received: from lucky1.263xmail.com ([211.157.147.133]:49258 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750746AbcBSHrI (ORCPT ); Fri, 19 Feb 2016 02:47:08 -0500 X-263anti-spam: bpcheck:1; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-ADDR-CHECKED: 0 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <3b5148ad11f93dbc15dc88feb6e30375> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Subject: Re: [PATCH] f2fs: add new wraper function for reading inline data To: Chao Yu , "'Jaegeuk Kim'" , "'Changman Lee'" References: <1455850210-31439-1-git-send-email-shawn.lin@rock-chips.com> <01ce01d16ae8$32023f20$9606bd60$@samsung.com> Cc: shawn.lin@rock-chips.com, shawn.lin@kernel-upstream.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org From: Shawn Lin Message-ID: <56C6C871.50605@rock-chips.com> Date: Fri, 19 Feb 2016 15:46:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <01ce01d16ae8$32023f20$9606bd60$@samsung.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/2/19 15:35, Chao Yu wrote: > Hi Shawn, > >> -----Original Message----- >> From: Shawn Lin [mailto:shawn.lin@rock-chips.com] >> Sent: Friday, February 19, 2016 10:50 AM >> To: Jaegeuk Kim; Changman Lee >> Cc: Chao Yu; linux-f2fs-devel@lists.sourceforge.net; linux-kernel@vger.kernel.org; Shawn Lin >> Subject: [PATCH] f2fs: add new wraper function for reading inline data >> >> This patch add __read_inline_data which will no check >> PageUptodate and page->index. This can be reused by >> f2fs_convert_inline_page to reduce the redundant code >> copied from read_inline_data. >> >> Signed-off-by: Shawn Lin >> --- >> >> fs/f2fs/inline.c | 26 ++++++++++++-------------- >> 1 file changed, 12 insertions(+), 14 deletions(-) >> >> diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c >> index d27347e..39eeff1 100644 >> --- a/fs/f2fs/inline.c >> +++ b/fs/f2fs/inline.c >> @@ -42,15 +42,11 @@ bool f2fs_may_inline_dentry(struct inode *inode) >> return true; >> } >> >> -void read_inline_data(struct page *page, struct page *ipage) >> +static inline void __read_inline_data(struct page *page, >> + struct page *ipage) >> { >> void *src_addr, *dst_addr; >> >> - if (PageUptodate(page)) >> - return; >> - >> - f2fs_bug_on(F2FS_P_SB(page), page->index); >> - >> zero_user_segment(page, MAX_INLINE_DATA, PAGE_CACHE_SIZE); >> >> /* Copy the whole inline data block */ >> @@ -61,6 +57,15 @@ void read_inline_data(struct page *page, struct page *ipage) >> kunmap_atomic(dst_addr); >> SetPageUptodate(page); >> } >> +void read_inline_data(struct page *page, struct page *ipage) >> +{ >> + if (PageUptodate(page)) >> + return; >> + >> + f2fs_bug_on(F2FS_P_SB(page), page->index); >> + >> + __read_inline_data(page, ipage); >> +} >> >> bool truncate_inline_inode(struct page *ipage, u64 from) >> { >> @@ -128,15 +133,8 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page) >> if (PageUptodate(page)) >> goto no_update; > > Seems we can remove above check and below 'no_update' tag completely > if we use read_inline_data here. > > So what about using read_inline_data to clean up codes in > f2fs_convert_inline_page? yep, it does make sense. I will respin v2 to the list later. Thanks for sharing your thought. > > Thanks, > >> >> - zero_user_segment(page, MAX_INLINE_DATA, PAGE_CACHE_SIZE); >> + __read_inline_data(page, dn->inode_page); >> >> - /* Copy the whole inline data block */ >> - src_addr = inline_data_addr(dn->inode_page); >> - dst_addr = kmap_atomic(page); >> - memcpy(dst_addr, src_addr, MAX_INLINE_DATA); >> - flush_dcache_page(page); >> - kunmap_atomic(dst_addr); >> - SetPageUptodate(page); >> no_update: >> set_page_dirty(page); >> >> -- >> 2.3.7 >> > > > > > -- Best Regards Shawn Lin