* [PATCH] f2fs: add new wraper function for reading inline data
@ 2016-02-19 2:50 Shawn Lin
2016-02-19 7:35 ` Chao Yu
0 siblings, 1 reply; 4+ messages in thread
From: Shawn Lin @ 2016-02-19 2:50 UTC (permalink / raw)
To: Jaegeuk Kim, Changman Lee
Cc: Chao Yu, linux-f2fs-devel, linux-kernel, Shawn Lin
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 <shawn.lin@rock-chips.com>
---
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;
- 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] f2fs: add new wraper function for reading inline data
2016-02-19 2:50 [PATCH] f2fs: add new wraper function for reading inline data Shawn Lin
@ 2016-02-19 7:35 ` Chao Yu
0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2016-02-19 7:35 UTC (permalink / raw)
To: 'Shawn Lin', 'Jaegeuk Kim',
'Changman Lee'
Cc: linux-kernel, linux-f2fs-devel
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 <shawn.lin@rock-chips.com>
> ---
>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] f2fs: add new wraper function for reading inline data
@ 2016-02-19 7:35 ` Chao Yu
0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2016-02-19 7:35 UTC (permalink / raw)
To: 'Shawn Lin', 'Jaegeuk Kim',
'Changman Lee'
Cc: linux-f2fs-devel, linux-kernel
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 <shawn.lin@rock-chips.com>
> ---
>
> 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] f2fs: add new wraper function for reading inline data
2016-02-19 7:35 ` Chao Yu
(?)
@ 2016-02-19 7:46 ` Shawn Lin
-1 siblings, 0 replies; 4+ messages in thread
From: Shawn Lin @ 2016-02-19 7:46 UTC (permalink / raw)
To: Chao Yu, 'Jaegeuk Kim', 'Changman Lee'
Cc: shawn.lin, shawn.lin, linux-f2fs-devel, linux-kernel
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 <shawn.lin@rock-chips.com>
>> ---
>>
>> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-19 7:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-19 2:50 [PATCH] f2fs: add new wraper function for reading inline data Shawn Lin
2016-02-19 7:35 ` Chao Yu
2016-02-19 7:35 ` Chao Yu
2016-02-19 7:46 ` Shawn Lin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.