]> git.baikalelectronics.ru Git - kernel.git/commit
gfs2: Fix gfs2_lookup_by_inum lock inversion
authorAndreas Gruenbacher <agruenba@redhat.com>
Tue, 14 Jun 2016 17:22:27 +0000 (12:22 -0500)
committerBob Peterson <rpeterso@redhat.com>
Mon, 27 Jun 2016 14:47:07 +0000 (09:47 -0500)
commit5f27b38b2a80126a46723ccf84c9aee92314fb71
tree76adc95997a6e5ba7668630597c0872dde734a45
parent27c874eb4935339f40545454b9c9ada89e9bd963
gfs2: Fix gfs2_lookup_by_inum lock inversion

The current gfs2_lookup_by_inum takes the glock of a presumed inode
identified by block number, verifies that the block is indeed an inode,
and then instantiates and reads the new inode via gfs2_inode_lookup.

However, instantiating a new inode may block on freeing a previous
instance of that inode (__wait_on_freeing_inode), and freeing an inode
requires to take the glock already held, leading to lock inversion and
deadlock.

Fix this by first instantiating the new inode, then verifying that the
block is an inode (if required), and then reading in the new inode, all
in gfs2_inode_lookup.

If the block we are looking for is not an inode, we discard the new
inode via iget_failed, which marks inodes as bad and unhashes them.
Other tasks waiting on that inode will get back a bad inode back from
ilookup or iget_locked; in that case, retry the lookup.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/dir.c
fs/gfs2/glock.c
fs/gfs2/inode.c
fs/gfs2/inode.h
fs/gfs2/ops_fstype.c