aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2011-12-14 20:12:02 -0500
committerChris Mason <chris.mason@oracle.com>2011-12-15 10:50:36 -0500
commit3642320e07444cc46327b24977d752f99706dac2 (patch)
tree1ae0d347b6cd2330ca99041d2234672919ebffac /fs
parentf4a2f4c548296168832ad4ab7e7f7b0cd0bf1214 (diff)
Btrfs: fix wrong disk space information of the files
Btrfsck report errors after the 83th case of xfstests was run, The error number is 400, it means the used disk space of the file is wrong. The reason of this bug is that: The file truncation may fail when the space of the file system is not enough, and leave some file extents, whose offset are beyond the end of the files. When we want to expand those files, we will drop those file extents, and put in dummy file extents, and then we should update the i-node. But btrfs forgets to do it. This patch adds the forgotten i-node update. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/inode.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 4bbceb928aff..f1c4bceed072 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3327,7 +3327,7 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
3327 u64 hint_byte = 0; 3327 u64 hint_byte = 0;
3328 hole_size = last_byte - cur_offset; 3328 hole_size = last_byte - cur_offset;
3329 3329
3330 trans = btrfs_start_transaction(root, 2); 3330 trans = btrfs_start_transaction(root, 3);
3331 if (IS_ERR(trans)) { 3331 if (IS_ERR(trans)) {
3332 err = PTR_ERR(trans); 3332 err = PTR_ERR(trans);
3333 break; 3333 break;
@@ -3337,6 +3337,7 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
3337 cur_offset + hole_size, 3337 cur_offset + hole_size,
3338 &hint_byte, 1); 3338 &hint_byte, 1);
3339 if (err) { 3339 if (err) {
3340 btrfs_update_inode(trans, root, inode);
3340 btrfs_end_transaction(trans, root); 3341 btrfs_end_transaction(trans, root);
3341 break; 3342 break;
3342 } 3343 }
@@ -3346,6 +3347,7 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
3346 0, hole_size, 0, hole_size, 3347 0, hole_size, 0, hole_size,
3347 0, 0, 0); 3348 0, 0, 0);
3348 if (err) { 3349 if (err) {
3350 btrfs_update_inode(trans, root, inode);
3349 btrfs_end_transaction(trans, root); 3351 btrfs_end_transaction(trans, root);
3350 break; 3352 break;
3351 } 3353 }
@@ -3353,6 +3355,7 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
3353 btrfs_drop_extent_cache(inode, hole_start, 3355 btrfs_drop_extent_cache(inode, hole_start,
3354 last_byte - 1, 0); 3356 last_byte - 1, 0);
3355 3357
3358 btrfs_update_inode(trans, root, inode);
3356 btrfs_end_transaction(trans, root); 3359 btrfs_end_transaction(trans, root);
3357 } 3360 }
3358 free_extent_map(em); 3361 free_extent_map(em);