All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/9] f2fs: avoid unneeded initializing when converting inline dentry
@ 2015-08-19 11:10 ` Chao Yu
  0 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2015-08-19 11:10 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel, linux-kernel

When converting inline dentry, we will zero out target dentry page before
duplicating data of inline dentry into target page, it become overhead
since inline dentry size is not small.

So this patch tries to remove unneeded initializing in the space of target
dentry page.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
 fs/f2fs/inline.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 79d18d5..e4da0d7 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -384,17 +384,30 @@ static int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage,
 		goto out;
 
 	f2fs_wait_on_page_writeback(page, DATA);
-	zero_user_segment(page, 0, PAGE_CACHE_SIZE);
+	zero_user_segment(page, MAX_INLINE_DATA, PAGE_CACHE_SIZE);
 
 	dentry_blk = kmap_atomic(page);
 
 	/* copy data from inline dentry block to new dentry block */
 	memcpy(dentry_blk->dentry_bitmap, inline_dentry->dentry_bitmap,
 					INLINE_DENTRY_BITMAP_SIZE);
+	memset(dentry_blk->dentry_bitmap + INLINE_DENTRY_BITMAP_SIZE, 0,
+			SIZE_OF_DENTRY_BITMAP - INLINE_DENTRY_BITMAP_SIZE);
+	/*
+	 * reserved space size of inline dentry is larger than the one of
+	 * regular dentry, here we just copy with the size of reserved space
+	 * in regular dentry.
+	 */
+	memcpy(dentry_blk->reserved, inline_dentry->reserved, SIZE_OF_RESERVED);
 	memcpy(dentry_blk->dentry, inline_dentry->dentry,
 			sizeof(struct f2fs_dir_entry) * NR_INLINE_DENTRY);
+	memset(dentry_blk->dentry + NR_INLINE_DENTRY, 0,
+			sizeof (struct f2fs_dir_entry) *
+			(NR_DENTRY_IN_BLOCK - NR_INLINE_DENTRY));
 	memcpy(dentry_blk->filename, inline_dentry->filename,
 					NR_INLINE_DENTRY * F2FS_SLOT_LEN);
+	memset(&dentry_blk->filename[NR_INLINE_DENTRY][0], 0,
+		F2FS_SLOT_LEN * (NR_DENTRY_IN_BLOCK - NR_INLINE_DENTRY));
 
 	kunmap_atomic(dentry_blk);
 	SetPageUptodate(page);
-- 
2.4.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/9] f2fs: avoid unneeded initializing when converting inline dentry
@ 2015-08-19 11:10 ` Chao Yu
  0 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2015-08-19 11:10 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel

When converting inline dentry, we will zero out target dentry page before
duplicating data of inline dentry into target page, it become overhead
since inline dentry size is not small.

So this patch tries to remove unneeded initializing in the space of target
dentry page.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
 fs/f2fs/inline.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 79d18d5..e4da0d7 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -384,17 +384,30 @@ static int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage,
 		goto out;
 
 	f2fs_wait_on_page_writeback(page, DATA);
-	zero_user_segment(page, 0, PAGE_CACHE_SIZE);
+	zero_user_segment(page, MAX_INLINE_DATA, PAGE_CACHE_SIZE);
 
 	dentry_blk = kmap_atomic(page);
 
 	/* copy data from inline dentry block to new dentry block */
 	memcpy(dentry_blk->dentry_bitmap, inline_dentry->dentry_bitmap,
 					INLINE_DENTRY_BITMAP_SIZE);
+	memset(dentry_blk->dentry_bitmap + INLINE_DENTRY_BITMAP_SIZE, 0,
+			SIZE_OF_DENTRY_BITMAP - INLINE_DENTRY_BITMAP_SIZE);
+	/*
+	 * reserved space size of inline dentry is larger than the one of
+	 * regular dentry, here we just copy with the size of reserved space
+	 * in regular dentry.
+	 */
+	memcpy(dentry_blk->reserved, inline_dentry->reserved, SIZE_OF_RESERVED);
 	memcpy(dentry_blk->dentry, inline_dentry->dentry,
 			sizeof(struct f2fs_dir_entry) * NR_INLINE_DENTRY);
+	memset(dentry_blk->dentry + NR_INLINE_DENTRY, 0,
+			sizeof (struct f2fs_dir_entry) *
+			(NR_DENTRY_IN_BLOCK - NR_INLINE_DENTRY));
 	memcpy(dentry_blk->filename, inline_dentry->filename,
 					NR_INLINE_DENTRY * F2FS_SLOT_LEN);
+	memset(&dentry_blk->filename[NR_INLINE_DENTRY][0], 0,
+		F2FS_SLOT_LEN * (NR_DENTRY_IN_BLOCK - NR_INLINE_DENTRY));
 
 	kunmap_atomic(dentry_blk);
 	SetPageUptodate(page);
-- 
2.4.2



------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/9] f2fs: avoid unneeded initializing when converting inline dentry
  2015-08-19 11:10 ` Chao Yu
@ 2015-08-20 17:17   ` Jaegeuk Kim
  -1 siblings, 0 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2015-08-20 17:17 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel, linux-kernel

Hi Chao,

On Wed, Aug 19, 2015 at 07:10:19PM +0800, Chao Yu wrote:
> When converting inline dentry, we will zero out target dentry page before
> duplicating data of inline dentry into target page, it become overhead
> since inline dentry size is not small.
> 
> So this patch tries to remove unneeded initializing in the space of target
> dentry page.
> 
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
>  fs/f2fs/inline.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> index 79d18d5..e4da0d7 100644
> --- a/fs/f2fs/inline.c
> +++ b/fs/f2fs/inline.c
> @@ -384,17 +384,30 @@ static int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage,
>  		goto out;
>  
>  	f2fs_wait_on_page_writeback(page, DATA);
> -	zero_user_segment(page, 0, PAGE_CACHE_SIZE);
> +	zero_user_segment(page, MAX_INLINE_DATA, PAGE_CACHE_SIZE);
>  
>  	dentry_blk = kmap_atomic(page);
>  
>  	/* copy data from inline dentry block to new dentry block */
>  	memcpy(dentry_blk->dentry_bitmap, inline_dentry->dentry_bitmap,
>  					INLINE_DENTRY_BITMAP_SIZE);
> +	memset(dentry_blk->dentry_bitmap + INLINE_DENTRY_BITMAP_SIZE, 0,
> +			SIZE_OF_DENTRY_BITMAP - INLINE_DENTRY_BITMAP_SIZE);

Setting zeros for bitmap would be enough.
It doesn't need to copy or set zeros for reserved, dentries, and filename slots.

Thanks,

> +	/*
> +	 * reserved space size of inline dentry is larger than the one of
> +	 * regular dentry, here we just copy with the size of reserved space
> +	 * in regular dentry.
> +	 */
> +	memcpy(dentry_blk->reserved, inline_dentry->reserved, SIZE_OF_RESERVED);
>  	memcpy(dentry_blk->dentry, inline_dentry->dentry,
>  			sizeof(struct f2fs_dir_entry) * NR_INLINE_DENTRY);
> +	memset(dentry_blk->dentry + NR_INLINE_DENTRY, 0,
> +			sizeof (struct f2fs_dir_entry) *
> +			(NR_DENTRY_IN_BLOCK - NR_INLINE_DENTRY));
>  	memcpy(dentry_blk->filename, inline_dentry->filename,
>  					NR_INLINE_DENTRY * F2FS_SLOT_LEN);
> +	memset(&dentry_blk->filename[NR_INLINE_DENTRY][0], 0,
> +		F2FS_SLOT_LEN * (NR_DENTRY_IN_BLOCK - NR_INLINE_DENTRY));
>  
>  	kunmap_atomic(dentry_blk);
>  	SetPageUptodate(page);
> -- 
> 2.4.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/9] f2fs: avoid unneeded initializing when converting inline dentry
@ 2015-08-20 17:17   ` Jaegeuk Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2015-08-20 17:17 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

Hi Chao,

On Wed, Aug 19, 2015 at 07:10:19PM +0800, Chao Yu wrote:
> When converting inline dentry, we will zero out target dentry page before
> duplicating data of inline dentry into target page, it become overhead
> since inline dentry size is not small.
> 
> So this patch tries to remove unneeded initializing in the space of target
> dentry page.
> 
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
>  fs/f2fs/inline.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> index 79d18d5..e4da0d7 100644
> --- a/fs/f2fs/inline.c
> +++ b/fs/f2fs/inline.c
> @@ -384,17 +384,30 @@ static int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage,
>  		goto out;
>  
>  	f2fs_wait_on_page_writeback(page, DATA);
> -	zero_user_segment(page, 0, PAGE_CACHE_SIZE);
> +	zero_user_segment(page, MAX_INLINE_DATA, PAGE_CACHE_SIZE);
>  
>  	dentry_blk = kmap_atomic(page);
>  
>  	/* copy data from inline dentry block to new dentry block */
>  	memcpy(dentry_blk->dentry_bitmap, inline_dentry->dentry_bitmap,
>  					INLINE_DENTRY_BITMAP_SIZE);
> +	memset(dentry_blk->dentry_bitmap + INLINE_DENTRY_BITMAP_SIZE, 0,
> +			SIZE_OF_DENTRY_BITMAP - INLINE_DENTRY_BITMAP_SIZE);

Setting zeros for bitmap would be enough.
It doesn't need to copy or set zeros for reserved, dentries, and filename slots.

Thanks,

> +	/*
> +	 * reserved space size of inline dentry is larger than the one of
> +	 * regular dentry, here we just copy with the size of reserved space
> +	 * in regular dentry.
> +	 */
> +	memcpy(dentry_blk->reserved, inline_dentry->reserved, SIZE_OF_RESERVED);
>  	memcpy(dentry_blk->dentry, inline_dentry->dentry,
>  			sizeof(struct f2fs_dir_entry) * NR_INLINE_DENTRY);
> +	memset(dentry_blk->dentry + NR_INLINE_DENTRY, 0,
> +			sizeof (struct f2fs_dir_entry) *
> +			(NR_DENTRY_IN_BLOCK - NR_INLINE_DENTRY));
>  	memcpy(dentry_blk->filename, inline_dentry->filename,
>  					NR_INLINE_DENTRY * F2FS_SLOT_LEN);
> +	memset(&dentry_blk->filename[NR_INLINE_DENTRY][0], 0,
> +		F2FS_SLOT_LEN * (NR_DENTRY_IN_BLOCK - NR_INLINE_DENTRY));
>  
>  	kunmap_atomic(dentry_blk);
>  	SetPageUptodate(page);
> -- 
> 2.4.2

------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 2/9] f2fs: avoid unneeded initializing when converting inline dentry
  2015-08-20 17:17   ` Jaegeuk Kim
  (?)
@ 2015-08-21 12:58   ` Chao Yu
  -1 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2015-08-21 12:58 UTC (permalink / raw)
  To: 'Jaegeuk Kim'; +Cc: linux-f2fs-devel, linux-kernel

Hi Jaegeuk,

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Friday, August 21, 2015 1:17 AM
> To: Chao Yu
> Cc: linux-f2fs-devel@lists.sourceforge.net; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 2/9] f2fs: avoid unneeded initializing when converting inline dentry
> 
> Hi Chao,
> 
> On Wed, Aug 19, 2015 at 07:10:19PM +0800, Chao Yu wrote:
> > When converting inline dentry, we will zero out target dentry page before
> > duplicating data of inline dentry into target page, it become overhead
> > since inline dentry size is not small.
> >
> > So this patch tries to remove unneeded initializing in the space of target
> > dentry page.
> >
> > Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> > ---
> >  fs/f2fs/inline.c | 15 ++++++++++++++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> > index 79d18d5..e4da0d7 100644
> > --- a/fs/f2fs/inline.c
> > +++ b/fs/f2fs/inline.c
> > @@ -384,17 +384,30 @@ static int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage,
> >  		goto out;
> >
> >  	f2fs_wait_on_page_writeback(page, DATA);
> > -	zero_user_segment(page, 0, PAGE_CACHE_SIZE);
> > +	zero_user_segment(page, MAX_INLINE_DATA, PAGE_CACHE_SIZE);
> >
> >  	dentry_blk = kmap_atomic(page);
> >
> >  	/* copy data from inline dentry block to new dentry block */
> >  	memcpy(dentry_blk->dentry_bitmap, inline_dentry->dentry_bitmap,
> >  					INLINE_DENTRY_BITMAP_SIZE);
> > +	memset(dentry_blk->dentry_bitmap + INLINE_DENTRY_BITMAP_SIZE, 0,
> > +			SIZE_OF_DENTRY_BITMAP - INLINE_DENTRY_BITMAP_SIZE);
> 
> Setting zeros for bitmap would be enough.
> It doesn't need to copy or set zeros for reserved, dentries, and filename slots.

Oh, you're right, I will fix it. :)

Thanks


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-21 12:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-19 11:10 [PATCH 2/9] f2fs: avoid unneeded initializing when converting inline dentry Chao Yu
2015-08-19 11:10 ` Chao Yu
2015-08-20 17:17 ` Jaegeuk Kim
2015-08-20 17:17   ` Jaegeuk Kim
2015-08-21 12:58   ` Chao Yu

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.