android_kernel_oneplus_msm8998/fs/f2fs
Chao Yu ecf753b370 f2fs: fix potential data inconsistence of checkpoint
Previously, we changed lock from cp_rwsem to node_change, it solved
the deadlock issue which was caused by below race condition:

Thread A			Thread B
- f2fs_setattr
 - f2fs_lock_op  -- read_lock
 - dquot_transfer
  - __dquot_transfer
   - dquot_acquire
    - commit_dqblk
     - f2fs_quota_write
      - f2fs_write_begin
       - f2fs_write_failed
				- write_checkpoint
				 - block_operations
				  - f2fs_lock_all  -- write_lock
        - f2fs_truncate_blocks
         - f2fs_lock_op  -- read_lock

But it breaks the sematics of cp_rwsem, in other callers like:
- f2fs_file_write_iter -> f2fs_write_begin -> f2fs_write_failed
- f2fs_direct_IO -> f2fs_write_failed

We allow to truncate dnode w/o cp_rwsem held, result in incorrect sit
bitmap update, which can cause further data corruption.

So this patch reverts previous fix implementation, and try to fix
deadlock by skipping calling f2fs_truncate_blocks() in f2fs_write_failed()
only for quota file, and keep the preallocated data/node in the tail of
quota file, we can expecte that the preallocated space can be used to
store quota info latter soon.

Fixes: af033b2aa8a8 ("f2fs: guarantee journalled quota data by checkpoint")
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2019-02-04 10:51:25 -08:00
..
acl.c f2fs: use kvmalloc, if kmalloc is failed 2019-01-02 16:17:37 -08:00
acl.h f2fs: add SPDX license identifiers 2018-10-27 11:57:18 -07:00
checkpoint.c f2fs: sync filesystem after roll-forward recovery 2019-02-04 10:50:02 -08:00
data.c f2fs: fix potential data inconsistence of checkpoint 2019-02-04 10:51:25 -08:00
debug.c f2fs: no need to check return value of debugfs_create functions 2019-02-04 10:33:49 -08:00
dir.c f2fs: check if file namelen exceeds max value 2019-02-04 10:33:52 -08:00
extent_cache.c f2fs: add SPDX license identifiers 2018-10-27 11:57:18 -07:00
f2fs.h f2fs: fix potential data inconsistence of checkpoint 2019-02-04 10:51:25 -08:00
file.c f2fs: fix potential data inconsistence of checkpoint 2019-02-04 10:51:25 -08:00
gc.c f2fs: check PageWriteback flag for ordered case 2019-01-02 16:17:53 -08:00
gc.h f2fs: add SPDX license identifiers 2018-10-27 11:57:18 -07:00
hash.c f2fs: add SPDX license identifiers 2018-10-27 11:57:18 -07:00
inline.c f2fs: fix potential data inconsistence of checkpoint 2019-02-04 10:51:25 -08:00
inode.c f2fs: check PageWriteback flag for ordered case 2019-01-02 16:17:53 -08:00
Kconfig f2fs: remove wrong backported codes 2017-01-11 09:55:38 -08:00
Makefile f2fs: move sysfs code from super.c to fs/f2fs/sysfs.c 2017-07-13 16:56:51 -07:00
namei.c f2fs: use kvmalloc, if kmalloc is failed 2019-01-02 16:17:37 -08:00
node.c f2fs: sync filesystem after roll-forward recovery 2019-02-04 10:50:02 -08:00
node.h f2fs: check PageWriteback flag for ordered case 2019-01-02 16:17:53 -08:00
recovery.c f2fs: check PageWriteback flag for ordered case 2019-01-02 16:17:53 -08:00
segment.c f2fs: fix to avoid deadlock of atomic file operations 2019-02-04 10:51:23 -08:00
segment.h f2fs: don't wake up too frequently, if there is lots of IOs 2019-02-04 10:34:05 -08:00
shrinker.c f2fs: fix sbi->extent_list corruption issue 2019-01-02 16:17:44 -08:00
super.c f2fs: fix to check inline_xattr_size boundary correctly 2019-02-04 10:51:22 -08:00
sysfs.c f2fs: run discard jobs when put_super 2019-02-04 10:33:59 -08:00
trace.c f2fs: add SPDX license identifiers 2018-10-27 11:57:18 -07:00
trace.h f2fs: add SPDX license identifiers 2018-10-27 11:57:18 -07:00
xattr.c f2fs: sanity check of xattr entry size 2019-01-02 16:17:57 -08:00
xattr.h f2fs: add SPDX license identifiers 2018-10-27 11:57:18 -07:00