On Wed, Aug 31 2016, Yan, Zheng wrote: > On Wed, Aug 31, 2016 at 10:56 AM, NeilBrown <neilb@xxxxxxxx> wrote: >> >> Hi, >> it is quite possible for O_DIRECT and buffered writes to a file to >> race. >> The xfstests test suite has a test - generic/036 - which tests this >> case. >> >> Unlike most filesystems, cephfs does not hold inode_lock() across >> direct writes. This means that buffer pages can become dirty while >> direct writes are happening. This confused ceph a little. > > how about make ceph_write_iter() hold inode_lock() for direct/sync write? You could probably do that. You could even use inode_lock_shared() to allow multiple writers to perform O_DIRECT writes to the same file in parallel. But I don't know why ceph did this differently from every other filesystem, and the git commit message doesn't shine any light on that question. I didn't want to propose a change that I didn't understand the consequences of. If you did extend the locking over ceph_direct_read_write(), it would probably make sense to remove the truncate_inode_pages_range() call as it should be redundant. Thanks, NeilBrown > > Regards > Yan, Zheng >> >> The following two patches allow ceph to handle this possibility a >> little more cleanly. The more important patch removes a WARN_ON() for >> a circumstance which can easily be triggered. >> >> Thanks, >> NeilBrown
Attachment:
signature.asc
Description: PGP signature