Skip to content

splice: i_mutex vs splice write deadlock

Dave Chinner linux-fsdevel linux-xfs lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2vfs: split generic splice code from i_mutex lockingfs/splice.c include/linux/fs.h+37 -40 replies
2/2xfs: fix splice/direct-IO deadlockfs/xfs/linux-2.6/xfs_file.c+2 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] splice: i_mutex vs splice write deadlock

generic_file_splice_write() takes the inode->i_mutex after the filesystem has taken whatever locks it needs to ensure sanity. however, this typically violates the locking order of filesystems with their own locks in that the order is usually i_mutex -> filesystem lock.

XFS is such a case, and generic_file_splice_write() is generating lockdep warnings because of lock inversions between the inode->i_mutex and the XFS_I(inode)->i_iolock. There is also a reported case of fio causing a deadlock when it mixes IO types (e.g. splice vs direct IO).

This patch set introduces generic_file_splice_write_unlocked() and factors the code such that __generic_file_splice_write() will only lock the i_mutex if called from the locked variant. The second patch modifies XFS to use the new function.