linux/fs/xfs
Dave Chinner 273203699f xfs: xfs_remove deadlocks due to inverted AGF vs AGI lock ordering
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>
2013-11-04 13:18:48 -06:00
..
Kconfig xfs: introduce CONFIG_XFS_WARN 2013-05-07 18:45:36 -05:00
Makefile xfs: abstract the differences in dir2/dir3 via an ops vector 2013-10-30 13:37:38 -05:00
kmem.c xfs: factor all the kmalloc-or-vmalloc fallback allocations 2013-09-10 13:57:03 -05:00
kmem.h xfs: factor all the kmalloc-or-vmalloc fallback allocations 2013-09-10 13:57:03 -05:00
mrlock.h xfs: introduce CONFIG_XFS_WARN 2013-05-07 18:45:36 -05:00
time.h xfs: remove subdirectories 2011-08-12 16:21:35 -05:00
uuid.c xfs: remove subdirectories 2011-08-12 16:21:35 -05:00
uuid.h xfs: add CRC infrastructure 2012-11-19 20:11:24 -06:00
xfs.h xfs: introduce CONFIG_XFS_WARN 2013-05-07 18:45:36 -05:00
xfs_acl.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_acl.h xfs: increase number of ACL entries for V5 superblocks 2013-06-06 10:52:15 -05:00
xfs_ag.h xfs: create a shared header file for format-related information 2013-10-23 14:11:30 -05:00
xfs_alloc.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_alloc.h xfs: create a shared header file for format-related information 2013-10-23 14:11:30 -05:00
xfs_alloc_btree.c xfs: fix static and extern sparse warnings 2013-10-30 13:59:56 -05:00
xfs_alloc_btree.h xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_aops.c xfs: prevent stack overflows from page cache allocation 2013-10-30 15:44:51 -05:00
xfs_aops.h direct-io: Implement generic deferred AIO completions 2013-09-04 09:23:46 -04:00
xfs_attr.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_attr.h xfs: kill xfs_vnodeops.[ch] 2013-08-12 16:53:39 -05:00
xfs_attr_inactive.c xfs: vectorise encoding/decoding directory headers 2013-10-30 13:47:22 -05:00
xfs_attr_leaf.c xfs: fix static and extern sparse warnings 2013-10-30 13:59:56 -05:00
xfs_attr_leaf.h xfs: unify directory/attribute format definitions 2013-10-23 14:21:40 -05:00
xfs_attr_list.c xfs: vectorise encoding/decoding directory headers 2013-10-30 13:47:22 -05:00
xfs_attr_remote.c xfs: fix static and extern sparse warnings 2013-10-30 13:59:56 -05:00
xfs_attr_remote.h xfs: unify directory/attribute format definitions 2013-10-23 14:21:40 -05:00
xfs_attr_sf.h xfs: convert attr to use unsigned names 2010-01-20 10:47:48 +11:00
xfs_bit.c xfs: fix static and extern sparse warnings 2013-10-30 13:59:56 -05:00
xfs_bit.h [XFS] Remove macro-to-function indirections in the mask code 2009-01-09 15:53:54 +11:00
xfs_bmap.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_bmap.h xfs: remove __KERNEL__ from debug code 2013-08-12 16:58:37 -05:00
xfs_bmap_btree.c xfs: fix static and extern sparse warnings 2013-10-30 13:59:56 -05:00
xfs_bmap_btree.h xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_bmap_util.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_bmap_util.h xfs: fold xfs_change_file_space into xfs_ioc_space 2013-10-21 16:57:03 -05:00
xfs_btree.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_btree.h xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_buf.c xfs: decouple log and transaction headers 2013-10-23 16:17:44 -05:00
xfs_buf.h xfs: rework buffer dispose list tracking 2013-09-10 18:56:31 -04:00
xfs_buf_item.c xfs: fix static and extern sparse warnings 2013-10-30 13:59:56 -05:00
xfs_buf_item.h xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_cksum.h xfs: add CRC infrastructure 2012-11-19 20:11:24 -06:00
xfs_da_btree.c xfs: convert directory vector functions to constants 2013-10-30 13:49:18 -05:00
xfs_da_btree.h xfs: abstract the differences in dir2/dir3 via an ops vector 2013-10-30 13:37:38 -05:00
xfs_da_format.c xfs: fix static and extern sparse warnings 2013-10-30 13:59:56 -05:00
xfs_da_format.h xfs: convert directory vector functions to constants 2013-10-30 13:48:41 -05:00
xfs_dinode.h xfs: di_flushiter considered harmful 2013-07-25 10:41:42 -05:00
xfs_dir2.c xfs: convert directory vector functions to constants 2013-10-30 13:49:18 -05:00
xfs_dir2.h xfs: convert directory vector functions to constants 2013-10-30 13:49:18 -05:00
xfs_dir2_block.c xfs: convert directory vector functions to constants 2013-10-30 13:49:18 -05:00
xfs_dir2_data.c xfs: validity check the directory block leaf entry count 2013-10-30 13:57:14 -05:00
xfs_dir2_leaf.c xfs: convert directory vector functions to constants 2013-10-30 13:49:18 -05:00
xfs_dir2_node.c xfs:xfs_dir2_node.c: pointer use before check for null 2013-10-30 15:53:14 -05:00
xfs_dir2_priv.h xfs: vectorise encoding/decoding directory headers 2013-10-30 13:47:22 -05:00
xfs_dir2_readdir.c xfs: convert directory vector functions to constants 2013-10-30 13:49:18 -05:00
xfs_dir2_sf.c xfs: convert directory vector functions to constants 2013-10-30 13:49:18 -05:00
xfs_discard.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_discard.h xfs: remove subdirectories 2011-08-12 16:21:35 -05:00
xfs_dquot.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_dquot.h xfs: create a shared header file for format-related information 2013-10-23 14:11:30 -05:00
xfs_dquot_buf.c xfs: fix static and extern sparse warnings 2013-10-30 13:59:56 -05:00
xfs_dquot_item.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_dquot_item.h xfs: remove subdirectories 2011-08-12 16:21:35 -05:00
xfs_error.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_error.h xfs: kill support/debug.[ch] 2011-03-07 10:09:35 +11:00
xfs_export.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_export.h xfs: remove subdirectories 2011-08-12 16:21:35 -05:00
xfs_extent_busy.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_extent_busy.h xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_extfree_item.c xfs: decouple log and transaction headers 2013-10-23 16:17:44 -05:00
xfs_extfree_item.h xfs: split out EFI/EFD log item format definition 2013-08-12 16:07:13 -05:00
xfs_file.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_filestream.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_filestream.h xfs: xfs_filestreams.h doesn't need __KERNEL__ 2013-08-12 17:00:11 -05:00
xfs_format.h xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_fs.h xfs: add the inode directory type support to XFS_IOC_FSGEOM 2013-10-08 14:28:09 -05:00
xfs_fsops.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_fsops.h xfs: ensure log covering transactions are synchronous 2011-01-11 20:28:17 -06:00
xfs_globals.c xfs: add background scanning to clear eofblocks inodes 2012-11-08 15:34:59 -06:00
xfs_ialloc.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_ialloc.h xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_ialloc_btree.c xfs: fix static and extern sparse warnings 2013-10-30 13:59:56 -05:00
xfs_ialloc_btree.h xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_icache.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_icache.h xfs: update #2 for v3.12-rc1 2013-09-12 16:13:41 -07:00
xfs_icreate_item.c xfs: decouple log and transaction headers 2013-10-23 16:17:44 -05:00
xfs_icreate_item.h xfs: separate icreate log format definitions from xfs_icreate_item.h 2013-08-12 16:10:35 -05:00
xfs_inode.c xfs: xfs_remove deadlocks due to inverted AGF vs AGI lock ordering 2013-11-04 13:18:48 -06:00
xfs_inode.h xfs: abstract the differences in dir2/dir3 via an ops vector 2013-10-30 13:37:38 -05:00
xfs_inode_buf.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_inode_buf.h xfs: create a shared header file for format-related information 2013-10-23 14:11:30 -05:00
xfs_inode_fork.c xfs: fix the extent count when allocating an new indirection array entry 2013-10-31 16:43:19 -05:00
xfs_inode_fork.h xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_inode_item.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_inode_item.h xfs: split out inode log item format definition 2013-08-12 16:05:19 -05:00
xfs_inum.h xfs: move xfsagino_t to xfs_types.h 2012-05-14 16:20:54 -05:00
xfs_ioctl.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_ioctl.h xfs: consolidate extent swap code 2013-08-12 16:56:06 -05:00
xfs_ioctl32.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_ioctl32.h xfs: remove subdirectories 2011-08-12 16:21:35 -05:00
xfs_iomap.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_iomap.h xfs: get rid of count from xfs_iomap_write_allocate() 2013-10-01 15:42:34 -05:00
xfs_iops.c xfs: prevent stack overflows from page cache allocation 2013-10-30 15:44:51 -05:00
xfs_iops.h xfs: fold xfs_change_file_space into xfs_ioc_space 2013-10-21 16:57:03 -05:00
xfs_itable.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_itable.h xfs: remove block number from inode lookup code 2010-06-24 11:35:17 +10:00
xfs_linux.h xfs: remove two unused macro definitions in xfs_linux.h 2013-08-20 15:30:23 -05:00
xfs_log.c xfs: fix possible NULL dereference in xlog_verify_iclog 2013-10-30 16:01:00 -05:00
xfs_log.h xfs: decouple log and transaction headers 2013-10-23 16:17:44 -05:00
xfs_log_cil.c xfs: decouple log and transaction headers 2013-10-23 16:17:44 -05:00
xfs_log_format.h xfs: create a shared header file for format-related information 2013-10-23 14:11:30 -05:00
xfs_log_priv.h xfs: decouple log and transaction headers 2013-10-23 16:17:44 -05:00
xfs_log_recover.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_log_recover.h xfs: Clean up XFS_BLI_* flag namespace 2010-05-24 10:33:39 -05:00
xfs_log_rlimit.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_message.c xfs: decouple log and transaction headers 2013-10-23 16:17:44 -05:00
xfs_message.h xfs: introduce CONFIG_XFS_WARN 2013-05-07 18:45:36 -05:00
xfs_mount.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_mount.h xfs: vectorise DA btree operations 2013-10-30 13:43:28 -05:00
xfs_mru_cache.c xfs: convert to alloc_workqueue() 2011-02-01 11:42:43 +01:00
xfs_mru_cache.h xfs: Kill filestreams cache flush 2010-01-15 15:34:22 -06:00
xfs_qm.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_qm.h xfs: split dquot buffer operations out 2013-10-23 14:28:35 -05:00
xfs_qm_bhv.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_qm_syscalls.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_quota.h xfs: split dquot buffer operations out 2013-10-23 14:28:35 -05:00
xfs_quota_defs.h xfs: split dquot buffer operations out 2013-10-23 14:28:35 -05:00
xfs_quota_priv.h xfs: use per-filesystem radix trees for dquot lookup 2012-03-14 11:09:06 -05:00
xfs_quotaops.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_rtalloc.c xfs: split xfs_rtalloc.c for userspace sanity 2013-10-23 17:16:32 -05:00
xfs_rtalloc.h xfs: split xfs_rtalloc.c for userspace sanity 2013-10-23 17:16:32 -05:00
xfs_rtbitmap.c xfs: fix static and extern sparse warnings 2013-10-30 13:59:56 -05:00
xfs_sb.c xfs: be more forgiving of a v4 secondary sb w/ junk in v5 fields 2013-10-30 16:38:29 -05:00
xfs_sb.h xfs: create a shared header file for format-related information 2013-10-23 14:11:30 -05:00
xfs_shared.h xfs: create a shared header file for format-related information 2013-10-23 14:11:30 -05:00
xfs_stats.c xfs: use common code for quota statistics 2012-03-14 11:09:06 -05:00
xfs_stats.h xfs: use common code for quota statistics 2012-03-14 11:09:06 -05:00
xfs_super.c xfs: fix static and extern sparse warnings 2013-10-30 13:59:56 -05:00
xfs_super.h xfs: xfs_sync_data is redundant. 2012-10-17 12:01:25 -05:00
xfs_symlink.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_symlink.h xfs: push down inactive transaction mgmt for remote symlinks 2013-10-08 14:53:02 -05:00
xfs_symlink_remote.c xfs: decouple log and transaction headers 2013-10-23 16:17:44 -05:00
xfs_sysctl.c xfs: Convert use of typedef ctl_table to struct ctl_table 2013-06-17 17:42:25 -05:00
xfs_sysctl.h xfs: add background scanning to clear eofblocks inodes 2012-11-08 15:34:59 -06:00
xfs_trace.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_trace.h xfs: update for 3.11-rc1 2013-07-09 12:29:12 -07:00
xfs_trans.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_trans.h xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_trans_ail.c xfs: decouple log and transaction headers 2013-10-23 16:17:44 -05:00
xfs_trans_buf.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_trans_dquot.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_trans_extfree.c xfs: decouple log and transaction headers 2013-10-23 16:17:44 -05:00
xfs_trans_inode.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_trans_priv.h xfs: decouple log and transaction headers 2013-10-23 16:17:44 -05:00
xfs_trans_resv.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00
xfs_trans_resv.h xfs: Get rid of all XFS_XXX_LOG_RES() macro 2013-08-12 17:48:08 -05:00
xfs_trans_space.h xfs: remove superflous inobt macros 2009-02-09 08:37:14 +01:00
xfs_types.h xfs: Add read-only support for dirent filetype field 2013-08-22 08:40:24 -05:00
xfs_vnode.h xfs: clean up xfs_inactive() error handling, kill VN_INACTIVE_[NO]CACHE 2013-10-08 17:20:41 -05:00
xfs_xattr.c xfs: decouple inode and bmap btree header files 2013-10-23 16:28:49 -05:00