diff options
author | Lachlan McIlroy <lachlan@sgi.com> | 2007-05-08 07:49:39 +0400 |
---|---|---|
committer | Tim Shimmin <tes@sgi.com> | 2007-05-08 07:49:39 +0400 |
commit | 2a32963130aec5e157b58ff7dfa3dfa1afdf7ca1 (patch) | |
tree | 97b38a1d7c69bad94fafeee75102a0701c44f27e /fs/xfs/xfs_inode.c | |
parent | e6d29426bc8a5d07d0eebd0842fe0cf6ecc862cd (diff) | |
download | linux-2a32963130aec5e157b58ff7dfa3dfa1afdf7ca1.tar.xz |
[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>
Diffstat (limited to 'fs/xfs/xfs_inode.c')
0 files changed, 0 insertions, 0 deletions