Fix wrong file allocation size in btrfs (#669511)

This commit is contained in:
Chuck Ebbert 2011-01-16 12:34:09 -05:00
parent b97dc7392d
commit b11f51521b
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,51 @@
From: Josef Bacik <josef@redhat.com>
Date: Mon, 22 Nov 2010 18:50:32 +0000 (+0000)
Subject: Btrfs: fix typo in fallocate to make it honor actual size
X-Git-Tag: v2.6.37-rc4~6^2~7
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=55a61d1d06a3dc443d0db8aaa613365dcb83b98a
Btrfs: fix typo in fallocate to make it honor actual size
[ Trivial backport to 2.6.35/2.6.36 ]
There is a typo in __btrfs_prealloc_file_range() where we set the i_size to
actual_len/cur_offset, and then just set it to cur_offset again, and do the same
with btrfs_ordered_update_i_size(). This fixes it back to keeping i_size in a
local variable and then updating i_size properly. Tested this with
xfs_io -F -f -c "falloc 0 1" -c "pwrite 0 1" foo
stat'ing foo gives us a size of 1 instead of 4096 like it was. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
---
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 37cc177..0058fb3 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7002,6 +7002,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_key ins;
u64 cur_offset = start;
+ u64 i_size;
int ret = 0;
while (num_bytes > 0) {
@@ -7043,11 +7044,11 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
(actual_len > inode->i_size) &&
(cur_offset > inode->i_size)) {
if (cur_offset > actual_len)
- i_size_write(inode, actual_len);
+ i_size = actual_len;
else
- i_size_write(inode, cur_offset);
- i_size_write(inode, cur_offset);
- btrfs_ordered_update_i_size(inode, cur_offset, NULL);
+ i_size = cur_offset;
+ i_size_write(inode, i_size);
+ btrfs_ordered_update_i_size(inode, i_size, NULL);
}
ret = btrfs_update_inode(trans, root, inode);

View File

@ -821,6 +821,9 @@ Patch13701: e1000e-82566DC-fails-to-get-link.patch
# CVE-2010-4668
Patch13702: block-check-for-proper-length-of-iov-entries-earlier-in-blk_rq_map_user_iov.patch
# RHBZ #669511
Patch13703: btrfs-fix-typo-in-fallocate-to-make-it-honor-actual-size.patch
%endif
BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root
@ -1297,6 +1300,9 @@ ApplyPatch btrfs-fix-error-handling-in-btrfs_get_sub.patch
ApplyPatch btrfs-setup-blank-root-and-fs_info-for-mount-time.patch
ApplyPatch btrfs-fix-race-between-btrfs_get_sb-and-unmount.patch
# RHBZ #669511
ApplyPatch btrfs-fix-typo-in-fallocate-to-make-it-honor-actual-size.patch
# eCryptfs
# NFSv4
@ -2129,6 +2135,9 @@ fi
# and build.
%changelog
* Sun Jan 16 2011 Chuck Ebbert <cebbert@redhat.com>
- Fix wrong file allocation size in btrfs (#669511)
* Mon Jan 10 2011 Jarod Wilson <jarod@redhat.com> 2.6.35.10-77
- Add support for local rebuild config option overrides
- Add missing --with/--without pae build flag support