diff options
author | David Chinner <dgc@sgi.com> | 2007-02-10 02:36:35 -0500 |
---|---|---|
committer | Tim Shimmin <tes@sgi.com> | 2007-02-10 02:36:35 -0500 |
commit | 549054afadae44889c0b40d4c3bfb0207b98d5a0 (patch) | |
tree | fe82d3c74b4ac1412746e29300df9ca725603d2f | |
parent | 5478eead8528f6cb5ebe3015fb88b68b175e1093 (diff) |
[XFS] Fix sub-block zeroing for buffered writes into unwritten extents.
When writing less than a filesystem block of data into an unwritten extent
via buffered I/O, __xfs_get_blocks fails to set the buffer new flag. As a
result, the generic code will not zero either edge of the block resulting
in garbage being written to disk either side of the real data. Set the
buffer new state on bufferd writes to unwritten extents to ensure that
zeroing occurs.
SGI-PV: 960328
SGI-Modid: xfs-linux-melb:xfs-kern:28000a
Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>
-rw-r--r-- | fs/xfs/linux-2.6/xfs_aops.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index 9761a5befef0..f3cc4ab20ba0 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c | |||
@@ -1283,13 +1283,18 @@ __xfs_get_blocks( | |||
1283 | bh_result->b_bdev = iomap.iomap_target->bt_bdev; | 1283 | bh_result->b_bdev = iomap.iomap_target->bt_bdev; |
1284 | 1284 | ||
1285 | /* | 1285 | /* |
1286 | * If we previously allocated a block out beyond eof and we are | 1286 | * If we previously allocated a block out beyond eof and we are now |
1287 | * now coming back to use it then we will need to flag it as new | 1287 | * coming back to use it then we will need to flag it as new even if it |
1288 | * even if it has a disk address. | 1288 | * has a disk address. |
1289 | * | ||
1290 | * With sub-block writes into unwritten extents we also need to mark | ||
1291 | * the buffer as new so that the unwritten parts of the buffer gets | ||
1292 | * correctly zeroed. | ||
1289 | */ | 1293 | */ |
1290 | if (create && | 1294 | if (create && |
1291 | ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || | 1295 | ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || |
1292 | (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) | 1296 | (offset >= i_size_read(inode)) || |
1297 | (iomap.iomap_flags & (IOMAP_NEW|IOMAP_UNWRITTEN)))) | ||
1293 | set_buffer_new(bh_result); | 1298 | set_buffer_new(bh_result); |
1294 | 1299 | ||
1295 | if (iomap.iomap_flags & IOMAP_DELAY) { | 1300 | if (iomap.iomap_flags & IOMAP_DELAY) { |