Skip to content

Commit 8df2085

Browse files
maharmstoneintel-lab-lkp
authored andcommitted
btrfs: update superblock's device bytes_used when dropping chunk
Each superblock contains a copy of the device item for that device. In a transaction which drops a chunk but doesn't create any new ones, we were correctly updating the device item in the chunk tree but not copying over the new bytes_used value to the superblock. This can be seen by doing the following: # cd # dd if=/dev/zero of=test bs=4096 count=2621440 # mkfs.btrfs test # mount test /root/temp # cd /root/temp # for i in {00..10}; do dd if=/dev/zero of=$i bs=4096 count=32768; done # sync # rm * # sync # btrfs balance start -dusage=0 . # sync # cd # umount /root/temp # btrfs check test (For btrfs-check to detect this, you will also need my patch at kdave/btrfs-progs#991.) Change btrfs_remove_dev_extents() so that it adds the devices to the post_commit_list if they're not there already. This causes btrfs_commit_device_sizes() to be called, which updates the bytes_used value in the superblock. Signed-off-by: Mark Harmstone <[email protected]>
1 parent 18e274f commit 8df2085

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/btrfs/volumes.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,6 +3282,12 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
32823282
device->bytes_used - dev_extent_len);
32833283
atomic64_add(dev_extent_len, &fs_info->free_chunk_space);
32843284
btrfs_clear_space_info_full(fs_info);
3285+
3286+
if (list_empty(&device->post_commit_list)) {
3287+
list_add_tail(&device->post_commit_list,
3288+
&trans->transaction->dev_update_list);
3289+
}
3290+
32853291
mutex_unlock(&fs_info->chunk_mutex);
32863292
}
32873293
}

0 commit comments

Comments
 (0)