Whamcloud - gitweb
LU-12382 llite: fix deadloop with tiny write 12/35312/2
authorWang Shilong <wshilong@ddn.com>
Tue, 4 Jun 2019 12:54:01 +0000 (20:54 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 3 Jul 2019 03:23:33 +0000 (03:23 +0000)
commit31f3bfb87ef02dd6c7f56f897a293406e846c4d9
tree6ff64f7d4098c85af4cd9738d81dee176231997e
parentf35d0fd92c063aa2b0c4d937c45dfc25729df550
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.

Lustre-change: https://review.whamcloud.com/35058
Lustre-commit: e9a543b0d3039027423cb469525015f97caa3a3f

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