Whamcloud - gitweb
LU-12382 llite: fix deadloop with tiny write 58/35058/7
authorWang Shilong <wshilong@ddn.com>
Tue, 4 Jun 2019 12:54:01 +0000 (20:54 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 25 Jun 2019 01:55:15 +0000 (01:55 +0000)
commite9a543b0d3039027423cb469525015f97caa3a3f
tree4b3b16619635f078b566cbe8147f6d11f7d45502
parenta32ce8f50ecafa4fd44732023cc1d45f57cd56bd
LU-12382 llite: fix deadloop with tiny write

For a small write(<4K), we will use tiny write and
__generic_file_write_iter() will be called to handle it.

On newer kernel(4.14 etc), the function is exported and will
do something like following:

|->__generic_file_write_iter
  |->generic_perform_write()

If iov_iter_count() passed in is 0, generic_write_perform() will
try go to forever loop as bytes copied is always calculated as 0.

The problem is VFS doesn't always skip IO count zero before it comes
to lower layer read/write hook, and we should do it by ourselves.

To fix this problem, always return 0 early if there is no
real any IO needed.

Change-Id: I765a723da79eb5fd09317c3fad47fe479b1dd4fb
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/35058
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Jenkins
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/file.c
lustre/tests/sanity.sh
lustre/tests/writeme.c