linux/fs/xfs
Lachlan McIlroy 2a32963130 [XFS] Fix race condition in xfs_write().
This change addresses a race in xfs_write() where, for direct I/O, the
flags need_i_mutex and need_flush are setup before the iolock is acquired.
The logic used to setup the flags may change between setting the flags and
acquiring the iolock resulting in these flags having incorrect values. For
example, if a file is not currently cached then need_i_mutex is set to
zero and then if the file is cached before the iolock is acquired we will
fail to do the flushinval before the direct write.

The flush (and also the call to xfs_zero_eof()) need to be done with the
iolock held exclusive so we need to acquire the iolock before checking for
cached data (or if the write begins after eof) to prevent this state from
changing. For direct I/O I've chosen to always acquire the iolock in
shared mode initially and if there is a need to promote it then drop it
and reacquire it.

There's also some other tidy-ups including removing the O_APPEND offset
adjustment since that work is done in generic_write_checks() (and we don't
use offset as an input parameter anywhere).

SGI-PV: 962170
SGI-Modid: xfs-linux-melb:xfs-kern:28319a

Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>
2007-05-08 13:49:39 +10:00
..
linux-2.6 [XFS] Fix race condition in xfs_write(). 2007-05-08 13:49:39 +10:00
quota [XFS] Fix uquota and oquota enforcement problems. 2007-05-08 13:49:33 +10:00
support [XFS] reducing the number of random number functions. 2007-05-08 13:49:03 +10:00
Kbuild
Kconfig
Makefile
Makefile-linux-2.6
xfs.h
xfs_acl.c [XFS] Remove unused header files for MAC and CAP checking functionality. 2007-02-10 18:37:28 +11:00
xfs_acl.h
xfs_ag.h
xfs_alloc.c [XFS] reducing the number of random number functions. 2007-05-08 13:49:03 +10:00
xfs_alloc.h
xfs_alloc_btree.c
xfs_alloc_btree.h [XFS] Remove unused arguments from the XFS_BTREE_*_ADDR macros. 2007-02-10 18:37:33 +11:00
xfs_arch.h
xfs_attr.c [XFS] The last argument "lsn" of xfs_trans_commit() is always called with 2007-05-08 13:48:42 +10:00
xfs_attr.h
xfs_attr_leaf.c [XFS] The last argument "lsn" of xfs_trans_commit() is always called with 2007-05-08 13:48:42 +10:00
xfs_attr_leaf.h
xfs_attr_sf.h
xfs_behavior.c
xfs_behavior.h
xfs_bit.c [XFS] Keep stack usage down for 4k stacks by using noinline. 2007-02-10 18:34:56 +11:00
xfs_bit.h
xfs_bmap.c [XFS] remove more misc. unused args 2007-05-08 13:48:56 +10:00
xfs_bmap.h [XFS] Remove unused argument to xfs_bmap_finish 2007-02-10 18:37:16 +11:00
xfs_bmap_btree.c [XFS] Remove a bunch of unused functions from XFS. 2007-02-10 18:37:40 +11:00
xfs_bmap_btree.h [XFS] Remove a bunch of unused functions from XFS. 2007-02-10 18:37:40 +11:00
xfs_btree.c
xfs_btree.h [XFS] Remove unused arguments from the XFS_BTREE_*_ADDR macros. 2007-02-10 18:37:33 +11:00
xfs_buf_item.c [XFS] Keep stack usage down for 4k stacks by using noinline. 2007-02-10 18:34:56 +11:00
xfs_buf_item.h [XFS] Get rid of old 5.3/6.1 v1 log items. Cleanup patch sent in by Eric 2007-02-10 18:35:02 +11:00
xfs_clnt.h
xfs_da_btree.c [XFS] Remove a bunch of unused functions from XFS. 2007-02-10 18:37:40 +11:00
xfs_da_btree.h [XFS] Remove a bunch of unused functions from XFS. 2007-02-10 18:37:40 +11:00
xfs_dfrag.c [XFS] propogate return codes from flush routines 2007-05-08 13:49:27 +10:00
xfs_dfrag.h
xfs_dinode.h
xfs_dir2.c
xfs_dir2.h
xfs_dir2_block.c [XFS] the "aendp" arg to xfs_dir2_data_freescan is always NULL, remove it. 2007-05-08 13:48:49 +10:00
xfs_dir2_block.h
xfs_dir2_data.c [XFS] the "aendp" arg to xfs_dir2_data_freescan is always NULL, remove it. 2007-05-08 13:48:49 +10:00
xfs_dir2_data.h [XFS] the "aendp" arg to xfs_dir2_data_freescan is always NULL, remove it. 2007-05-08 13:48:49 +10:00
xfs_dir2_leaf.c [XFS] the "aendp" arg to xfs_dir2_data_freescan is always NULL, remove it. 2007-05-08 13:48:49 +10:00
xfs_dir2_leaf.h
xfs_dir2_node.c [XFS] the "aendp" arg to xfs_dir2_data_freescan is always NULL, remove it. 2007-05-08 13:48:49 +10:00
xfs_dir2_node.h
xfs_dir2_sf.c
xfs_dir2_sf.h
xfs_dir2_trace.c
xfs_dir2_trace.h
xfs_dmapi.h
xfs_dmops.c
xfs_error.c [XFS] reducing the number of random number functions. 2007-05-08 13:49:03 +10:00
xfs_error.h [XFS] Remove a bunch of unused functions from XFS. 2007-02-10 18:37:40 +11:00
xfs_extfree_item.c [XFS] Keep stack usage down for 4k stacks by using noinline. 2007-02-10 18:34:56 +11:00
xfs_extfree_item.h
xfs_fs.h
xfs_fsops.c [XFS] The last argument "lsn" of xfs_trans_commit() is always called with 2007-05-08 13:48:42 +10:00
xfs_fsops.h
xfs_ialloc.c [XFS] Keep stack usage down for 4k stacks by using noinline. 2007-02-10 18:34:56 +11:00
xfs_ialloc.h
xfs_ialloc_btree.c
xfs_ialloc_btree.h [XFS] Remove unused arguments from the XFS_BTREE_*_ADDR macros. 2007-02-10 18:37:33 +11:00
xfs_iget.c
xfs_imap.h
xfs_inode.c [XFS] propogate return codes from flush routines 2007-05-08 13:49:27 +10:00
xfs_inode.h [XFS] propogate return codes from flush routines 2007-05-08 13:49:27 +10:00
xfs_inode_item.c [XFS] Keep stack usage down for 4k stacks by using noinline. 2007-02-10 18:34:56 +11:00
xfs_inode_item.h
xfs_inum.h
xfs_iocore.c
xfs_iomap.c [XFS] The last argument "lsn" of xfs_trans_commit() is always called with 2007-05-08 13:48:42 +10:00
xfs_iomap.h
xfs_itable.c
xfs_itable.h
xfs_log.c
xfs_log.h
xfs_log_priv.h
xfs_log_recover.c [XFS] remove more misc. unused args 2007-05-08 13:48:56 +10:00
xfs_log_recover.h
xfs_mount.c [XFS] The last argument "lsn" of xfs_trans_commit() is always called with 2007-05-08 13:48:42 +10:00
xfs_mount.h [XFS] Re-initialize the per-cpu superblock counters after recovery. 2007-02-10 18:36:29 +11:00
xfs_qmops.c [XFS] The last argument "lsn" of xfs_trans_commit() is always called with 2007-05-08 13:48:42 +10:00
xfs_quota.h [XFS] Fix uquota and oquota enforcement problems. 2007-05-08 13:49:33 +10:00
xfs_refcache.h
xfs_rename.c [XFS] The last argument "lsn" of xfs_trans_commit() is always called with 2007-05-08 13:48:42 +10:00
xfs_rtalloc.c [XFS] The last argument "lsn" of xfs_trans_commit() is always called with 2007-05-08 13:48:42 +10:00
xfs_rtalloc.h [XFS] Remove a bunch of unused functions from XFS. 2007-02-10 18:37:40 +11:00
xfs_rw.c [XFS] The last argument "lsn" of xfs_trans_commit() is always called with 2007-05-08 13:48:42 +10:00
xfs_rw.h
xfs_sb.h
xfs_trans.c [XFS] The last argument "lsn" of xfs_trans_commit() is always called with 2007-05-08 13:48:42 +10:00
xfs_trans.h [XFS] The last argument "lsn" of xfs_trans_commit() is always called with 2007-05-08 13:48:42 +10:00
xfs_trans_ail.c [XFS] Workaround log space issue by increasing XFS_TRANS_PUSH_AIL_RESTARTS 2007-02-10 18:35:52 +11:00
xfs_trans_buf.c
xfs_trans_extfree.c
xfs_trans_inode.c
xfs_trans_item.c
xfs_trans_priv.h
xfs_trans_space.h
xfs_types.h
xfs_utils.c [XFS] propogate return codes from flush routines 2007-05-08 13:49:27 +10:00
xfs_utils.h
xfs_vfsops.c [XFS] propogate return codes from flush routines 2007-05-08 13:49:27 +10:00
xfs_vnodeops.c [XFS] propogate return codes from flush routines 2007-05-08 13:49:27 +10:00