From: "Aneesh Kumar K. V" <aneesh.kumar@linux.vnet.ibm.com>
To: Paul Komkoff <i@stingr.net>, Chris Mason <chris.mason@oracle.com>,
Roland Dreier <rdreier@cisco.com>, Paul Komkoff <i@stingr.net>,
linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: btrfs fallocate woes
Date: Wed, 20 Jan 2010 12:58:54 +0530 [thread overview]
Message-ID: <87vdexdykp.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <715ea5c11001190718u396f41cua51ccf74c498482a@mail.gmail.com>
On Tue, 19 Jan 2010 15:18:26 +0000, Paul Komkoff <i@stingr.net> wrote:
> On Thu, Jan 14, 2010 at 8:33 PM, Paul Komkoff <i@stingr.net> wrote:
> > If it's fixed in latest tree it's fine, I guess that fix isn't in
> > fedora's 2.6.32.3
>
> Sorry for popping up again, but did anyone fix this/verified there's
> no problem in recent kernels? For some reasons I cannot run latest git
> so I'm stuck with fedora kernels, and every one I have around me (with
> btrfs) has this problem.
>
the below change fixes this for me on btrfs
commit f2bc9dd07e3424c4ec5f3949961fe053d47bc825
Author: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Date: Wed Jan 20 12:57:53 2010 +0530
btrfs: Use correct values when updating inode i_size on fallocate
Even though we allocate more, we should be updating inode i_size
as per the arguments passed
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5440bab..db406a4 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5789,7 +5789,7 @@ out_fail:
}
static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
- u64 alloc_hint, int mode)
+ u64 alloc_hint, int mode, loff_t actual_len)
{
struct btrfs_trans_handle *trans;
struct btrfs_root *root = BTRFS_I(inode)->root;
@@ -5798,6 +5798,7 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
u64 cur_offset = start;
u64 num_bytes = end - start;
int ret = 0;
+ u64 i_size;
while (num_bytes > 0) {
alloc_size = min(num_bytes, root->fs_info->max_extent);
@@ -5836,8 +5837,12 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;
if (!(mode & FALLOC_FL_KEEP_SIZE) &&
cur_offset > inode->i_size) {
- i_size_write(inode, cur_offset);
- btrfs_ordered_update_i_size(inode, cur_offset, NULL);
+ if (cur_offset > actual_len)
+ i_size = actual_len;
+ else
+ 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);
@@ -5930,7 +5935,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
!test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) {
ret = prealloc_file_range(inode,
cur_offset, last_byte,
- alloc_hint, mode);
+ alloc_hint, mode, offset+len);
if (ret < 0) {
free_extent_map(em);
break;
next prev parent reply other threads:[~2010-01-20 7:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-14 11:28 btrfs fallocate woes Paul Komkoff
2010-01-14 17:27 ` Roland Dreier
2010-01-14 18:24 ` Paul Komkoff
2010-01-14 18:25 ` Paul Komkoff
2010-01-14 18:26 ` Aneesh Kumar K. V
2010-01-14 19:20 ` Chris Mason
2010-01-14 20:33 ` Paul Komkoff
2010-01-19 15:18 ` Paul Komkoff
2010-01-20 7:28 ` Aneesh Kumar K. V [this message]
2010-01-20 15:13 ` Paul Komkoff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vdexdykp.fsf@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=chris.mason@oracle.com \
--cc=i@stingr.net \
--cc=linux-btrfs@vger.kernel.org \
--cc=rdreier@cisco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox