f2fs: clear cold data flag if IO is not counted
Jaegeuk Kim
maintainerPATCH 1/1 f2fs: clear cold data flag if IO is not counted
If we clear the cold data flag out of the writeback flow, we can miscount -1 by end_io.
--- fs/f2fs/data.c | 4 ---- 1 file changed, 4 deletions(-)
fs/f2fs/data.c +0 -4
@@ -2636,10 +2636,6 @@ static int f2fs_set_data_page_dirty(struct page *page)if (!PageUptodate (page))SetPageUptodate (page); -/* don't remain PG_checked flag which was set during GC */ -if (is_cold_data (page)) -clear_cold_data (page); -if (f2fs_is_atomic_file (inode) && !f2fs_is_commit_atomic_write (inode)) {if (!IS_ATOMIC_WRITTEN_PAGE (page)) {f2fs_register_inmem_page (inode, page);
Signature · 1 line
2.19.0.605.g01d371f741-goog
Quoted 2 lines · Jaegeuk Kim
If we clear the cold data flag out of the writeback flow, we can miscount -1 by
end_io.
I didn't get it, which count do you mean?
Thanks,
Quoted 22 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/data.c | 4 ---- 1 file changed, 4 deletions(-)fs/f2fs/data.c +0
-4@@ -2636,10 +2636,6 @@ static int f2fs_set_data_page_dirty(struct page *page)if (!PageUptodate (page))SetPageUptodate (page); -/* don't remain PG_checked flag which was set during GC */ -if (is_cold_data (page)) -clear_cold_data (page); -if (f2fs_is_atomic_file (inode) && !f2fs_is_commit_atomic_write (inode)) {if (!IS_ATOMIC_WRITTEN_PAGE (page)) {f2fs_register_inmem_page (inode, page);
Jaegeuk Kim
maintainerQuoted 5 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
If we clear the cold data flag out of the writeback flow, we can miscount -1 by
end_io.I didn't get it, which count do you mean?
It's the number of dirty pages.
Balancing F2FS Async:
- IO (CP: 1, Data: -1, Flush: ( 0 0 1), Discard: ( 0 129304)) cmd: 0 undiscard: 0
Quoted 25 lines
Thanks,
Quoted 22 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/data.c | 4 ---- 1 file changed, 4 deletions(-)fs/f2fs/data.c +0
-4@@ -2636,10 +2636,6 @@ static int f2fs_set_data_page_dirty(struct page *page)if (!PageUptodate (page))SetPageUptodate (page); -/* don't remain PG_checked flag which was set during GC */ -if (is_cold_data (page)) -clear_cold_data (page); -if (f2fs_is_atomic_file (inode) && !f2fs_is_commit_atomic_write (inode)) {if (!IS_ATOMIC_WRITTEN_PAGE (page)) {f2fs_register_inmem_page (inode, page);
Quoted 5 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
If we clear the cold data flag out of the writeback flow, we can miscount -1 by
end_io.
Quoted 7 lines
Quoted 1 line
I didn't get it, which count do you mean?
It's the number of dirty pages.
Balancing F2FS Async:
- IO (CP: 1, Data: -1, Flush: ( 0 0 1), Discard: ( 0 129304)) cmd: 0 undiscard: 0
So I guess the race should be:
GC thread: IRQ
- move_data_page()
- set_page_dirty()
- clear_cold_data()
- f2fs_write_end_io()
- type = WB_DATA_TYPE(page); here, we get wrong type
- dec_page_count(sbi, type);
- f2fs_wait_on_page_writeback()
How about relocate wait_writeback & set_page_dirty to avoid above race:
move_data_page()
retry:
f2fs_wait_on_page_writeback(page, DATA, true); set_page_dirty(page);
Thanks,
Quoted 28 lines
Quoted 17 lines
Thanks,
Quoted 14 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/data.c | 4 ---- 1 file changed, 4 deletions(-)fs/f2fs/data.c +0
-0@@ -2636,10 +2636,6 @@ static int f2fs_set_data_page_dirty(struct page *page)if (!PageUptodate (page))SetPageUptodate (page);Quoted 8 lines
fs/f2fs/data.c static int f2fs_set_data_page_dirty(struct page *page) · line 2641
Quoted 8 lines
fs/f2fs/data.c +0
-4-/* don't remain PG_checked flag which was set during GC */ -if (is_cold_data (page)) -clear_cold_data (page); -if (f2fs_is_atomic_file (inode) && !f2fs_is_commit_atomic_write (inode)) {if (!IS_ATOMIC_WRITTEN_PAGE (page)) {f2fs_register_inmem_page (inode, page);.
Jaegeuk Kim
maintainerQuoted 26 lines · Chao Yu
Quoted 5 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
If we clear the cold data flag out of the writeback flow, we can miscount -1 by
end_io.Quoted 7 lines
Quoted 1 line
I didn't get it, which count do you mean?
It's the number of dirty pages.
Balancing F2FS Async:
- IO (CP: 1, Data: -1, Flush: ( 0 0 1), Discard: ( 0 129304)) cmd: 0 undiscard: 0So I guess the race should be:
GC thread: IRQ
-move_data_page()
-set_page_dirty()
-clear_cold_data()
-f2fs_write_end_io()
- type =WB_DATA_TYPE(page); here, we get wrong type
-dec_page_count(sbi, type);
-f2fs_wait_on_page_writeback()
Quoted 1 line
How about relocate
wait_writeback&set_page_dirtyto avoid above race:
Well, wait_on_stable_page() doesn't guarantee its end_io. So, I'm not sure this is the only case.
Quoted 37 lines
move_data_page()retry:
f2fs_wait_on_page_writeback(page, DATA, true); set_page_dirty(page);Thanks,
Quoted 28 lines
Quoted 17 lines
Thanks,
Quoted 14 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/data.c | 4 ---- 1 file changed, 4 deletions(-)fs/f2fs/data.c +0
-0@@ -2636,10 +2636,6 @@ static int f2fs_set_data_page_dirty(struct page *page)if (!PageUptodate (page))SetPageUptodate (page);Quoted 8 lines
fs/f2fs/data.c static int f2fs_set_data_page_dirty(struct page *page) · line 2641
Quoted 8 lines
fs/f2fs/data.c +0
-4-/* don't remain PG_checked flag which was set during GC */ -if (is_cold_data (page)) -clear_cold_data (page); -if (f2fs_is_atomic_file (inode) && !f2fs_is_commit_atomic_write (inode)) {if (!IS_ATOMIC_WRITTEN_PAGE (page)) {f2fs_register_inmem_page (inode, page);.
Quoted 7 lines · Jaegeuk Kim
Quoted 6 lines · Chao Yu
Quoted 5 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
If we clear the cold data flag out of the writeback flow, we can miscount -1 by
end_io.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
I didn't get it, which count do you mean?
It's the number of dirty pages.
Balancing F2FS Async:
- IO (CP: 1, Data: -1, Flush: ( 0 0 1), Discard: ( 0 129304)) cmd: 0 undiscard: 0
Better to add such info in commit message. :)
Quoted 14 lines
Quoted 14 lines
Quoted 1 line
So I guess the race should be:
GC thread: IRQ
-move_data_page()
-set_page_dirty()
-clear_cold_data()
-f2fs_write_end_io()
- type =WB_DATA_TYPE(page); here, we get wrong type
-dec_page_count(sbi, type);
-f2fs_wait_on_page_writeback()
Quoted 4 lines
Quoted 1 line
How about relocate
wait_writeback&set_page_dirtyto avoid above race:Well,
wait_on_stable_page()doesn't guarantee itsend_io. So, I'm not sure this is the only case.
Yes, you're right, I missed that case.
Can you use git-revert to generate the patch? so we can remain original commit info for better backward tracking.
How do you think pick up original patch I submitted:
https://lkml.org/lkml/2018/7/27/415
Thanks,
Quoted 41 lines
Quoted 38 lines
move_data_page()retry:
f2fs_wait_on_page_writeback(page, DATA, true); set_page_dirty(page);Thanks,
Quoted 28 lines
Quoted 17 lines
Thanks,
Quoted 14 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/data.c | 4 ---- 1 file changed, 4 deletions(-)fs/f2fs/data.c +0
-0@@ -2636,10 +2636,6 @@ static int f2fs_set_data_page_dirty(struct page *page)if (!PageUptodate (page))SetPageUptodate (page);Quoted 8 lines
fs/f2fs/data.c static int f2fs_set_data_page_dirty(struct page *page) · line 2641
Quoted 8 lines
fs/f2fs/data.c +0
-4-/* don't remain PG_checked flag which was set during GC */ -if (is_cold_data (page)) -clear_cold_data (page); -if (f2fs_is_atomic_file (inode) && !f2fs_is_commit_atomic_write (inode)) {if (!IS_ATOMIC_WRITTEN_PAGE (page)) {f2fs_register_inmem_page (inode, page);.
.
Jaegeuk Kim
maintainerQuoted 36 lines · Chao Yu
Quoted 7 lines · Jaegeuk Kim
Quoted 6 lines · Chao Yu
Quoted 5 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
If we clear the cold data flag out of the writeback flow, we can miscount -1 by
end_io.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
I didn't get it, which count do you mean?
It's the number of dirty pages.
Balancing F2FS Async:
- IO (CP: 1, Data: -1, Flush: ( 0 0 1), Discard: ( 0 129304)) cmd: 0 undiscard: 0Better to add such info in commit message. :)
Quoted 14 lines
Quoted 14 lines
Quoted 1 line
So I guess the race should be:
GC thread: IRQ
-move_data_page()
-set_page_dirty()
-clear_cold_data()
-f2fs_write_end_io()
- type =WB_DATA_TYPE(page); here, we get wrong type
-dec_page_count(sbi, type);
-f2fs_wait_on_page_writeback()Quoted 4 lines
Quoted 1 line
How about relocate
wait_writeback&set_page_dirtyto avoid above race:Well,
wait_on_stable_page()doesn't guarantee itsend_io. So, I'm not sure this is the only case.
Quoted 8 lines
Yes, you're right, I missed that case.
Can you use git-revert to generate the patch? so we can remain original commit info for better backward tracking.
How do you think pick up original patch I submitted:
Seems that works.
Thanks,
Quoted 44 lines
Thanks,
Quoted 41 lines
Quoted 38 lines
move_data_page()retry:
f2fs_wait_on_page_writeback(page, DATA, true); set_page_dirty(page);Thanks,
Quoted 28 lines
Quoted 17 lines
Thanks,
Quoted 14 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/data.c | 4 ---- 1 file changed, 4 deletions(-)fs/f2fs/data.c +0
-0@@ -2636,10 +2636,6 @@ static int f2fs_set_data_page_dirty(struct page *page)if (!PageUptodate (page))SetPageUptodate (page);Quoted 8 lines
fs/f2fs/data.c static int f2fs_set_data_page_dirty(struct page *page) · line 2641
Quoted 8 lines
fs/f2fs/data.c +0
-4-/* don't remain PG_checked flag which was set during GC */ -if (is_cold_data (page)) -clear_cold_data (page); -if (f2fs_is_atomic_file (inode) && !f2fs_is_commit_atomic_write (inode)) {if (!IS_ATOMIC_WRITTEN_PAGE (page)) {f2fs_register_inmem_page (inode, page);.
.
Jaegeuk Kim
maintainerThis reverts commit 66110abc4c931f879d70e83e1281f891699364bf.
If we clear the cold data flag out of the writeback flow, we can miscount -1 by end_io.
Balancing F2FS Async:
- IO (CP: 1, Data: -1, Flush: ( 0 0 1), Discard: ( ...
GC thread: IRQ
- move_data_page()
- set_page_dirty()
- clear_cold_data()
- f2fs_write_end_io()
- type = WB_DATA_TYPE(page); here, we get wrong type
- dec_page_count(sbi, type);
- f2fs_wait_on_page_writeback()
--- fs/f2fs/data.c | 4 ---- 1 file changed, 4 deletions(-)
fs/f2fs/data.c +0 -4
@@ -2650,10 +2650,6 @@ static int f2fs_set_data_page_dirty(struct page *page)if (!PageUptodate (page))SetPageUptodate (page); -/* don't remain PG_checked flag which was set during GC */ -if (is_cold_data (page)) -clear_cold_data (page); -if (f2fs_is_atomic_file (inode) && !f2fs_is_commit_atomic_write (inode)) {if (!IS_ATOMIC_WRITTEN_PAGE (page)) {f2fs_register_inmem_page (inode, page);
Signature · 1 line
2.19.0.605.g01d371f741-goog
Chao Yu
Reviewed-byQuoted 18 lines · Jaegeuk Kim
This reverts commit
66110abc4c931f879d70e83e1281f891699364bf.If we clear the cold data flag out of the writeback flow, we can miscount -1 by
end_io.Balancing F2FS Async:
- IO (CP: 1, Data: -1, Flush: ( 0 0 1), Discard: ( ...GC thread: IRQ
-move_data_page()
-set_page_dirty()
-clear_cold_data()
-f2fs_write_end_io()
- type =WB_DATA_TYPE(page); here, we get wrong type
-dec_page_count(sbi, type);
-f2fs_wait_on_page_writeback()
Quoted 2 lines
Cc <[email protected]>Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
Ju Hyung Park
Tested-byThis does seem to fix the problem I've been having.
I was encountering all I/Os to be blocked on my Android device almost on a daily basis, but after this patch I'm rock solid for almost a week.
I'd appreciate it if you could add the following tags:
Also, a little additional note would be helpful
for those who are unfamiliar with f2fs:
This fixes a deadlock causing all I/Os to be blocked during heavy GC.
Thanks,
Quoted 49 lines · Jaegeuk Kim
This reverts commit
66110abc4c931f879d70e83e1281f891699364bf.If we clear the cold data flag out of the writeback flow, we can miscount -1 by
end_io.Balancing F2FS Async:
- IO (CP: 1, Data: -1, Flush: ( 0 0 1), Discard: ( ...GC thread: IRQ
-move_data_page()
-set_page_dirty()
-clear_cold_data()
-f2fs_write_end_io()
- type =WB_DATA_TYPE(page); here, we get wrong type
-dec_page_count(sbi, type);
-f2fs_wait_on_page_writeback()Cc <[email protected]>Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/data.c | 4 ---- 1 file changed, 4 deletions(-)fs/f2fs/data.c +0
-5@@ -2650,10 +2650,6 @@ static int f2fs_set_data_page_dirty(struct page *page)if (!PageUptodate (page))SetPageUptodate (page); -/* don't remain PG_checked flag which was set during GC */ -if (is_cold_data (page)) -clear_cold_data (page); -if (f2fs_is_atomic_file (inode) && !f2fs_is_commit_atomic_write (inode)) {if (!IS_ATOMIC_WRITTEN_PAGE (page)) {f2fs_register_inmem_page (inode, page); --2.19.0.605.g01d371f741-goog
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerQuoted 5 lines · Ju Hyung Park
This does seem to fix the problem I've been having.
I was encountering all I/Os to be blocked on my Android device almost on a daily basis, but after this patch I'm rock solid for almost a week.
Quoted 7 lines
I'd appreciate it if you could add the following tags:
Reported-by Park Ju Hyung <[email protected]>Tested-by Park Ju Hyung <[email protected]>Also, a little additional note would be helpful
for those who are unfamiliar with f2fs:
This fixes a deadlock causing all I/Os to be blocked during heavy GC.
Cool. Please check the below. :P
Thanks,
Quoted 52 lines
Thanks,
Quoted 49 lines · Jaegeuk Kim
This reverts commit
66110abc4c931f879d70e83e1281f891699364bf.If we clear the cold data flag out of the writeback flow, we can miscount -1 by
end_io.Balancing F2FS Async:
- IO (CP: 1, Data: -1, Flush: ( 0 0 1), Discard: ( ...GC thread: IRQ
-move_data_page()
-set_page_dirty()
-clear_cold_data()
-f2fs_write_end_io()
- type =WB_DATA_TYPE(page); here, we get wrong type
-dec_page_count(sbi, type);
-f2fs_wait_on_page_writeback()Cc <[email protected]>Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/data.c | 4 ---- 1 file changed, 4 deletions(-)fs/f2fs/data.c +0
-5@@ -2650,10 +2650,6 @@ static int f2fs_set_data_page_dirty(struct page *page)if (!PageUptodate (page))SetPageUptodate (page); -/* don't remain PG_checked flag which was set during GC */ -if (is_cold_data (page)) -clear_cold_data (page); -if (f2fs_is_atomic_file (inode) && !f2fs_is_commit_atomic_write (inode)) {if (!IS_ATOMIC_WRITTEN_PAGE (page)) {f2fs_register_inmem_page (inode, page); --2.19.0.605.g01d371f741-goog
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel