]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.31/patches.suse/xfs-wait-for-all-IO-on-truncate-to-zero
Move xen patchset to new version's subdir.
[ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.suse / xfs-wait-for-all-IO-on-truncate-to-zero
CommitLineData
00e5a55c
BS
1From: Lachlan McIlroy <lachlan@sgi.com>
2Subject: [XFS] Wait for all I/O on truncate to zero file size
3Patch-mainline: ?
4References: bnc#450658
5
6It's possible to have outstanding xfs_ioend_t's queued when the file size
7is zero. This can happen in the direct I/O path when a direct I/O write
8fails due to ENOSPC. In this case the xfs_ioend_t will still be queued (ie
9xfs_end_io_direct() does not know that the I/O failed so can't force the
10xfs_ioend_t to be flushed synchronously).
11
12When we truncate a file on unlink we don't know to wait for these
13xfs_ioend_ts and we can have a use-after-free situation if the inode is
14reclaimed before the xfs_ioend_t is finally processed.
15
16As was suggested by Dave Chinner lets wait for all I/Os to complete when
17truncating the file size to zero.
18
19SGI-PV: 981668
20
21SGI-Modid: xfs-linux-melb:xfs-kern:32216a
22
23Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
24Signed-off-by: Christoph Hellwig <hch@infradead.org>
25Acked-by: Jan Kara <jack@suse.cz>
26
27Index: linux-2.6.27.5-2/fs/xfs/xfs_inode.c
28===================================================================
29--- linux-2.6.27.5-2.orig/fs/xfs/xfs_inode.c 2008-12-03 11:58:00.992733026 +1100
30+++ linux-2.6.27.5-2/fs/xfs/xfs_inode.c 2008-12-03 11:59:17.542975042 +1100
31@@ -1414,7 +1414,7 @@ xfs_itruncate_start(
32 mp = ip->i_mount;
33
34 /* wait for the completion of any pending DIOs */
35- if (new_size < ip->i_size)
36+ if (new_size == 0 || new_size < ip->i_size)
37 vn_iowait(ip);
38
39 /*