f2fs: fix hungtask when decompressed fail
PATCH v2 1/1 f2fs: fix hungtask when decompressed fail
When decompressed failed, f2fs_prepare_compress_overwrite will enter endless loop, may casue hungtask.
[ 14.088665] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155 [ 14.089851] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155
--- fs/f2fs/compress.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
fs/f2fs/compress.c +16 -5
@@ -1060,7 +1060,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,sector_t last_block_in_bio;unsigned fgp_flag =FGP_LOCK |FGP_WRITE |FGP_CREAT ;pgoff_t start_idx =start_idx_of_cluster (cc); -int i, ret; +int i, ret, retry_count =3 ; retry: ret =f2fs_is_compressed_cluster (cc->inode, start_idx);
@@ -1120,7 +1120,12 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,f2fs_put_rpages (cc);f2fs_unlock_rpages (cc, i +1 );f2fs_destroy_compress_ctx (cc, true); - goto retry; + retry_count--; +if (PageError (page) && !retry_count) { + ret = -EIO ; + goto out; + }else + goto retry; } }
@@ -1657,10 +1662,16 @@ static void __f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed)if (!rpage)continue ; -/* PG_error was set if verity failed. */ -if (failed ||PageError (rpage)) { +if (failed) { +/* decompress page failed */ +ClearPageUptodate (rpage); +SetPageError (rpage); + }else if (PageError (rpage)) { +/* +* PG_error was set if verity failed. +* will re-read again later. +*/ ClearPageUptodate (rpage); -/* will re-read again later */ ClearPageError (rpage); }else {SetPageUptodate (rpage);
Signature · 8 lines
2.25.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
ping, it seems this had been forgotten.
Quoted 63 lines
2022年6月8日 21:48,Fengnan Chang <[email protected]> 写道:
When decompressed failed,
f2fs_prepare_compress_overwritewill enter endless loop, may casue hungtask.[ 14.088665] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155 [ 14.089851] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155Signed-off-by Fengnan Chang <[email protected]>---
fs/f2fs/compress.c| 21 ++++++++++++++++-----1 file changed, 16 insertions(+), 5 deletions(-)fs/f2fs/compress.c +1
-1@@ -1060,7 +1060,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,sector_t last_block_in_bio;unsigned fgp_flag =FGP_LOCK |FGP_WRITE |FGP_CREAT ;pgoff_t start_idx =start_idx_of_cluster (cc); -int i, ret; +int i, ret, retry_count =3 ;retry:
ret = f2fs_is_compressed_cluster(cc->inode, start_idx);fs/f2fs/compress.c +15
-4@@ -1120,7 +1120,12 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,f2fs_put_rpages (cc);f2fs_unlock_rpages (cc, i +1 );f2fs_destroy_compress_ctx (cc, true); - goto retry; + retry_count--; +if (PageError (page) && !retry_count) { + ret = -EIO ; + goto out; + }else + goto retry; } }@@ -1657,10 +1662,16 @@ static void __f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed)if (!rpage)continue ; -/* PG_error was set if verity failed. */ -if (failed ||PageError (rpage)) { +if (failed) { +/* decompress page failed */ +ClearPageUptodate (rpage); +SetPageError (rpage); + }else if (PageError (rpage)) { +/* +* PG_error was set if verity failed. +* will re-read again later. +*/ ClearPageUptodate (rpage); -/* will re-read again later */ ClearPageError (rpage); }else {SetPageUptodate (rpage);Signature · 1 line
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
friendly ping...
Quoted 58 lines · fengnan chang <[email protected]> 于2022年10月14日周五 16:46写道:
ping, it seems this had been forgotten.
Quoted 55 lines
2022年6月8日 21:48,Fengnan Chang <[email protected]> 写道:
When decompressed failed,
f2fs_prepare_compress_overwritewill enter endless loop, may casue hungtask.[ 14.088665] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155 [ 14.089851] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155Signed-off-by Fengnan Chang <[email protected]>---
fs/f2fs/compress.c| 21 ++++++++++++++++-----1 file changed, 16 insertions(+), 5 deletions(-)fs/f2fs/compress.c +1
-1@@ -1060,7 +1060,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,sector_t last_block_in_bio;unsigned fgp_flag =FGP_LOCK |FGP_WRITE |FGP_CREAT ;pgoff_t start_idx =start_idx_of_cluster (cc); -int i, ret; +int i, ret, retry_count =3 ;retry:
ret = f2fs_is_compressed_cluster(cc->inode, start_idx);fs/f2fs/compress.c +15
-3@@ -1120,7 +1120,12 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,f2fs_put_rpages (cc);f2fs_unlock_rpages (cc, i +1 );f2fs_destroy_compress_ctx (cc, true); - goto retry; + retry_count--; +if (PageError (page) && !retry_count) { + ret = -EIO ; + goto out; + }else + goto retry; } }@@ -1657,10 +1662,16 @@ static void __f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed)if (!rpage)continue ; -/* PG_error was set if verity failed. */ -if (failed ||PageError (rpage)) { +if (failed) { +/* decompress page failed */ +ClearPageUptodate (rpage); +SetPageError (rpage); + }else if (PageError (rpage)) { +/* +* PG_error was set if verity failed. +* will re-read again later. +*/
Quoted 9 lines
Quoted 8 lines
fs/f2fs/compress.c +0
-2ClearPageUptodate (rpage); -/* will re-read again later */ ClearPageError (rpage); }else {SetPageUptodate (rpage); --2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerHi Fengnan,
Sorry for the delay.
I guess we can merge this patch, but let me check whether there is another solution, since mm guys want to remove PG_error usage to save one bit slot in page.flags.
Quoted 19 lines · fengnan chang
friendly ping...
Quoted 16 lines · fengnan chang <[email protected]> 于2022年10月14日周五 16:46写道:
ping, it seems this had been forgotten.
Quoted 13 lines
2022年6月8日 21:48,Fengnan Chang <[email protected]> 写道:
When decompressed failed,
f2fs_prepare_compress_overwritewill enter endless loop, may casue hungtask.[ 14.088665] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155 [ 14.089851] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155Signed-off-by Fengnan Chang <[email protected]>---
fs/f2fs/compress.c| 21 ++++++++++++++++-----1 file changed, 16 insertions(+), 5 deletions(-)
Quoted 10 lines
Quoted 10 lines
fs/f2fs/compress.c static int prepare_compress_overwrite(struct compress_ctx *cc, · line 1063
Quoted 10 lines
fs/f2fs/compress.c +1
-1@@ -1060,7 +1060,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,sector_t last_block_in_bio;unsigned fgp_flag =FGP_LOCK |FGP_WRITE |FGP_CREAT ;pgoff_t start_idx =start_idx_of_cluster (cc); -int i, ret; +int i, ret, retry_count =3 ;
Wrap magic number w/ macro?
Quoted 14 lines
Quoted 14 lines
Quoted 4 lines
retry:
ret = f2fs_is_compressed_cluster(cc->inode, start_idx);fs/f2fs/compress.c static int prepare_compress_overwrite(struct compress_ctx *cc, · line 1128
Quoted 10 lines
fs/f2fs/compress.c +6
-1@@ -1120,7 +1120,12 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,f2fs_put_rpages (cc);f2fs_unlock_rpages (cc, i +1 );f2fs_destroy_compress_ctx (cc, true); - goto retry; + retry_count--; +if (PageError (page) && !retry_count) { + ret = -EIO ; + goto out; + }else + goto retry;
} else {
goto retry;
}Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
fs/f2fs/compress.c +9
-2} }@@ -1657,10 +1662,16 @@ static void __f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed)if (!rpage)continue ; -/* PG_error was set if verity failed. */ -if (failed ||PageError (rpage)) { +if (failed) { +/* decompress page failed */ +ClearPageUptodate (rpage); +SetPageError (rpage); + }else if (PageError (rpage)) { +/* +* PG_error was set if verity failed. +* will re-read again later. +*/ ClearPageUptodate (rpage);
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
fs/f2fs/compress.c +0
-2-/* will re-read again later */ ClearPageError (rpage); }else {SetPageUptodate (rpage); --2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 7 lines · Fengnan Chang
When decompressed failed,
f2fs_prepare_compress_overwritewill enter endless loop, may casue hungtask.[ 14.088665] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155 [ 14.089851] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155Signed-off-by Fengnan Chang <[email protected]>
This commit message only explains the problem, not the solution. It should explain the solution too.
Also, if it's fixing a bug, it needs 'Fixes' and 'Cc stable' tags.
Quoted 14 lines
fs/f2fs/compress.c +1
-1@@ -1060,7 +1060,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,sector_t last_block_in_bio;unsigned fgp_flag =FGP_LOCK |FGP_WRITE |FGP_CREAT ;pgoff_t start_idx =start_idx_of_cluster (cc); -int i, ret; +int i, ret, retry_count =3 ; retry: ret =f2fs_is_compressed_cluster (cc->inode, start_idx);
fs/f2fs/compress.c static int prepare_compress_overwrite(struct compress_ctx *cc, · line 1127
Quoted 9 lines
fs/f2fs/compress.c +5
-1@@ -1120,7 +1120,12 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,f2fs_put_rpages (cc);f2fs_unlock_rpages (cc, i +1 );f2fs_destroy_compress_ctx (cc, true); - goto retry; + retry_count--; +if (PageError (page) && !retry_count) { + ret = -EIO ; + goto out; + }else
What is the purpose of using PG_error here?
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 11 lines
2022年11月2日 10:05,Eric Biggers <[email protected]> 写道:
Quoted 6 lines · Fengnan Chang
When decompressed failed,
f2fs_prepare_compress_overwritewill enter endless loop, may casue hungtask.[ 14.088665] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155 [ 14.089851] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155
Quoted 6 lines
Quoted 1 line
Signed-off-by Fengnan Chang <[email protected]>This commit message only explains the problem, not the solution. It should explain the solution too.
Also, if it's fixing a bug, it needs 'Fixes' and 'Cc stable' tags.
I’ll add more explanation and tags, thanks.
Quoted 12 lines
Quoted 12 lines
fs/f2fs/compress.c +1
-1@@ -1060,7 +1060,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,sector_t last_block_in_bio;unsigned fgp_flag =FGP_LOCK |FGP_WRITE |FGP_CREAT ;pgoff_t start_idx =start_idx_of_cluster (cc); -int i, ret; +int i, ret, retry_count =3 ;
Quoted 14 lines
fs/f2fs/compress.c static int prepare_compress_overwrite(struct compress_ctx *cc, · line 1127
Quoted 12 lines
retry:
ret = f2fs_is_compressed_cluster(cc->inode, start_idx);fs/f2fs/compress.c +5
-1@@ -1120,7 +1120,12 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,f2fs_put_rpages (cc);f2fs_unlock_rpages (cc, i +1 );f2fs_destroy_compress_ctx (cc, true); - goto retry; + retry_count--; +if (PageError (page) && !retry_count) { + ret = -EIO ; + goto out; + }else What is the purpose of using
PG_errorhere?
In this version, we set PG_error when compressed failed, so check PG_error here. Maybe we can remove PG_error in later?
Quoted 2 lines
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 47 lines · fengnan chang
Quoted 11 lines
2022年11月2日 10:05,Eric Biggers <[email protected]> 写道:
Quoted 6 lines · Fengnan Chang
When decompressed failed,
f2fs_prepare_compress_overwritewill enter endless loop, may casue hungtask.[ 14.088665] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155 [ 14.089851] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155Quoted 6 lines
Quoted 1 line
Signed-off-by Fengnan Chang <[email protected]>This commit message only explains the problem, not the solution. It should explain the solution too.
Also, if it's fixing a bug, it needs 'Fixes' and 'Cc stable' tags.
I’ll add more explanation and tags, thanks.
Quoted 12 lines
Quoted 12 lines
fs/f2fs/compress.c +1
-1@@ -1060,7 +1060,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,sector_t last_block_in_bio;unsigned fgp_flag =FGP_LOCK |FGP_WRITE |FGP_CREAT ;pgoff_t start_idx =start_idx_of_cluster (cc); -int i, ret; +int i, ret, retry_count =3 ;Quoted 14 lines
fs/f2fs/compress.c static int prepare_compress_overwrite(struct compress_ctx *cc, · line 1127
Quoted 12 lines
retry:
ret = f2fs_is_compressed_cluster(cc->inode, start_idx);fs/f2fs/compress.c +5
-1@@ -1120,7 +1120,12 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,f2fs_put_rpages (cc);f2fs_unlock_rpages (cc, i +1 );f2fs_destroy_compress_ctx (cc, true); - goto retry; + retry_count--; +if (PageError (page) && !retry_count) { + ret = -EIO ; + goto out; + }else What is the purpose of using
PG_errorhere?
Quoted 3 lines
In this version, we set
PG_errorwhen compressed failed, so checkPG_errorhere. Maybe we can removePG_errorin later?
Read I/O errors can be detected via PG_uptodate not being set. There shouldn't be any need for PG_error here.
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 49 lines · Eric Biggers <[email protected]> 于2022年11月2日周三 11:18写道:
Quoted 47 lines · fengnan chang
Quoted 11 lines
2022年11月2日 10:05,Eric Biggers <[email protected]> 写道:
Quoted 6 lines · Fengnan Chang
When decompressed failed,
f2fs_prepare_compress_overwritewill enter endless loop, may casue hungtask.[ 14.088665] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155 [ 14.089851] F2FS-fs (nvme0n1): lz4 decompress failed, ret:-4155Quoted 6 lines
Quoted 1 line
Signed-off-by Fengnan Chang <[email protected]>This commit message only explains the problem, not the solution. It should explain the solution too.
Also, if it's fixing a bug, it needs 'Fixes' and 'Cc stable' tags.
I’ll add more explanation and tags, thanks.
Quoted 26 lines
Quoted 15 lines
fs/f2fs/compress.c +1
-1@@ -1060,7 +1060,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,sector_t last_block_in_bio;unsigned fgp_flag =FGP_LOCK |FGP_WRITE |FGP_CREAT ;pgoff_t start_idx =start_idx_of_cluster (cc); -int i, ret; +int i, ret, retry_count =3 ;retry:
ret = f2fs_is_compressed_cluster(cc->inode, start_idx);fs/f2fs/compress.c static int prepare_compress_overwrite(struct compress_ctx *cc, · line 1127
Quoted 9 lines
fs/f2fs/compress.c +5
-1@@ -1120,7 +1120,12 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,f2fs_put_rpages (cc);f2fs_unlock_rpages (cc, i +1 );f2fs_destroy_compress_ctx (cc, true); - goto retry; + retry_count--; +if (PageError (page) && !retry_count) { + ret = -EIO ; + goto out; + }else What is the purpose of using
PG_errorhere?
Quoted 6 lines
Quoted 3 lines
In this version, we set
PG_errorwhen compressed failed, so checkPG_errorhere. Maybe we can removePG_errorin later?Read I/O errors can be detected via
PG_uptodatenot being set. There shouldn't be any need forPG_errorhere.
Yeah, I get it now. Maybe we can remove PG_error in f2fs_verify_cluster too.
fs/f2fs/compress.c +0 -0
@@ -1727,10 +1727,9 @@ static void __f2fs_decompress_end_io(struct
decompress_io_ctx *dic, bool failed,
continue;
/* PG_error was set if verity failed. */
- if (failed || PageError(rpage)) {
- ClearPageUptodate(rpage);
+ if (failed) {
/* will re-read again later */
- ClearPageError(rpage);
+ ClearPageUptodate(rpage);
} else {
SetPageUptodate(rpage);
}
@@ -1745,13 +1744,14 @@ static void f2fs_verify_cluster(struct
work_struct *work)
struct decompress_io_ctx *dic =
container_of(work, struct decompress_io_ctx, verity_work);
int i;+ bool failed = false;
/* Verify the cluster's decompressed pages with fs-verity. */
for (i = 0; i < dic->cluster_size; i++) {
struct page *rpage = dic->rpages[i];
if (rpage && !fsverity_verify_page(rpage))
- SetPageError(rpage);
+ failed = true;
}
__f2fs_decompress_end_io(dic, false, true);Quoted 2 lines
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 34 lines · fengnan chang
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
What is the purpose of using
PG_errorhere?In this version, we set
PG_errorwhen compressed failed, so checkPG_errorhere. Maybe we can removePG_errorin later?Read I/O errors can be detected via
PG_uptodatenot being set. There shouldn't be any need forPG_errorhere.Yeah, I get it now. Maybe we can remove
PG_errorinf2fs_verify_clustertoo.fs/f2fs/compress.c +2
-3@@ -1727,10 +1727,9 @@ static void __f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed, continue;/* PG_error was set if verity failed. */ -if (failed ||PageError (rpage)) { -ClearPageUptodate (rpage); +if (failed) {/* will re-read again later */ -ClearPageError (rpage); +ClearPageUptodate (rpage); }else {SetPageUptodate (rpage);}fs/f2fs/compress.c +0
-0@@ -1745,13 +1744,14 @@ static void f2fs_verify_cluster(struct work_struct *work)struct decompress_io_ctx *dic = container_of(work, struct decompress_io_ctx, verity_work);int i;
fs/f2fs/compress.c static void f2fs_verify_cluster(struct · line 1756
Quoted 10 lines
fs/f2fs/compress.c +2
-1+bool failed = false;/* Verify the cluster's decompressed pages with fs-verity. */ for (i =0 ; i < dic->cluster_size; i++) {struct page *rpage = dic->rpages[i];if (rpage && !fsverity_verify_page (rpage)) -SetPageError (rpage); + failed = true; }
No, PG_error is still used to notify f2fs_finish_read_bio() and __f2fs_decompress_end_io() of verity errors. My patch
https://lore.kernel.org/r/[email protected] changes that. Please leave that to my patch. For your patch, please just don't add a new use of PG_error, as it doesn't seem to be necessary.
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel