linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: change the method of calculating the number summary blocks
@ 2013-10-28  8:54 Fan Li
  2013-10-28 10:34 ` Jaegeuk Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Fan Li @ 2013-10-28  8:54 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=windows-1252, Size: 2176 bytes --]

"There is a HTML error in the previous email, so I send this one.If you already received this before, please ignore it.Sorry for the inconvenience"

This patch change the method of calculating the number of summary blocks in function  npages_for_summary_flush.
npages_for_summary_flush uses (SUMMARY_SIZE + 1) as the size of a f2fs_summary while the actual size is just SUMMARY_SIZE.
As a result, occasionally the return value of npages_for_summary_flush will be bigger than the actual number by one, and the checkpoint won't be written contiguously  into disk.
Besides, struct f2fs_summary can't be split to two pages, so it could take more space than the sum of its size, the current version seems not to take it into account.

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

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 487af61..ba2930f 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -279,9 +279,8 @@ static void __add_sum_entry(struct f2fs_sb_info *sbi, int type,
  */
 int npages_for_summary_flush(struct f2fs_sb_info *sbi)  {
-	int total_size_bytes = 0;
 	int valid_sum_count = 0;
-	int i, sum_space;
+	int i, sum_in_page;
 
 	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
 		if (sbi->ckpt->alloc_type[i] == SSR)
@@ -290,13 +289,12 @@ int npages_for_summary_flush(struct f2fs_sb_info *sbi)
 			valid_sum_count += curseg_blkoff(sbi, i);
 	}
 
-	total_size_bytes = valid_sum_count * (SUMMARY_SIZE + 1)
-			+ sizeof(struct nat_journal) + 2
-			+ sizeof(struct sit_journal) + 2;
-	sum_space = PAGE_CACHE_SIZE - SUM_FOOTER_SIZE;
-	if (total_size_bytes < sum_space)
+	sum_in_page = (PAGE_CACHE_SIZE - 2*SUM_JOURNAL_SIZE - SUM_FOOTER_SIZE)/
+			SUMMARY_SIZE;
+	if (valid_sum_count <= sum_in_page)
 		return 1;
-	else if (total_size_bytes < 2 * sum_space)
+	else if (valid_sum_count-sum_in_page <=
+			(PAGE_CACHE_SIZE-SUM_FOOTER_SIZE)/SUMMARY_SIZE)
 		return 2;
 	return 3;
 }
--
1.7.9.5
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [f2fs-dev] [PATCH] f2fs: change the method of calculating the number summary blocks
  2013-10-28  8:54 [f2fs-dev] [PATCH] f2fs: change the method of calculating the number summary blocks Fan Li
@ 2013-10-28 10:34 ` Jaegeuk Kim
  2013-10-29  7:41   ` Fan Li
  0 siblings, 1 reply; 3+ messages in thread
From: Jaegeuk Kim @ 2013-10-28 10:34 UTC (permalink / raw)
  To: fanofcode.li; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel

Hi,

2013-10-28 (월), 08:54 +0000, Fan Li:
> "There is a HTML error in the previous email, so I send this one.If you already received this before, please ignore it.Sorry for the inconvenience"
> 
> This patch change the method of calculating the number of summary blocks in function  npages_for_summary_flush.
> npages_for_summary_flush uses (SUMMARY_SIZE + 1) as the size of a f2fs_summary while the actual size is just SUMMARY_SIZE.
> As a result, occasionally the return value of npages_for_summary_flush will be bigger than the actual number by one, and the checkpoint won't be written contiguously  into disk.
> Besides, struct f2fs_summary can't be split to two pages, so it could take more space than the sum of its size, the current version seems not to take it into account.
> 

Again. Please write a description not to exceed 80 columns.

> Signed-off-by: Fan Li <fanofcode.li@samsung.com>
> ---
>  fs/f2fs/segment.c |   14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 487af61..ba2930f 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -279,9 +279,8 @@ static void __add_sum_entry(struct f2fs_sb_info *sbi, int type,
>   */
>  int npages_for_summary_flush(struct f2fs_sb_info *sbi)  {
> -	int total_size_bytes = 0;
>  	int valid_sum_count = 0;
> -	int i, sum_space;
> +	int i, sum_in_page;
>  
>  	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
>  		if (sbi->ckpt->alloc_type[i] == SSR)
> @@ -290,13 +289,12 @@ int npages_for_summary_flush(struct f2fs_sb_info *sbi)
>  			valid_sum_count += curseg_blkoff(sbi, i);
>  	}
>  
> -	total_size_bytes = valid_sum_count * (SUMMARY_SIZE + 1)
> -			+ sizeof(struct nat_journal) + 2
> -			+ sizeof(struct sit_journal) + 2;
> -	sum_space = PAGE_CACHE_SIZE - SUM_FOOTER_SIZE;
> -	if (total_size_bytes < sum_space)
> +	sum_in_page = (PAGE_CACHE_SIZE - 2*SUM_JOURNAL_SIZE - SUM_FOOTER_SIZE)/

	sum_in_page = (PAGE_CACHE_SIZE - 2 * SUM_JOURNAL_SIZE -
SUM_FOOTER_SIZE) / SUMMARY_SIZE;

Coding style.

> +			SUMMARY_SIZE;
> +	if (valid_sum_count <= sum_in_page)
>  		return 1;
> -	else if (total_size_bytes < 2 * sum_space)
> +	else if (valid_sum_count-sum_in_page <=
> +			(PAGE_CACHE_SIZE-SUM_FOOTER_SIZE)/SUMMARY_SIZE)

ditto.

>  		return 2;
>  	return 3;
>  }
> --
> 1.7.9.5

-- 
Jaegeuk Kim
Samsung


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

* RE: [f2fs-dev] [PATCH] f2fs: change the method of calculating the number summary blocks
  2013-10-28 10:34 ` Jaegeuk Kim
@ 2013-10-29  7:41   ` Fan Li
  0 siblings, 0 replies; 3+ messages in thread
From: Fan Li @ 2013-10-29  7:41 UTC (permalink / raw)
  To: jaegeuk.kim; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel

> Hi,
> 
> 2013-10-28 (월), 08:54 +0000, Fan Li:
> > "There is a HTML error in the previous email, so I send this one.If you
> already received this before, please ignore it.Sorry for the inconvenience"
> >
> > This patch change the method of calculating the number of summary blocks
> in function  npages_for_summary_flush.
> > npages_for_summary_flush uses (SUMMARY_SIZE + 1) as the size of a
> f2fs_summary while the actual size is just SUMMARY_SIZE.
> > As a result, occasionally the return value of npages_for_summary_flush will
> be bigger than the actual number by one, and the checkpoint won't be
> written contiguously  into disk.
> > Besides, struct f2fs_summary can't be split to two pages, so it could take
> more space than the sum of its size, the current version seems not to take it
> into account.
> >
> 
> Again. Please write a description not to exceed 80 columns.
> 

Sorry, didn't know. here's the short version:
npages_for_summary_flush uses (SUMMARY_SIZE + 1) as the size of a f2fs_summary 
while its actual size is  SUMMARY_SIZE. So the result sometimes is bigger than 
actual number by one, which causes checkpoint can't be written into disk contiguously,
and sometimes summary blocks can't be compacted like they should.
Besides, when writing summary blocks into pages, if remain space in a page isn't 
big enough for one f2fs_summary, it will be left unused, current code seems 
not to take it into account.

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

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 487af61..e40cdc4 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -279,9 +279,8 @@ static void __add_sum_entry(struct f2fs_sb_info *sbi, int type,
  */
 int npages_for_summary_flush(struct f2fs_sb_info *sbi)
 {
-	int total_size_bytes = 0;
 	int valid_sum_count = 0;
-	int i, sum_space;
+	int i, sum_in_page;
 
 	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
 		if (sbi->ckpt->alloc_type[i] == SSR)
@@ -290,13 +289,12 @@ int npages_for_summary_flush(struct f2fs_sb_info *sbi)
 			valid_sum_count += curseg_blkoff(sbi, i);
 	}
 
-	total_size_bytes = valid_sum_count * (SUMMARY_SIZE + 1)
-			+ sizeof(struct nat_journal) + 2
-			+ sizeof(struct sit_journal) + 2;
-	sum_space = PAGE_CACHE_SIZE - SUM_FOOTER_SIZE;
-	if (total_size_bytes < sum_space)
+	sum_in_page = (PAGE_CACHE_SIZE - 2 * SUM_JOURNAL_SIZE -
+			SUM_FOOTER_SIZE) / SUMMARY_SIZE;
+	if (valid_sum_count <= sum_in_page)
 		return 1;
-	else if (total_size_bytes < 2 * sum_space)
+	else if ((valid_sum_count - sum_in_page) <=
+		(PAGE_CACHE_SIZE - SUM_FOOTER_SIZE) / SUMMARY_SIZE)
 		return 2;
 	return 3;
 }
-- 
1.7.9.5


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

end of thread, other threads:[~2013-10-29  7:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-28  8:54 [f2fs-dev] [PATCH] f2fs: change the method of calculating the number summary blocks Fan Li
2013-10-28 10:34 ` Jaegeuk Kim
2013-10-29  7:41   ` Fan Li

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).