aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 68127b8462ab..0afb6cece82c 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -136,8 +136,11 @@ static int btrfs_unlink_trans(struct btrfs_trans_handle *trans,
136err: 136err:
137 btrfs_release_path(root, path); 137 btrfs_release_path(root, path);
138 btrfs_free_path(path); 138 btrfs_free_path(path);
139 if (ret == 0) 139 if (ret == 0) {
140 inode_dec_link_count(dentry->d_inode); 140 inode_dec_link_count(dentry->d_inode);
141 dir->i_size -= name_len;
142 mark_inode_dirty(dir);
143 }
141 return ret; 144 return ret;
142} 145}
143 146
@@ -290,6 +293,10 @@ static int btrfs_truncate_in_trans(struct btrfs_trans_handle *trans,
290 key.objectid = inode->i_ino; 293 key.objectid = inode->i_ino;
291 key.offset = (u64)-1; 294 key.offset = (u64)-1;
292 key.flags = 0; 295 key.flags = 0;
296 /*
297 * use BTRFS_CSUM_ITEM_KEY because it is larger than inline keys
298 * or extent data
299 */
293 btrfs_set_key_type(&key, BTRFS_CSUM_ITEM_KEY); 300 btrfs_set_key_type(&key, BTRFS_CSUM_ITEM_KEY);
294 while(1) { 301 while(1) {
295 btrfs_init_path(path); 302 btrfs_init_path(path);
@@ -306,6 +313,7 @@ static int btrfs_truncate_in_trans(struct btrfs_trans_handle *trans,
306 if (btrfs_disk_key_objectid(found_key) != inode->i_ino) 313 if (btrfs_disk_key_objectid(found_key) != inode->i_ino)
307 break; 314 break;
308 if (btrfs_disk_key_type(found_key) != BTRFS_CSUM_ITEM_KEY && 315 if (btrfs_disk_key_type(found_key) != BTRFS_CSUM_ITEM_KEY &&
316 btrfs_disk_key_type(found_key) != BTRFS_INLINE_DATA_KEY &&
309 btrfs_disk_key_type(found_key) != BTRFS_EXTENT_DATA_KEY) 317 btrfs_disk_key_type(found_key) != BTRFS_EXTENT_DATA_KEY)
310 break; 318 break;
311 if (btrfs_disk_key_offset(found_key) < inode->i_size) 319 if (btrfs_disk_key_offset(found_key) < inode->i_size)
@@ -1036,7 +1044,7 @@ static void btrfs_truncate(struct inode *inode)
1036 if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) 1044 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
1037 return; 1045 return;
1038 1046
1039 nobh_truncate_page(inode->i_mapping, inode->i_size); 1047 // nobh_truncate_page(inode->i_mapping, inode->i_size);
1040 1048
1041 /* FIXME, add redo link to tree so we don't leak on crash */ 1049 /* FIXME, add redo link to tree so we don't leak on crash */
1042 mutex_lock(&root->fs_info->fs_mutex); 1050 mutex_lock(&root->fs_info->fs_mutex);
@@ -1309,7 +1317,9 @@ again:
1309 } 1317 }
1310insert: 1318insert:
1311 btrfs_release_path(root, path); 1319 btrfs_release_path(root, path);
1312 copy_size = min(write_bytes, (size_t)512); 1320 copy_size = min(write_bytes,
1321 (size_t)BTRFS_LEAF_DATA_SIZE(root) -
1322 sizeof(struct btrfs_item) * 4);
1313 ret = btrfs_insert_empty_item(trans, root, path, &key, copy_size); 1323 ret = btrfs_insert_empty_item(trans, root, path, &key, copy_size);
1314 BUG_ON(ret); 1324 BUG_ON(ret);
1315 dst = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]), 1325 dst = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]),