linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/4] f2fs: compress: fix panic in mkwrite
@ 2020-01-06  8:01 Chao Yu
  2020-01-06  8:01 ` [f2fs-dev] [PATCH 2/4] f2fs: compress: revert error path fix Chao Yu
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Chao Yu @ 2020-01-06  8:01 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

[ 1237.458208] invalid opcode: 0000 [#1] SMP PTI
[ 1237.458228] CPU: 9 PID: 6291 Comm: fsstress Tainted: G           OE     5.5.0-rc1 #36
[ 1237.458255] Hardware name: Xen HVM domU, BIOS 4.1.2_115-908.790. 06/05/2017
[ 1237.458299] RIP: 0010:f2fs_vm_page_mkwrite+0x1c6/0x630 [f2fs]
[ 1237.458321] Code: d6 fe ff ff 49 8b 75 20 48 89 df e8 24 0a 05 00 85 c0 41 89 c7 78 8e 0f 84 bd fe ff ff 45 31 f6 41 83 ff 02 0f 85 c3 fe ff ff <0f> 0b 45 84 f6 0f 84 e4 00 00 00 ba 01 00 00 00 be 05 00 00 00 48
[ 1237.458374] RSP: 0000:ffffaecdc0c1bd38 EFLAGS: 00010246
[ 1237.458395] RAX: 0000000000000002 RBX: ffff9241c5b5d8c0 RCX: 0000000000000000
[ 1237.458418] RDX: ffffeeb715d42407 RSI: ffff9242d8085168 RDI: 0000000000000000
[ 1237.458441] RBP: ffff9243f1c67000 R08: 0000000000017677 R09: 0000000000000004
[ 1237.458463] R10: 0000000000000000 R11: ffff9242d8085000 R12: ffffaecdc0c1bdf8
[ 1237.458488] R13: ffffeeb715d037c0 R14: 0000000000000000 R15: 0000000000000002
[ 1237.458512] FS:  00007f71f28ce700(0000) GS:ffff92443d840000(0000) knlGS:0000000000000000
[ 1237.458540] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1237.458561] CR2: 00007f71f28c9000 CR3: 00000007e0ba2003 CR4: 00000000001606e0
[ 1237.458586] Call Trace:
[ 1237.458611]  do_page_mkwrite+0x5a/0xc0
[ 1237.458630]  __handle_mm_fault+0xb81/0x12a0
[ 1237.458648]  ? do_mmap+0x4bd/0x640
[ 1237.458665]  handle_mm_fault+0xe3/0x1d0
[ 1237.458686]  __do_page_fault+0x288/0x500
[ 1237.458704]  do_page_fault+0x30/0x120
[ 1237.458725]  page_fault+0x3e/0x50

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/file.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 9aeadf14413c..f18d1262b274 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -72,7 +72,10 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
 			err = ret;
 			goto err;
 		} else if (ret) {
-			f2fs_bug_on(sbi, ret == CLUSTER_HAS_SPACE);
+			if (ret == CLUSTER_HAS_SPACE) {
+				err = -EAGAIN;
+				goto err;
+			}
 			need_alloc = false;
 		}
 	}
-- 
2.18.0.rc1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* [f2fs-dev] [PATCH 2/4] f2fs: compress: revert error path fix
  2020-01-06  8:01 [f2fs-dev] [PATCH 1/4] f2fs: compress: fix panic in mkwrite Chao Yu
@ 2020-01-06  8:01 ` Chao Yu
  2020-01-06 19:26   ` Jaegeuk Kim
  2020-01-06  8:01 ` [f2fs-dev] [PATCH 3/4] f2fs: compress: fix error path in prepare_compress_overwrite() Chao Yu
  2020-01-06  8:01 ` [f2fs-dev] [PATCH 4/4] f2fs: compress: release compress context in caller of f2fs_read_multi_pages() Chao Yu
  2 siblings, 1 reply; 9+ messages in thread
From: Chao Yu @ 2020-01-06  8:01 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

Revert incorrect fix in ("TEMP: f2fs: support data compression - fix1")

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/compress.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index f993b4ce1970..fc4510729654 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -601,7 +601,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
 							fgp_flag, GFP_NOFS);
 		if (!page) {
 			ret = -ENOMEM;
-			goto release_pages;
+			goto unlock_pages;
 		}
 
 		if (PageUptodate(page))
@@ -616,13 +616,13 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
 		ret = f2fs_read_multi_pages(cc, &bio, cc->cluster_size,
 						&last_block_in_bio, false);
 		if (ret)
-			goto unlock_pages;
+			goto release_pages;
 		if (bio)
 			f2fs_submit_bio(sbi, bio, DATA);
 
 		ret = f2fs_init_compress_ctx(cc);
 		if (ret)
-			goto unlock_pages;
+			goto release_pages;
 	}
 
 	for (i = 0; i < cc->cluster_size; i++) {
-- 
2.18.0.rc1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* [f2fs-dev] [PATCH 3/4] f2fs: compress: fix error path in prepare_compress_overwrite()
  2020-01-06  8:01 [f2fs-dev] [PATCH 1/4] f2fs: compress: fix panic in mkwrite Chao Yu
  2020-01-06  8:01 ` [f2fs-dev] [PATCH 2/4] f2fs: compress: revert error path fix Chao Yu
@ 2020-01-06  8:01 ` Chao Yu
  2020-01-06 19:08   ` Jaegeuk Kim
  2020-01-06  8:01 ` [f2fs-dev] [PATCH 4/4] f2fs: compress: release compress context in caller of f2fs_read_multi_pages() Chao Yu
  2 siblings, 1 reply; 9+ messages in thread
From: Chao Yu @ 2020-01-06  8:01 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

- fix to release cluster pages in retry flow
- fix to call f2fs_put_dnode() & __do_map_lock() in error path

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/compress.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index fc4510729654..3390351d2e39 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -626,20 +626,26 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
 	}
 
 	for (i = 0; i < cc->cluster_size; i++) {
+		f2fs_bug_on(sbi, cc->rpages[i]);
+
 		page = find_lock_page(mapping, start_idx + i);
 		f2fs_bug_on(sbi, !page);
 
 		f2fs_wait_on_page_writeback(page, DATA, true, true);
 
-		cc->rpages[i] = page;
+		f2fs_compress_ctx_add_page(cc, page);
 		f2fs_put_page(page, 0);
 
 		if (!PageUptodate(page)) {
-			for (idx = 0; idx < cc->cluster_size; idx++) {
-				f2fs_put_page(cc->rpages[idx],
-						(idx <= i) ? 1 : 0);
+			for (idx = 0; idx <= i; idx++) {
+				unlock_page(cc->rpages[idx]);
 				cc->rpages[idx] = NULL;
 			}
+			for (idx = 0; idx < cc->cluster_size; idx++) {
+				page = find_lock_page(mapping, start_idx + idx);
+				f2fs_put_page(page, 1);
+				f2fs_put_page(page, 0);
+			}
 			kvfree(cc->rpages);
 			cc->nr_rpages = 0;
 			goto retry;
@@ -654,16 +660,20 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
 		for (i = cc->cluster_size - 1; i > 0; i--) {
 			ret = f2fs_get_block(&dn, start_idx + i);
 			if (ret) {
-				/* TODO: release preallocate blocks */
 				i = cc->cluster_size;
-				goto unlock_pages;
+				break;
 			}
 
 			if (dn.data_blkaddr != NEW_ADDR)
 				break;
 		}
 
+		f2fs_put_dnode(&dn);
+
 		__do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false);
+
+		if (ret)
+			goto unlock_pages;
 	}
 
 	*fsdata = cc->rpages;
-- 
2.18.0.rc1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* [f2fs-dev] [PATCH 4/4] f2fs: compress: release compress context in caller of f2fs_read_multi_pages()
  2020-01-06  8:01 [f2fs-dev] [PATCH 1/4] f2fs: compress: fix panic in mkwrite Chao Yu
  2020-01-06  8:01 ` [f2fs-dev] [PATCH 2/4] f2fs: compress: revert error path fix Chao Yu
  2020-01-06  8:01 ` [f2fs-dev] [PATCH 3/4] f2fs: compress: fix error path in prepare_compress_overwrite() Chao Yu
@ 2020-01-06  8:01 ` Chao Yu
  2 siblings, 0 replies; 9+ messages in thread
From: Chao Yu @ 2020-01-06  8:01 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

Execute initialize/destroy flow of compress context outside of
f2fs_read_multi_pages()

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/compress.c |  1 +
 fs/f2fs/data.c     | 10 +++-------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 3390351d2e39..7727b6553a14 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -615,6 +615,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
 
 		ret = f2fs_read_multi_pages(cc, &bio, cc->cluster_size,
 						&last_block_in_bio, false);
+		f2fs_destroy_compress_ctx(cc);
 		if (ret)
 			goto release_pages;
 		if (bio)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 5476d33f2d76..e68b9f4b7913 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2121,7 +2121,6 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
 							false);
 				f2fs_free_dic(dic);
 				f2fs_put_dnode(&dn);
-				f2fs_destroy_compress_ctx(cc);
 				*bio_ret = bio;
 				return ret;
 			}
@@ -2139,7 +2138,6 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
 
 	f2fs_put_dnode(&dn);
 
-	f2fs_destroy_compress_ctx(cc);
 	*bio_ret = bio;
 	return 0;
 
@@ -2213,10 +2211,9 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 							max_nr_pages,
 							&last_block_in_bio,
 							is_readahead);
-				if (ret) {
-					f2fs_destroy_compress_ctx(&cc);
+				f2fs_destroy_compress_ctx(&cc);
+				if (ret)
 					goto set_error_page;
-				}
 			}
 			ret = f2fs_is_compressed_cluster(inode, page->index);
 			if (ret < 0)
@@ -2257,8 +2254,7 @@ int f2fs_mpage_readpages(struct address_space *mapping,
 							max_nr_pages,
 							&last_block_in_bio,
 							is_readahead);
-				if (ret)
-					f2fs_destroy_compress_ctx(&cc);
+				f2fs_destroy_compress_ctx(&cc);
 			}
 		}
 #endif
-- 
2.18.0.rc1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH 3/4] f2fs: compress: fix error path in prepare_compress_overwrite()
  2020-01-06  8:01 ` [f2fs-dev] [PATCH 3/4] f2fs: compress: fix error path in prepare_compress_overwrite() Chao Yu
@ 2020-01-06 19:08   ` Jaegeuk Kim
  2020-01-07  1:35     ` Chao Yu
  0 siblings, 1 reply; 9+ messages in thread
From: Jaegeuk Kim @ 2020-01-06 19:08 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

On 01/06, Chao Yu wrote:
> - fix to release cluster pages in retry flow
> - fix to call f2fs_put_dnode() & __do_map_lock() in error path
> 
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
>  fs/f2fs/compress.c | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> index fc4510729654..3390351d2e39 100644
> --- a/fs/f2fs/compress.c
> +++ b/fs/f2fs/compress.c
> @@ -626,20 +626,26 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
>  	}
>  
>  	for (i = 0; i < cc->cluster_size; i++) {
> +		f2fs_bug_on(sbi, cc->rpages[i]);
> +
>  		page = find_lock_page(mapping, start_idx + i);
>  		f2fs_bug_on(sbi, !page);
>  
>  		f2fs_wait_on_page_writeback(page, DATA, true, true);
>  
> -		cc->rpages[i] = page;
> +		f2fs_compress_ctx_add_page(cc, page);
>  		f2fs_put_page(page, 0);
>  
>  		if (!PageUptodate(page)) {
> -			for (idx = 0; idx < cc->cluster_size; idx++) {
> -				f2fs_put_page(cc->rpages[idx],
> -						(idx <= i) ? 1 : 0);
> +			for (idx = 0; idx <= i; idx++) {
> +				unlock_page(cc->rpages[idx]);
>  				cc->rpages[idx] = NULL;
>  			}
> +			for (idx = 0; idx < cc->cluster_size; idx++) {
> +				page = find_lock_page(mapping, start_idx + idx);

Why do we need to lock the pages again?

> +				f2fs_put_page(page, 1);
> +				f2fs_put_page(page, 0);
> +			}
>  			kvfree(cc->rpages);
>  			cc->nr_rpages = 0;
>  			goto retry;
> @@ -654,16 +660,20 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
>  		for (i = cc->cluster_size - 1; i > 0; i--) {
>  			ret = f2fs_get_block(&dn, start_idx + i);
>  			if (ret) {
> -				/* TODO: release preallocate blocks */
>  				i = cc->cluster_size;
> -				goto unlock_pages;
> +				break;
>  			}
>  
>  			if (dn.data_blkaddr != NEW_ADDR)
>  				break;
>  		}
>  
> +		f2fs_put_dnode(&dn);

We don't neeed this, since f2fs_reserve_block() put the dnode.

> +
>  		__do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false);
> +
> +		if (ret)
> +			goto unlock_pages;
>  	}
>  
>  	*fsdata = cc->rpages;
> -- 
> 2.18.0.rc1


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH 2/4] f2fs: compress: revert error path fix
  2020-01-06  8:01 ` [f2fs-dev] [PATCH 2/4] f2fs: compress: revert error path fix Chao Yu
@ 2020-01-06 19:26   ` Jaegeuk Kim
  2020-01-08  9:33     ` Chao Yu
  0 siblings, 1 reply; 9+ messages in thread
From: Jaegeuk Kim @ 2020-01-06 19:26 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

Hi Chao,

Could you please check this out?
https://github.com/jaegeuk/f2fs/commits/g-dev-test

Thanks,

On 01/06, Chao Yu wrote:
> Revert incorrect fix in ("TEMP: f2fs: support data compression - fix1")
> 
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
>  fs/f2fs/compress.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> index f993b4ce1970..fc4510729654 100644
> --- a/fs/f2fs/compress.c
> +++ b/fs/f2fs/compress.c
> @@ -601,7 +601,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
>  							fgp_flag, GFP_NOFS);
>  		if (!page) {
>  			ret = -ENOMEM;
> -			goto release_pages;
> +			goto unlock_pages;
>  		}
>  
>  		if (PageUptodate(page))
> @@ -616,13 +616,13 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
>  		ret = f2fs_read_multi_pages(cc, &bio, cc->cluster_size,
>  						&last_block_in_bio, false);
>  		if (ret)
> -			goto unlock_pages;
> +			goto release_pages;
>  		if (bio)
>  			f2fs_submit_bio(sbi, bio, DATA);
>  
>  		ret = f2fs_init_compress_ctx(cc);
>  		if (ret)
> -			goto unlock_pages;
> +			goto release_pages;
>  	}
>  
>  	for (i = 0; i < cc->cluster_size; i++) {
> -- 
> 2.18.0.rc1


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH 3/4] f2fs: compress: fix error path in prepare_compress_overwrite()
  2020-01-06 19:08   ` Jaegeuk Kim
@ 2020-01-07  1:35     ` Chao Yu
  2020-01-08 20:49       ` Jaegeuk Kim
  0 siblings, 1 reply; 9+ messages in thread
From: Chao Yu @ 2020-01-07  1:35 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel

On 2020/1/7 3:08, Jaegeuk Kim wrote:
> On 01/06, Chao Yu wrote:
>> - fix to release cluster pages in retry flow
>> - fix to call f2fs_put_dnode() & __do_map_lock() in error path
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>>  fs/f2fs/compress.c | 22 ++++++++++++++++------
>>  1 file changed, 16 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
>> index fc4510729654..3390351d2e39 100644
>> --- a/fs/f2fs/compress.c
>> +++ b/fs/f2fs/compress.c
>> @@ -626,20 +626,26 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
>>  	}
>>  
>>  	for (i = 0; i < cc->cluster_size; i++) {
>> +		f2fs_bug_on(sbi, cc->rpages[i]);
>> +
>>  		page = find_lock_page(mapping, start_idx + i);
>>  		f2fs_bug_on(sbi, !page);
>>  
>>  		f2fs_wait_on_page_writeback(page, DATA, true, true);
>>  
>> -		cc->rpages[i] = page;
>> +		f2fs_compress_ctx_add_page(cc, page);
>>  		f2fs_put_page(page, 0);
>>  
>>  		if (!PageUptodate(page)) {
>> -			for (idx = 0; idx < cc->cluster_size; idx++) {
>> -				f2fs_put_page(cc->rpages[idx],
>> -						(idx <= i) ? 1 : 0);
>> +			for (idx = 0; idx <= i; idx++) {
>> +				unlock_page(cc->rpages[idx]);
>>  				cc->rpages[idx] = NULL;
>>  			}
>> +			for (idx = 0; idx < cc->cluster_size; idx++) {
>> +				page = find_lock_page(mapping, start_idx + idx);
> 
> Why do we need to lock the pages again?

Here, all pages in cluster has one extra reference count, we need to find all
pages, and release those references on them.

cc->rpages may not record all pages' pointers, so we can not use

f2fs_put_page(cc->rpages[idx], (idx <= i) ? 1 : 0); to release all pages' references.

BTW, find_get_page() should be fine to instead find_lock_page().

> 
>> +				f2fs_put_page(page, 1);
>> +				f2fs_put_page(page, 0);
>> +			}
>>  			kvfree(cc->rpages);
>>  			cc->nr_rpages = 0;
>>  			goto retry;
>> @@ -654,16 +660,20 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
>>  		for (i = cc->cluster_size - 1; i > 0; i--) {
>>  			ret = f2fs_get_block(&dn, start_idx + i);
>>  			if (ret) {
>> -				/* TODO: release preallocate blocks */
>>  				i = cc->cluster_size;
>> -				goto unlock_pages;
>> +				break;
>>  			}
>>  
>>  			if (dn.data_blkaddr != NEW_ADDR)
>>  				break;
>>  		}
>>  
>> +		f2fs_put_dnode(&dn);
> 
> We don't neeed this, since f2fs_reserve_block() put the dnode.

Correct.

Thanks,

> 
>> +
>>  		__do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false);
>> +
>> +		if (ret)
>> +			goto unlock_pages;
>>  	}
>>  
>>  	*fsdata = cc->rpages;
>> -- 
>> 2.18.0.rc1
> .
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH 2/4] f2fs: compress: revert error path fix
  2020-01-06 19:26   ` Jaegeuk Kim
@ 2020-01-08  9:33     ` Chao Yu
  0 siblings, 0 replies; 9+ messages in thread
From: Chao Yu @ 2020-01-08  9:33 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel

On 2020/1/7 3:26, Jaegeuk Kim wrote:
> Hi Chao,
> 
> Could you please check this out?
> https://github.com/jaegeuk/f2fs/commits/g-dev-test

Looks good to me, I add some minor comments on github.

Any comments on below thread?

Re: [f2fs-dev] [PATCH 3/4] f2fs: compress: fix error path in prepare_compress_overwrite()

Thanks,

> 
> Thanks,
> 
> On 01/06, Chao Yu wrote:
>> Revert incorrect fix in ("TEMP: f2fs: support data compression - fix1")
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>>  fs/f2fs/compress.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
>> index f993b4ce1970..fc4510729654 100644
>> --- a/fs/f2fs/compress.c
>> +++ b/fs/f2fs/compress.c
>> @@ -601,7 +601,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
>>  							fgp_flag, GFP_NOFS);
>>  		if (!page) {
>>  			ret = -ENOMEM;
>> -			goto release_pages;
>> +			goto unlock_pages;
>>  		}
>>  
>>  		if (PageUptodate(page))
>> @@ -616,13 +616,13 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
>>  		ret = f2fs_read_multi_pages(cc, &bio, cc->cluster_size,
>>  						&last_block_in_bio, false);
>>  		if (ret)
>> -			goto unlock_pages;
>> +			goto release_pages;
>>  		if (bio)
>>  			f2fs_submit_bio(sbi, bio, DATA);
>>  
>>  		ret = f2fs_init_compress_ctx(cc);
>>  		if (ret)
>> -			goto unlock_pages;
>> +			goto release_pages;
>>  	}
>>  
>>  	for (i = 0; i < cc->cluster_size; i++) {
>> -- 
>> 2.18.0.rc1
> .
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH 3/4] f2fs: compress: fix error path in prepare_compress_overwrite()
  2020-01-07  1:35     ` Chao Yu
@ 2020-01-08 20:49       ` Jaegeuk Kim
  0 siblings, 0 replies; 9+ messages in thread
From: Jaegeuk Kim @ 2020-01-08 20:49 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

On 01/07, Chao Yu wrote:
> On 2020/1/7 3:08, Jaegeuk Kim wrote:
> > On 01/06, Chao Yu wrote:
> >> - fix to release cluster pages in retry flow
> >> - fix to call f2fs_put_dnode() & __do_map_lock() in error path
> >>
> >> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> >> ---
> >>  fs/f2fs/compress.c | 22 ++++++++++++++++------
> >>  1 file changed, 16 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> >> index fc4510729654..3390351d2e39 100644
> >> --- a/fs/f2fs/compress.c
> >> +++ b/fs/f2fs/compress.c
> >> @@ -626,20 +626,26 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
> >>  	}
> >>  
> >>  	for (i = 0; i < cc->cluster_size; i++) {
> >> +		f2fs_bug_on(sbi, cc->rpages[i]);
> >> +
> >>  		page = find_lock_page(mapping, start_idx + i);
> >>  		f2fs_bug_on(sbi, !page);
> >>  
> >>  		f2fs_wait_on_page_writeback(page, DATA, true, true);
> >>  
> >> -		cc->rpages[i] = page;
> >> +		f2fs_compress_ctx_add_page(cc, page);
> >>  		f2fs_put_page(page, 0);
> >>  
> >>  		if (!PageUptodate(page)) {
> >> -			for (idx = 0; idx < cc->cluster_size; idx++) {
> >> -				f2fs_put_page(cc->rpages[idx],
> >> -						(idx <= i) ? 1 : 0);
> >> +			for (idx = 0; idx <= i; idx++) {
> >> +				unlock_page(cc->rpages[idx]);
> >>  				cc->rpages[idx] = NULL;
> >>  			}
> >> +			for (idx = 0; idx < cc->cluster_size; idx++) {
> >> +				page = find_lock_page(mapping, start_idx + idx);
> > 
> > Why do we need to lock the pages again?
> 
> Here, all pages in cluster has one extra reference count, we need to find all
> pages, and release those references on them.
> 
> cc->rpages may not record all pages' pointers, so we can not use
> 
> f2fs_put_page(cc->rpages[idx], (idx <= i) ? 1 : 0); to release all pages' references.
> 
> BTW, find_get_page() should be fine to instead find_lock_page().

Could you take a look at this?

https://github.com/jaegeuk/f2fs/commit/2e4ea726633dd2666f57ae88dfec5d97694d6495


Thanks,

> 
> > 
> >> +				f2fs_put_page(page, 1);
> >> +				f2fs_put_page(page, 0);
> >> +			}
> >>  			kvfree(cc->rpages);
> >>  			cc->nr_rpages = 0;
> >>  			goto retry;
> >> @@ -654,16 +660,20 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
> >>  		for (i = cc->cluster_size - 1; i > 0; i--) {
> >>  			ret = f2fs_get_block(&dn, start_idx + i);
> >>  			if (ret) {
> >> -				/* TODO: release preallocate blocks */
> >>  				i = cc->cluster_size;
> >> -				goto unlock_pages;
> >> +				break;
> >>  			}
> >>  
> >>  			if (dn.data_blkaddr != NEW_ADDR)
> >>  				break;
> >>  		}
> >>  
> >> +		f2fs_put_dnode(&dn);
> > 
> > We don't neeed this, since f2fs_reserve_block() put the dnode.
> 
> Correct.
> 
> Thanks,
> 
> > 
> >> +
> >>  		__do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false);
> >> +
> >> +		if (ret)
> >> +			goto unlock_pages;
> >>  	}
> >>  
> >>  	*fsdata = cc->rpages;
> >> -- 
> >> 2.18.0.rc1
> > .
> > 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2020-01-08 20:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-06  8:01 [f2fs-dev] [PATCH 1/4] f2fs: compress: fix panic in mkwrite Chao Yu
2020-01-06  8:01 ` [f2fs-dev] [PATCH 2/4] f2fs: compress: revert error path fix Chao Yu
2020-01-06 19:26   ` Jaegeuk Kim
2020-01-08  9:33     ` Chao Yu
2020-01-06  8:01 ` [f2fs-dev] [PATCH 3/4] f2fs: compress: fix error path in prepare_compress_overwrite() Chao Yu
2020-01-06 19:08   ` Jaegeuk Kim
2020-01-07  1:35     ` Chao Yu
2020-01-08 20:49       ` Jaegeuk Kim
2020-01-06  8:01 ` [f2fs-dev] [PATCH 4/4] f2fs: compress: release compress context in caller of f2fs_read_multi_pages() 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).