xfs
[Top] [All Lists]

Re: xfs_file_splice_read: possible circular locking dependency detected

To: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Subject: Re: xfs_file_splice_read: possible circular locking dependency detected
From: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 8 Sep 2016 11:12:33 -0700
Cc: CAI Qian <caiqian@xxxxxxxxxx>, Dave Chinner <david@xxxxxxxxxxxxx>, linux-xfs <linux-xfs@xxxxxxxxxxxxxxx>, xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=5O9Ex7lNWDptg8oaKKVBWMdLFswxXDWJ4uNR63rPn5w=; b=NAr1JmxJkMjdzvZmdOTZ+fsTo9fCXSHXiKI84kecrH4sBCbElyq4vyubQVfieTp6Ka MvrYcmsP22yzRi3hPAnieEX6pu/9BMFvTpUm5RFcoqqb0YkXQ6lMJBPSlhq3iUH3WidH chEL/CG/4/UThcJyGctzdoQl2CpE4Jw4YzKO2N+Y0I75eAnQkRnmJFfgjjzq0UZa12mG 5PYWHDF9Jxc+qdyKF4fQU4Aj0FzrJTkHv93kX32tb5SAOpmGYz+EJ70OW5Gbqu1diNOA 1r7cDHUzVqXni8JowIB97AMSgOfKr+81sit6uydtnd6r/IoejskPB8H/X7SX1KxTIQDo cZsw==
In-reply-to: <20160908175632.GH2356@xxxxxxxxxxxxxxxxxx>
References: <723420070.1340881.1472835555274.JavaMail.zimbra@xxxxxxxxxx> <1832555471.1341372.1472835736236.JavaMail.zimbra@xxxxxxxxxx> <20160903003919.GI30056@dastard> <1450936953.949798.1473348551588.JavaMail.zimbra@xxxxxxxxxx> <20160908175632.GH2356@xxxxxxxxxxxxxxxxxx>
Sender: linus971@xxxxxxxxx
On Thu, Sep 8, 2016 at 10:56 AM, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>
> ... and brings back a lot of other crap.  The thing is, pipe lock should
> be on the outside of everything fs might be taking, so that splice IO
> is the same as normal IO as far as filesystem locking is concerned.  For
> the write side it had been done in that commit, for the read side it's yet
> to be done.

Al, look at generic_file_splice_read().

The problem is that XFS takes its own

        xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
        ..
        xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);

around all the generic file accessors. So for example, it doesn't use
"generic_file_read_iter()", it does

STATIC ssize_t
xfs_file_buffered_aio_read(
        struct kiocb            *iocb,
        struct iov_iter         *to)
{
        struct xfs_inode        *ip = XFS_I(file_inode(iocb->ki_filp));
        ssize_t                 ret;

        trace_xfs_file_buffered_read(ip, iov_iter_count(to), iocb->ki_pos);

        xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
        ret = generic_file_read_iter(iocb, to);
        xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);

        return ret;
}

and the exact same pattern holds for generic_file_splice_read().

So the XFS model *requires* that XFS_IOLOCK to be outside all the operations.

But then in iter_file_splice_write we have the other ordering.

Now, xfs could do a wrapper for ->splice_write() like it used to, and
have that same "take the xfs lock around the call to
iter_file_splice_write(). That was my first obvious patch.

I threw it out because that's garbage too: then we end up doing
->write_iter(), which takes the xfs_rw_ilock() again, and would
immediately deadlock *there* instead.

So the problem really is that the vfs layer seems to simply not allow
the filesystem to do any locking around the generic page cache helper
functions. And XFS really wants to do that.

              Linus

<Prev in Thread] Current Thread [Next in Thread>