diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-10-29 22:11:44 +1100 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2014-07-04 10:06:58 +0200 |
commit | f7009499bc593c23ec4fe9525f4e545ad0c16691 (patch) | |
tree | f3e4ce9a1f7797fd0955dd667b04b35f72ede8ef /fs/f2fs | |
parent | 67820ad00235119639737a7a4bcf4e526de43d54 (diff) |
xfs: xfs_remove deadlocks due to inverted AGF vs AGI lock ordering
commit 273203699f82667296e1f14344c5a5a6c4600470 upstream.
Removing an inode from the namespace involves removing the directory
entry and dropping the link count on the inode. Removing the
directory entry can result in locking an AGF (directory blocks were
freed) and removing a link count can result in placing the inode on
an unlinked list which results in locking an AGI.
The big problem here is that we have an ordering constraint on AGF
and AGI locking - inode allocation locks the AGI, then can allocate
a new extent for new inodes, locking the AGF after the AGI.
Similarly, freeing the inode removes the inode from the unlinked
list, requiring that we lock the AGI first, and then freeing the
inode can result in an inode chunk being freed and hence freeing
disk space requiring that we lock an AGF.
Hence the ordering that is imposed by other parts of the code is AGI
before AGF. This means we cannot remove the directory entry before
we drop the inode reference count and put it on the unlinked list as
this results in a lock order of AGF then AGI, and this can deadlock
against inode allocation and freeing. Therefore we must drop the
link counts before we remove the directory entry.
This is still safe from a transactional point of view - it is not
until we get to xfs_bmap_finish() that we have the possibility of
multiple transactions in this operation. Hence as long as we remove
the directory entry and drop the link count in the first transaction
of the remove operation, there are no transactional constraints on
the ordering here.
Change the ordering of the operations in the xfs_remove() function
to align the ordering of AGI and AGF locking to match that of the
rest of the code.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Diffstat (limited to 'fs/f2fs')
0 files changed, 0 insertions, 0 deletions