aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorAllison Henderson <achender@linux.vnet.ibm.com>2011-09-06 21:53:01 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-09-06 21:53:01 -0400
commit02fac1297eb3f471a27368271aadd285548297b0 (patch)
treed0008f0aa889dba759cb780e8e805b30953083cf /fs/ext4/inode.c
parent189e868fa8fdca702eb9db9d8afc46b5cb9144c9 (diff)
ext4: fix partial page writes
While running extended fsx tests to verify the preceeding patches, a similar bug was also found in the write operation When ever a write operation begins or ends in a hole, or extends EOF, the partial page contained in the hole or beyond EOF needs to be zeroed out. To correct this the new ext4_discard_partial_page_buffers_no_lock routine is used to zero out the partial page, but only for buffer heads that are already unmapped. Signed-off-by: Allison Henderson <achender@linux.vnet.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index f86b149fb8b1..6ecc93979e48 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2255,6 +2255,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
2255 pgoff_t index; 2255 pgoff_t index;
2256 struct inode *inode = mapping->host; 2256 struct inode *inode = mapping->host;
2257 handle_t *handle; 2257 handle_t *handle;
2258 loff_t page_len;
2258 2259
2259 index = pos >> PAGE_CACHE_SHIFT; 2260 index = pos >> PAGE_CACHE_SHIFT;
2260 2261
@@ -2301,6 +2302,13 @@ retry:
2301 */ 2302 */
2302 if (pos + len > inode->i_size) 2303 if (pos + len > inode->i_size)
2303 ext4_truncate_failed_write(inode); 2304 ext4_truncate_failed_write(inode);
2305 } else {
2306 page_len = pos & (PAGE_CACHE_SIZE - 1);
2307 if (page_len > 0) {
2308 ret = ext4_discard_partial_page_buffers_no_lock(handle,
2309 inode, page, pos - page_len, page_len,
2310 EXT4_DISCARD_PARTIAL_PG_ZERO_UNMAPPED);
2311 }
2304 } 2312 }
2305 2313
2306 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 2314 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
@@ -2343,6 +2351,7 @@ static int ext4_da_write_end(struct file *file,
2343 loff_t new_i_size; 2351 loff_t new_i_size;
2344 unsigned long start, end; 2352 unsigned long start, end;
2345 int write_mode = (int)(unsigned long)fsdata; 2353 int write_mode = (int)(unsigned long)fsdata;
2354 loff_t page_len;
2346 2355
2347 if (write_mode == FALL_BACK_TO_NONDELALLOC) { 2356 if (write_mode == FALL_BACK_TO_NONDELALLOC) {
2348 if (ext4_should_order_data(inode)) { 2357 if (ext4_should_order_data(inode)) {
@@ -2391,6 +2400,16 @@ static int ext4_da_write_end(struct file *file,
2391 } 2400 }
2392 ret2 = generic_write_end(file, mapping, pos, len, copied, 2401 ret2 = generic_write_end(file, mapping, pos, len, copied,
2393 page, fsdata); 2402 page, fsdata);
2403
2404 page_len = PAGE_CACHE_SIZE -
2405 ((pos + copied - 1) & (PAGE_CACHE_SIZE - 1));
2406
2407 if (page_len > 0) {
2408 ret = ext4_discard_partial_page_buffers_no_lock(handle,
2409 inode, page, pos + copied - 1, page_len,
2410 EXT4_DISCARD_PARTIAL_PG_ZERO_UNMAPPED);
2411 }
2412
2394 copied = ret2; 2413 copied = ret2;
2395 if (ret2 < 0) 2414 if (ret2 < 0)
2396 ret = ret2; 2415 ret = ret2;