linux/fs/xfs
Dave Chinner 7ac956576d xfs: fix race condition in AIL push trigger
The recent conversion of the xfsaild functionality to a work queue
introduced a hard-to-hit log space grant hang. One is caused by a
race condition in determining whether there is a psh in progress or
not.

The XFS_AIL_PUSHING_BIT is used to determine whether a push is
currently in progress.  When the AIL push work completes, it checked
whether the target changed and cleared the PUSHING bit to allow a
new push to be requeued. The race condition is as follows:

	Thread 1		push work

	smp_wmb()
				smp_rmb()
				check ailp->xa_target unchanged
	update ailp->xa_target
	test/set PUSHING bit
	does not queue
				clear PUSHING bit
				does not requeue

Now that the push target is updated, new attempts to push the AIL
will not trigger as the push target will be the same, and hence
despite trying to push the AIL we won't ever wake it again.

The fix is to ensure that the AIL push work clears the PUSHING bit
before it checks if the target is unchanged.

As a result, both push triggers operate on the same test/set bit
criteria, so even if we race in the push work and miss the target
update, the thread requesting the push will still set the PUSHING
bit and queue the push work to occur. For safety sake, the same
queue check is done if the push work detects the target change,
though only one of the two will will queue new work due to the use
of test_and_set_bit() checks.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>

(cherry picked from commit e4d3c4a43b)
2011-05-09 18:35:04 -05:00
..
linux-2.6 xfs: ensure reclaim cursor is reset correctly at end of AG 2011-05-09 18:35:03 -05:00
quota Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs 2011-04-11 15:48:57 -07:00
support
Kconfig
Makefile Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs 2011-03-21 14:24:56 -07:00
xfs.h
xfs_acl.h
xfs_ag.h
xfs_alloc.c xfs: catch bad block numbers freeing extents. 2011-04-08 12:45:07 +10:00
xfs_alloc.h
xfs_alloc_btree.c
xfs_alloc_btree.h
xfs_arch.h
xfs_attr.c
xfs_attr.h
xfs_attr_leaf.c
xfs_attr_leaf.h
xfs_attr_sf.h
xfs_bit.c
xfs_bit.h
xfs_bmap.c
xfs_bmap.h
xfs_bmap_btree.c
xfs_bmap_btree.h
xfs_btree.c
xfs_btree.h
xfs_btree_trace.c
xfs_btree_trace.h
xfs_buf_item.c Fix common misspellings 2011-03-31 11:26:23 -03:00
xfs_buf_item.h
xfs_da_btree.c
xfs_da_btree.h
xfs_dfrag.c
xfs_dfrag.h
xfs_dinode.h
xfs_dir2.c
xfs_dir2.h
xfs_dir2_block.c
xfs_dir2_block.h
xfs_dir2_data.c
xfs_dir2_data.h
xfs_dir2_leaf.c
xfs_dir2_leaf.h
xfs_dir2_node.c
xfs_dir2_node.h
xfs_dir2_sf.c
xfs_dir2_sf.h
xfs_error.c
xfs_error.h
xfs_extfree_item.c
xfs_extfree_item.h
xfs_filestream.c
xfs_filestream.h
xfs_fs.h
xfs_fsops.c
xfs_fsops.h
xfs_ialloc.c
xfs_ialloc.h
xfs_ialloc_btree.c
xfs_ialloc_btree.h
xfs_iget.c
xfs_inode.c Fix common misspellings 2011-03-31 11:26:23 -03:00
xfs_inode.h Fix common misspellings 2011-03-31 11:26:23 -03:00
xfs_inode_item.c xfs: fix extent format buffer allocation size 2011-04-08 12:45:07 +10:00
xfs_inode_item.h
xfs_inum.h
xfs_iomap.c
xfs_iomap.h
xfs_itable.c xfs: fix variable set but not used warnings 2011-04-08 08:09:12 -05:00
xfs_itable.h
xfs_log.c xfs: convert log tail checking to a warning 2011-04-08 12:45:07 +10:00
xfs_log.h
xfs_log_cil.c
xfs_log_priv.h Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs 2011-04-11 15:48:57 -07:00
xfs_log_recover.c Fix common misspellings 2011-03-31 11:26:23 -03:00
xfs_log_recover.h
xfs_mount.c
xfs_mount.h xfs: introduce background inode reclaim work 2011-04-08 12:45:07 +10:00
xfs_mru_cache.c
xfs_mru_cache.h
xfs_quota.h
xfs_rename.c
xfs_rtalloc.c
xfs_rtalloc.h
xfs_rw.c
xfs_rw.h
xfs_sb.h
xfs_trans.c
xfs_trans.h
xfs_trans_ail.c xfs: fix race condition in AIL push trigger 2011-05-09 18:35:04 -05:00
xfs_trans_buf.c xfs: xfs_trans_read_buf() should return an error on failure 2011-03-26 09:14:44 +11:00
xfs_trans_extfree.c
xfs_trans_inode.c Fix common misspellings 2011-03-31 11:26:23 -03:00
xfs_trans_priv.h xfs: push the AIL from memory reclaim and periodic sync 2011-04-08 12:45:07 +10:00
xfs_trans_space.h
xfs_types.h
xfs_utils.c
xfs_utils.h
xfs_vnodeops.c Fix common misspellings 2011-03-31 11:26:23 -03:00
xfs_vnodeops.h xfs: preallocation transactions do not need to be synchronous 2011-03-26 09:13:08 +11:00