Skip to content

Commit e65cbb9

Browse files
author
Josef Bacik
committed
Btrfs: only set cache_generation if we setup the block group
A user reported a problem booting into a new kernel with the old format inodes. He was panicing in cow_file_range while writing out the inode cache. This is because if the block group is not cached we'll just skip writing out the cache, however if it gets dirtied again in the same transaction and it finished caching we'd go ahead and write it out, but since we set cache_generation to the transid we think we've already truncated it and will just carry on, running into cow_file_range and blowing up. We need to make sure we only set cache_generation if we've done the truncate. The user tested this patch and verified that the panic no longer occured. Thanks, Reported-and-Tested-by: Klaus Bitto <klaus.bitto@gmail.com> Signed-off-by: Josef Bacik <josef@redhat.com>
1 parent ee4d89f commit e65cbb9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎fs/btrfs/extent-tree.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2822,7 +2822,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
28222822
btrfs_release_path(path);
28232823
out:
28242824
spin_lock(&block_group->lock);
2825-
if (!ret)
2825+
if (!ret && dcs == BTRFS_DC_SETUP)
28262826
block_group->cache_generation = trans->transid;
28272827
block_group->disk_cache_state = dcs;
28282828
spin_unlock(&block_group->lock);

0 commit comments

Comments
 (0)