From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chao Yu Subject: Re: [PATCH] f2fs: add new wraper function for reading inline data Date: Fri, 19 Feb 2016 15:35:18 +0800 Message-ID: <01ce01d16ae8$32023f20$9606bd60$@samsung.com> References: <1455850210-31439-1-git-send-email-shawn.lin@rock-chips.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aWfbr-000838-AV for linux-f2fs-devel@lists.sourceforge.net; Fri, 19 Feb 2016 07:36:15 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1aWfbp-0005PL-A8 for linux-f2fs-devel@lists.sourceforge.net; Fri, 19 Feb 2016 07:36:15 +0000 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O2S034V4AFX2L00@mailout1.samsung.com> for linux-f2fs-devel@lists.sourceforge.net; Fri, 19 Feb 2016 16:36:05 +0900 (KST) In-reply-to: <1455850210-31439-1-git-send-email-shawn.lin@rock-chips.com> Content-language: zh-cn List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: 'Shawn Lin' , 'Jaegeuk Kim' , 'Changman Lee' Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net 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? 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 > ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1425825AbcBSHgJ (ORCPT ); Fri, 19 Feb 2016 02:36:09 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:35552 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757189AbcBSHgH (ORCPT ); Fri, 19 Feb 2016 02:36:07 -0500 X-AuditID: cbfee61b-f793c6d00000236c-2c-56c6c5e579fe From: Chao Yu To: "'Shawn Lin'" , "'Jaegeuk Kim'" , "'Changman Lee'" Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <1455850210-31439-1-git-send-email-shawn.lin@rock-chips.com> In-reply-to: <1455850210-31439-1-git-send-email-shawn.lin@rock-chips.com> Subject: RE: [PATCH] f2fs: add new wraper function for reading inline data Date: Fri, 19 Feb 2016 15:35:18 +0800 Message-id: <01ce01d16ae8$32023f20$9606bd60$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AQKiVShNRbj1vlnj3OpkuvT1SB69iZ2RIVFg Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRmVeSWpSXmKPExsVy+t9jAd2nR4+FGXy+K2hxbV8jk8WT9bOY LS4tcre4vGsOm8WdJ+tZHVg9Nq3qZPPYveAzk8ffWftZPPq2rGL0+LxJLoA1issmJTUnsyy1 SN8ugSvjyMpJrAWHRSoOf1jF0sB4S6CLkZNDQsBE4uDeW4wQtpjEhXvr2boYuTiEBJYySlyd cg3KecUo0dXXwgZSxSagIrG84z8TiC0iUCGxv6OVBcRmFvCQaOz4zgpiCwHZP/9dYgaxOQU8 JfadOMQOYgsLeEk86O4Fq2cRUJWYuuwd2ExeAUuJfR1LmCFsQYkfk+9BzdSS2LytiRXClpfY vOYtM8SlChI7zr5mhLjBSOLYhhuMEDXiEhuP3GKZwCg0C8moWUhGzUIyahaSlgWMLKsYJVIL kguKk9JzjfJSy/WKE3OLS/PS9ZLzczcxguPjmfQOxsO73A8xCnAwKvHwVugdCxNiTSwrrsw9 xCjBwawkwqvrDxTiTUmsrEotyo8vKs1JLT7EKM3BoiTO+/j/ujAhgfTEktTs1NSC1CKYLBMH p1QDI9e/9hPJscs/aNocrK7cz+R5TiFWf5npsoqFT44whkpfbOy5fL9O49Gh5XtcOrJyFy4p sfvz/8E1cRXRQIHCBOcfO8sZmIp+fL0y99gLiwV5YjNX67AeEQ04oX4qfMP8F1MsY3bMfbJq heX3/0//fFzuetXkx+kDQj/Uo55JbjKc6vnhr8DjOBUlluKMREMt5qLiRAD2YrqxiwIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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 >