* need to check for -EAGAIN.
*/
ret = btrfs_truncate_inode_items(trans, root, inode, &control);
+
+ btrfs_inode_safe_disk_i_size_write(inode, control.last_size);
+
unlock_extent_cached(&inode->io_tree, 0, (u64)-1, &cached_state);
if (ret)
goto fail;
u64 extent_num_bytes = 0;
u64 extent_offset = 0;
u64 item_end = 0;
- u64 last_size = new_size;
u32 found_type = (u8)-1;
int del_item;
int pending_del_nr = 0;
BUG_ON(new_size > 0 && control->min_type != BTRFS_EXTENT_DATA_KEY);
+ control->last_size = new_size;
+
/*
* For shareable roots we want to back off from time to time, this turns
* out to be subvolume roots, reloc roots, and data reloc roots.
}
if (del_item)
- last_size = found_key.offset;
+ control->last_size = found_key.offset;
else
- last_size = new_size;
+ control->last_size = new_size;
if (del_item) {
if (!pending_del_nr) {
/* No pending yet, add ourselves */
ret = err;
}
}
- if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
- ASSERT(last_size >= new_size);
- if (!ret && last_size > new_size)
- last_size = new_size;
- btrfs_inode_safe_disk_i_size_write(inode, last_size);
- }
+
+ ASSERT(control->last_size >= new_size);
+ if (!ret && control->last_size > new_size)
+ control->last_size = new_size;
btrfs_free_path(path);
return ret;
/* OUT: the number of extents truncated. */
u64 extents_found;
+ /* OUT: the last size we truncated this inode to. */
+ u64 last_size;
+
/*
* IN: minimum key type to remove. All key types with this type are
* removed only if their offset >= new_size.
ret = btrfs_truncate_inode_items(trans, root, BTRFS_I(inode),
&control);
+
+ btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), control.last_size);
+
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lock_start,
(u64)-1, &cached_state);