I have merged two series here: (1) Using inode_lock_shared for <EOF DIO writes (2) Fix O_DSYNC | O_DIRECT Both require inode locking to be pushed closer to I/O calls and thought was relevant. (2) requires changes in iomap code. If there is a need to separate the two please let me know. I don't have any ulterior motives here ;) Testing: xfstests on both btrfs and xfs Git: https://github.com/goldwynr/linux/tree/btrfs-inode-lock Changes since v1: - Changed fix for deadlock due to O_DSYNC (iomap patches added) - btrfs_inode_lock() shifted to inode.c - Reinstated lockdep_assert_held() in iomap_dio_rw() -- Goldwyn fs/btrfs/btrfs_inode.h | 28 -- fs/btrfs/ctree.h | 13 + fs/btrfs/file.c | 497 +++++++++++++++++++++++++++---------------------- fs/btrfs/inode.c | 176 +++-------------- fs/btrfs/transaction.h | 1 fs/direct-io.c | 19 - fs/iomap/direct-io.c | 38 ++- include/linux/fs.h | 2 include/linux/iomap.h | 5 9 files changed, 355 insertions(+), 424 deletions(-)