virtiofsd: Fix data corruption with O_APPEND write in writeback mode
commit8e4e41e39eac5ee5f378d66f069a2f70a1734317
authorMisono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Wed, 23 Oct 2019 12:25:23 +0000 (23 21:25 +0900)
committerDr. David Alan Gilbert <dgilbert@redhat.com>
Thu, 23 Jan 2020 16:41:37 +0000 (23 16:41 +0000)
tree97438c5efe0cffbb78899314557c712a9c625068
parent65da4539803373ec4eec97ffc49ee90083e56efd
virtiofsd: Fix data corruption with O_APPEND write in writeback mode

When writeback mode is enabled (-o writeback), O_APPEND handling is
done in kernel. Therefore virtiofsd clears O_APPEND flag when open.
Otherwise O_APPEND flag takes precedence over pwrite() and write
data may corrupt.

Currently clearing O_APPEND flag is done in lo_open(), but we also
need the same operation in lo_create(). So, factor out the flag
update operation in lo_open() to update_open_flags() and call it
in both lo_open() and lo_create().

This fixes the failure of xfstest generic/069 in writeback mode
(which tests O_APPEND write data integrity).

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
tools/virtiofsd/passthrough_ll.c