On Sun, Aug 04, 2024 at 04:02:51PM +0800, Yafang Shao wrote: > One solution we're currently exploring is leveraging the preadv2(2) > syscall. By using the RWF_NOWAIT flag, preadv2(2) can avoid the XFS inode > lock hung task. This can be illustrated as follows: > > retry: > if (preadv2(fd, iovec, cnt, offset, RWF_NOWAIT) < 0) { > sleep(n) > goto retry; But that's not how you're supposed to use RWF_NOWAIT! You're supposed to try it _once_ in the thread that can't block, then hand the I/O off to another thread which _can_ block. Because that single thread is the one which does all the blocking I/O, there's no lock contention. So this is a kernel workaround for bad application design, and should be rejected.