linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: Copy summary entries in bulk
       [not found]   ` <000901d3d575$fdbba760$f932f620$@samsung.com>
@ 2018-04-16 11:48     ` LiFan
  2018-04-17  8:12       ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: LiFan @ 2018-04-16 11:48 UTC (permalink / raw)
  To: 'Chao Yu', jaegeuk; +Cc: linux-f2fs-devel

Copy summary entries in bulk in write_compacted_summaries().
And zero the blank part of page after writing the summaries
to the page.

Signed-off-by: Fan li <fanofcode.li@samsung.com>
---
 fs/f2fs/segment.c | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 3bc77c2..a08b2a8 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3103,14 +3103,12 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
 {
 	struct page *page;
 	unsigned char *kaddr;
-	struct f2fs_summary *summary;
 	struct curseg_info *seg_i;
 	int written_size = 0;
-	int i, j;
+	int i;
 
 	page = grab_meta_page(sbi, blkaddr++);
 	kaddr = (unsigned char *)page_address(page);
-	memset(kaddr, 0, PAGE_SIZE);
 
 	/* Step 1: write nat cache */
 	seg_i = CURSEG_I(sbi, CURSEG_HOT_DATA);
@@ -3124,34 +3122,42 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
 
 	/* Step 3: write summary entries */
 	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
-		unsigned short blkoff;
+		unsigned short blkoff, page_cap, summary_cnt;
+
 		seg_i = CURSEG_I(sbi, i);
 		if (sbi->ckpt->alloc_type[i] == SSR)
 			blkoff = sbi->blocks_per_seg;
 		else
 			blkoff = curseg_blkoff(sbi, i);
 
-		for (j = 0; j < blkoff; j++) {
+		while (blkoff) {
 			if (!page) {
 				page = grab_meta_page(sbi, blkaddr++);
 				kaddr = (unsigned char *)page_address(page);
-				memset(kaddr, 0, PAGE_SIZE);
 				written_size = 0;
 			}
-			summary = (struct f2fs_summary *)(kaddr + written_size);
-			*summary = seg_i->sum_blk->entries[j];
-			written_size += SUMMARY_SIZE;
 
-			if (written_size + SUMMARY_SIZE <= PAGE_SIZE -
-							SUM_FOOTER_SIZE)
-				continue;
-
-			set_page_dirty(page);
-			f2fs_put_page(page, 1);
-			page = NULL;
+			page_cap = (PAGE_SIZE - SUM_FOOTER_SIZE - written_size)
+						/ SUMMARY_SIZE;
+			summary_cnt = min(page_cap, blkoff);
+			memcpy(kaddr + written_size, seg_i->sum_blk->entries,
+						summary_cnt * SUMMARY_SIZE);
+			written_size += summary_cnt * SUMMARY_SIZE;
+			blkoff -= summary_cnt;
+
+			if (page_cap == summary_cnt) {
+				memset(kaddr + written_size, 0,
+						PAGE_SIZE - written_size);
+				set_page_dirty(page);
+				f2fs_put_page(page, 1);
+				page = NULL;
+			}
 		}
 	}
+
 	if (page) {
+		memset(kaddr + written_size, 0,
+				PAGE_SIZE - written_size);
 		set_page_dirty(page);
 		f2fs_put_page(page, 1);
 	}
-- 
2.7.4




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [PATCH] f2fs: Copy summary entries in bulk
  2018-04-16 11:48     ` [PATCH] f2fs: Copy summary entries in bulk LiFan
@ 2018-04-17  8:12       ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2018-04-17  8:12 UTC (permalink / raw)
  To: LiFan, jaegeuk; +Cc: linux-f2fs-devel

On 2018/4/16 19:48, LiFan wrote:
> Copy summary entries in bulk in write_compacted_summaries().
> And zero the blank part of page after writing the summaries
> to the page.
> 
> Signed-off-by: Fan li <fanofcode.li@samsung.com>
> ---
>  fs/f2fs/segment.c | 38 ++++++++++++++++++++++----------------
>  1 file changed, 22 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 3bc77c2..a08b2a8 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -3103,14 +3103,12 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
>  {
>  	struct page *page;
>  	unsigned char *kaddr;
> -	struct f2fs_summary *summary;
>  	struct curseg_info *seg_i;
>  	int written_size = 0;
> -	int i, j;
> +	int i;
>  
>  	page = grab_meta_page(sbi, blkaddr++);
>  	kaddr = (unsigned char *)page_address(page);
> -	memset(kaddr, 0, PAGE_SIZE);
>  
>  	/* Step 1: write nat cache */
>  	seg_i = CURSEG_I(sbi, CURSEG_HOT_DATA);
> @@ -3124,34 +3122,42 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
>  
>  	/* Step 3: write summary entries */
>  	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
> -		unsigned short blkoff;
> +		unsigned short blkoff, page_cap, summary_cnt;

blkoff = 0;

> +
>  		seg_i = CURSEG_I(sbi, i);
>  		if (sbi->ckpt->alloc_type[i] == SSR)
>  			blkoff = sbi->blocks_per_seg;

max = sbi->blocks_per_seg;

>  		else
>  			blkoff = curseg_blkoff(sbi, i);

max = curseg_blkoff(sbi, i);

>  
> -		for (j = 0; j < blkoff; j++) {
> +		while (blkoff) {

while (blkoff < max)

>  			if (!page) {
>  				page = grab_meta_page(sbi, blkaddr++);
>  				kaddr = (unsigned char *)page_address(page);
> -				memset(kaddr, 0, PAGE_SIZE);
>  				written_size = 0;
>  			}
> -			summary = (struct f2fs_summary *)(kaddr + written_size);
> -			*summary = seg_i->sum_blk->entries[j];
> -			written_size += SUMMARY_SIZE;
>  
> -			if (written_size + SUMMARY_SIZE <= PAGE_SIZE -
> -							SUM_FOOTER_SIZE)
> -				continue;
> -
> -			set_page_dirty(page);
> -			f2fs_put_page(page, 1);
> -			page = NULL;
> +			page_cap = (PAGE_SIZE - SUM_FOOTER_SIZE - written_size)
> +						/ SUMMARY_SIZE;
> +			summary_cnt = min(page_cap, blkoff);

summary_cnt = min(page_cap, max - blkoff);

> +			memcpy(kaddr + written_size, seg_i->sum_blk->entries,

memcpy(kaddr + written_size, seg_i->sum_blk->entries + blkoff

> +						summary_cnt * SUMMARY_SIZE);

blkoff += summary_cnt;

> +			written_size += summary_cnt * SUMMARY_SIZE;
> +			blkoff -= summary_cnt;

removed.

Thanks,

> +
> +			if (page_cap == summary_cnt) {
> +				memset(kaddr + written_size, 0,
> +						PAGE_SIZE - written_size);
> +				set_page_dirty(page);
> +				f2fs_put_page(page, 1);
> +				page = NULL;
> +			}
>  		}
>  	}
> +
>  	if (page) {
> +		memset(kaddr + written_size, 0,
> +				PAGE_SIZE - written_size);
>  		set_page_dirty(page);
>  		f2fs_put_page(page, 1);
>  	}
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

end of thread, other threads:[~2018-04-17  8:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20180416111043epcas5p3ea799775cd4117bd80a4207982f98548@epcas5p3.samsung.com>
     [not found] ` <000801d3d573$856747d0$9035d770$@samsung.com>
     [not found]   ` <000901d3d575$fdbba760$f932f620$@samsung.com>
2018-04-16 11:48     ` [PATCH] f2fs: Copy summary entries in bulk LiFan
2018-04-17  8:12       ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).