mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-07 04:26:29 +00:00
As a regular file reader first acquires a cluster lock it checks the file's extents to see if the region it is reading contains offline extents. When this was written the extent operations didn't have their own internal locking. It was up to callers to use vfs mechanisms to serialize readers and writers. The aio_read data_wait_check extent caller tried to use dio_count and an i_mutex acquisition to ensure that our ioctls wouldn't modify extents. This creates a bad inversion between the vfs i_mutex and our cluster inode lock. There are lots of fs methods which are called by the vfs with i_mutex held which acquire a lock. This read case was holding a cluster lock and then acquiring i_mutex. Since the data waiting was written the file data extent operations have added their own extent_sem to protect the extent items from concurrent callers. We can rely on that internal locking and drop the bad i_mutex use which causes the inversion. Not surprisingly, this was trivial to deadlock by racing simple utilities like cat and touch. Signed-off-by: Zach Brown <zab@versity.com>