Suparna Bhattacharya wrote: >http://www.kernel.org/pub/linux/kernel/people/suparna/DIO-simplify.txt >(also inlined below) > > Hi, Suparna, It would be nice to ensure that the lock sequence will not cause issues for out-of-tree external kernel modules (e.g. cluster files System) that require extra locking for various purposes. We've found several deadlocks issues in Global File System (GFS) Direct IO path due to lock order enforced by VFS layer: 1) In sys_ftruncate()->do_truncate(), VFS layer grabs * i_sem * then i_alloc_sem (i_mutex) * then call filesystem's setattr(). 2) In Direct IO read, VFS layer calls * filesystem's direct_IO() * grabs i_sem (i_mutex) * followed by i_alloc_sem. In our case, both gfs_setattr() and gfs_direct_IO() need its own (global) locks to synchronize inter-nodes (and inter-processes) control structures access but gfs_direct_IO later ends up in __blockdev_direct_IO path that deadlocks with i_sem (i_mutex) and i_alloc_sem. A new DIO flag is added into our distribution (2.6.9 based) to work around the problem by moving the inode semaphore acquiring within __blockdev_direct_IO() (patch attached) into GFS code path (so lock order can be re-arranged). The new lock granularity is not ideal but it gets us out of this deadlock. We havn't had a chance to go thru your mail (and patch) in details yet but would like bring up this issue earlier before it gets messy. -- Wendy