All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] f2fs: fix a missing discard prefree segments
@ 2016-12-16 12:07 Yunlei He
  2016-12-16 12:07 ` [PATCH 2/2] f2fs: add a case of no need to read a page in write begin Yunlei He
  2016-12-19 23:24 ` [PATCH 1/2] f2fs: fix a missing discard prefree segments Jaegeuk Kim
  0 siblings, 2 replies; 4+ messages in thread
From: Yunlei He @ 2016-12-16 12:07 UTC (permalink / raw)
  To: linux-f2fs-devel, jaegeuk, yuchao0; +Cc: heyunlei

If userspace issue a fstrim with a range not involve prefree segments,
it will reuse these segments without discard. This patch fix it.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
 fs/f2fs/segment.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index d7d5727..5b4468f 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -899,6 +899,9 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 	unsigned int secno, start_segno;
 	bool force = (cpc->reason == CP_DISCARD);
 
+	if (!test_opt(sbi, DISCARD))
+		return;
+
 	blk_start_plug(&plug);
 
 	mutex_lock(&dirty_i->seglist_lock);
@@ -910,15 +913,15 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 			break;
 		end = find_next_zero_bit(prefree_map, MAIN_SEGS(sbi),
 								start + 1);
+		if (force && start * sbi->blocks_per_seg >= cpc->trim_start &&
+					end * sbi->blocks_per_seg <= cpc->trim_end)
+			continue;
 
 		for (i = start; i < end; i++)
 			clear_bit(i, prefree_map);
 
 		dirty_i->nr_dirty[PRE] -= end - start;
 
-		if (force || !test_opt(sbi, DISCARD))
-			continue;
-
 		if (!test_opt(sbi, LFS) || sbi->segs_per_sec == 1) {
 			f2fs_issue_discard(sbi, START_BLOCK(sbi, start),
 				(end - start) << sbi->log_blocks_per_seg);
-- 
2.10.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 related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] f2fs: add a case of no need to read a page in write begin
  2016-12-16 12:07 [PATCH 1/2] f2fs: fix a missing discard prefree segments Yunlei He
@ 2016-12-16 12:07 ` Yunlei He
  2016-12-19 23:52   ` Jaegeuk Kim
  2016-12-19 23:24 ` [PATCH 1/2] f2fs: fix a missing discard prefree segments Jaegeuk Kim
  1 sibling, 1 reply; 4+ messages in thread
From: Yunlei He @ 2016-12-16 12:07 UTC (permalink / raw)
  To: linux-f2fs-devel, jaegeuk, yuchao0; +Cc: heyunlei

If the range we write cover the whole valid data
in the last page, we do not need to read it.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
 fs/f2fs/data.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b90fb01..d9f7339 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1715,6 +1715,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 	if (len == PAGE_SIZE || PageUptodate(page))
 		return 0;
 
+	if (!(pos % PAGE_SHIFT) && (pos + len) > i_size_read(inode))
+		return 0;
+
 	if (blkaddr == NEW_ADDR) {
 		zero_user_segment(page, 0, PAGE_SIZE);
 		SetPageUptodate(page);
-- 
2.10.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 related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] f2fs: fix a missing discard prefree segments
  2016-12-16 12:07 [PATCH 1/2] f2fs: fix a missing discard prefree segments Yunlei He
  2016-12-16 12:07 ` [PATCH 2/2] f2fs: add a case of no need to read a page in write begin Yunlei He
@ 2016-12-19 23:24 ` Jaegeuk Kim
  1 sibling, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2016-12-19 23:24 UTC (permalink / raw)
  To: Yunlei He; +Cc: heyunlei, linux-f2fs-devel

Hi Yunlei,

On 12/16, Yunlei He wrote:
> If userspace issue a fstrim with a range not involve prefree segments,
> it will reuse these segments without discard. This patch fix it.
> 
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
>  fs/f2fs/segment.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index d7d5727..5b4468f 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -899,6 +899,9 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
>  	unsigned int secno, start_segno;
>  	bool force = (cpc->reason == CP_DISCARD);
>  
> +	if (!test_opt(sbi, DISCARD))
> +		return;

We need to clear the prefree bits, even if discard option was not set.

> +
>  	blk_start_plug(&plug);
>  
>  	mutex_lock(&dirty_i->seglist_lock);
> @@ -910,15 +913,15 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
>  			break;
>  		end = find_next_zero_bit(prefree_map, MAIN_SEGS(sbi),
>  								start + 1);
> +		if (force && start * sbi->blocks_per_seg >= cpc->trim_start &&
> +					end * sbi->blocks_per_seg <= cpc->trim_end)
> +			continue;

ditto.

>  
>  		for (i = start; i < end; i++)
>  			clear_bit(i, prefree_map);
>  
>  		dirty_i->nr_dirty[PRE] -= end - start;
>  
> -		if (force || !test_opt(sbi, DISCARD))
> -			continue;

Why not just adding that condition here?

Thanks,

> -
>  		if (!test_opt(sbi, LFS) || sbi->segs_per_sec == 1) {
>  			f2fs_issue_discard(sbi, START_BLOCK(sbi, start),
>  				(end - start) << sbi->log_blocks_per_seg);
> -- 
> 2.10.1
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most 
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel

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

* Re: [PATCH 2/2] f2fs: add a case of no need to read a page in write begin
  2016-12-16 12:07 ` [PATCH 2/2] f2fs: add a case of no need to read a page in write begin Yunlei He
@ 2016-12-19 23:52   ` Jaegeuk Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2016-12-19 23:52 UTC (permalink / raw)
  To: Yunlei He; +Cc: heyunlei, linux-f2fs-devel

Hi,

On 12/16, Yunlei He wrote:
> If the range we write cover the whole valid data
> in the last page, we do not need to read it.
> 
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
>  fs/f2fs/data.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index b90fb01..d9f7339 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1715,6 +1715,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
>  	if (len == PAGE_SIZE || PageUptodate(page))
>  		return 0;
>  
> +	if (!(pos % PAGE_SHIFT) && (pos + len) > i_size_read(inode))

PAGE_SHIFT?

Do you mean like this?

	if (!(pos % PAGE_MASK) && (pos + len) >= i_size_read(inode))

And, it needs to change f2fs_write_end() together.

	/* Need to change comments */
	if (!PageUptodate(page)) {
		if (unlikely(copied != len))  <== like this?
			copied = 0;
		else
			...

Thanks,

> +		return 0;
> +
>  	if (blkaddr == NEW_ADDR) {
>  		zero_user_segment(page, 0, PAGE_SIZE);
>  		SetPageUptodate(page);
> -- 
> 2.10.1
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most 
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel

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

end of thread, other threads:[~2016-12-19 23:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-16 12:07 [PATCH 1/2] f2fs: fix a missing discard prefree segments Yunlei He
2016-12-16 12:07 ` [PATCH 2/2] f2fs: add a case of no need to read a page in write begin Yunlei He
2016-12-19 23:52   ` Jaegeuk Kim
2016-12-19 23:24 ` [PATCH 1/2] f2fs: fix a missing discard prefree segments Jaegeuk Kim

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.