Chao Yu 5079e1c0c8 f2fs: avoid dead loop in f2fs_issue_checkpoint()
generic/082 reports a bug as below:

__schedule+0x332/0xf60
schedule+0x6f/0xf0
schedule_timeout+0x23b/0x2a0
wait_for_completion+0x8f/0x140
f2fs_issue_checkpoint+0xfe/0x1b0
f2fs_sync_fs+0x9d/0xb0
sync_filesystem+0x87/0xb0
dquot_load_quota_sb+0x41b/0x460
dquot_load_quota_inode+0xa5/0x130
dquot_quota_on+0x4b/0x60
f2fs_quota_on+0xe3/0x1b0
do_quotactl+0x483/0x700
__x64_sys_quotactl+0x15c/0x310
do_syscall_64+0x3f/0x90
entry_SYSCALL_64_after_hwframe+0x72/0xdc

The root casue is race case as below:

Thread A			Kworker			IRQ
- write()
: write data to quota.user file

				- writepages
				 - f2fs_submit_page_write
				  - __is_cp_guaranteed return false
				  - inc_page_count(F2FS_WB_DATA)
				 - submit_bio
- quotactl(Q_QUOTAON)
 - f2fs_quota_on
  - dquot_quota_on
   - dquot_load_quota_inode
    - vfs_setup_quota_inode
    : inode->i_flags |= S_NOQUOTA
							- f2fs_write_end_io
							 - __is_cp_guaranteed return true
							 - dec_page_count(F2FS_WB_CP_DATA)
    - dquot_load_quota_sb
     - f2fs_sync_fs
      - f2fs_issue_checkpoint
       - do_checkpoint
        - f2fs_wait_on_all_pages(F2FS_WB_CP_DATA)
        : loop due to F2FS_WB_CP_DATA count is negative

Calling filemap_fdatawrite() and filemap_fdatawait() to keep all data
clean before quota file setup.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2023-06-12 13:37:36 -07:00
..
2023-05-05 19:12:01 -07:00
2023-02-20 14:10:36 -08:00
2023-04-26 09:13:44 -07:00
2023-05-05 04:29:58 -05:00
2023-04-27 16:52:33 -07:00
2023-02-27 10:04:49 -08:00
2023-04-26 16:07:23 -07:00
2023-04-24 14:25:39 -07:00
2023-03-01 08:42:27 -08:00
\n
2023-04-26 09:07:46 -07:00
2023-04-27 11:53:57 -07:00
2023-04-26 09:28:15 -07:00
2023-04-29 10:35:48 -07:00
2023-04-24 19:20:27 -07:00
2023-04-27 11:53:57 -07:00
2023-04-29 11:04:14 -07:00
2023-04-29 11:04:14 -07:00
2023-04-03 11:16:57 +02:00
2023-04-29 10:52:37 -07:00
2023-04-27 17:03:40 -07:00
2023-03-14 12:56:30 -06:00
\n
2023-04-26 09:07:46 -07:00
2023-03-12 20:03:41 -04:00
2023-04-29 10:44:27 -07:00
2023-03-30 08:51:48 +02:00
2023-04-08 13:45:37 -07:00
2023-04-05 18:06:23 -07:00
2022-10-10 19:45:17 -07:00
2023-04-28 15:57:53 -07:00
2023-02-20 11:53:11 -08:00
2023-05-06 08:28:58 -07:00
2022-10-10 14:21:11 -07:00
2023-01-19 09:24:30 +01:00
2023-04-24 19:14:20 -07:00
2023-04-25 14:08:59 -06:00
2023-04-06 14:53:38 +02:00
2023-03-06 09:59:20 +01:00
2023-05-06 08:15:20 -07:00
2023-02-20 11:53:11 -08:00
2023-02-20 11:53:11 -08:00
2023-03-06 09:59:20 +01:00