Fix ext3-4-migrate.patch and mballoc-core.patches
[ext4-patch-queue.git] / ext4_handle_uniniatilized_extents_split_return_error_fix.patch
bloba9739c8fcdb660fa8ecc2b6abe27d65a71cab12f
1 ext4: fix uniniatilized extent splitting error
3 From: Dmitry Monakhov <dmonakhov@openvz.org>
5 Fix bug reported by Dmitry Monakhov caused by lost error code
7 Testcase:
9 blksize = 0x1000;
10 fd = open(argv[1], O_RDWR|O_CREAT, 0700);
11 unsigned long long sz = 0x10000000UL;
12 /* allocating big blocks chunk */
13 syscall(__NR_fallocate, fd, 0, 0UL, sz)
15 /* grab all other available filesystem space */
16 tfd = open("tmp", O_RDWR|O_CREAT|O_DIRECT, 0700);
17 while( write(tfd, buf, 4096) > 0); /* loop untill ENOSPC */
18 fsync(fd); /* just in case */
19 while (pos < sz) {
20 /* each seek+ write operation result in splits uninitialized extent
21 in three extents. Splitting may result in new extent allocation
22 which probably will fail because of ENOSPC*/
24 lseek(fd, blksize*2 -1, SEEK_CUR);
25 if ((ret = write(fd, 'a', 1)) != 1)
26 exit(1);
27 pos += blksize * 2;
30 Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
31 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
32 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
34 ---
36 fs/ext4/extents.c | 5 +++--
37 1 file changed, 3 insertions(+), 2 deletions(-)
40 Index: linux-2.6.24-rc7/fs/ext4/extents.c
41 ===================================================================
42 --- linux-2.6.24-rc7.orig/fs/ext4/extents.c 2008-01-16 13:52:19.000000000 -0800
43 +++ linux-2.6.24-rc7/fs/ext4/extents.c 2008-01-16 13:52:34.000000000 -0800
44 @@ -2373,9 +2373,10 @@ int ext4_ext_get_blocks(handle_t *handle
45 ret = ext4_ext_convert_to_initialized(handle, inode,
46 path, iblock,
47 max_blocks);
48 - if (ret <= 0)
49 + if (ret <= 0) {
50 + err = ret;
51 goto out2;
52 - else
53 + } else
54 allocated = ret;
55 goto outnew;