]> git.baikalelectronics.ru Git - kernel.git/commit
ceph: take the inode lock before acquiring cap refs
authorJeff Layton <jlayton@kernel.org>
Wed, 13 Nov 2019 14:10:27 +0000 (09:10 -0500)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 14 Nov 2019 17:44:51 +0000 (18:44 +0100)
commitc1a8da97720bc1d74ca87140b70005f2245f821d
tree5ce3d7f6ddc3c2b9ffbe43736f18115c9bc29948
parent4ecc71eb0b9570f91bd8c41c6eccfb90b9620aa0
ceph: take the inode lock before acquiring cap refs

Most of the time, we (or the vfs layer) takes the inode_lock and then
acquires caps, but ceph_read_iter does the opposite, and that can lead
to a deadlock.

When there are multiple clients treading over the same data, we can end
up in a situation where a reader takes caps and then tries to acquire
the inode_lock. Another task holds the inode_lock and issues a request
to the MDS which needs to revoke the caps, but that can't happen until
the inode_lock is unwedged.

Fix this by having ceph_read_iter take the inode_lock earlier, before
attempting to acquire caps.

Fixes: 872d773fa527 ("ceph: add buffered/direct exclusionary locking for reads and writes")
Link: https://tracker.ceph.com/issues/36348
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/file.c