aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/dev-replace.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2014-09-03 09:35:34 -0400
committerChris Mason <clm@fb.com>2014-09-17 16:38:34 -0400
commitce7213c70c37e3a66bc0b50c45edcbfea505f62f (patch)
tree3b458f3f28ae3d69f508b4bd9194a264f74f6f34 /fs/btrfs/dev-replace.c
parent935e5cc935bcbf9b3d0dd59fed7dbc0f2ebca6bc (diff)
Btrfs: fix wrong device bytes_used in the super block
device->bytes_used will be changed when allocating a new chunk, and disk_total_size will be changed if resizing is successful. Meanwhile, the on-disk super blocks of the previous transaction might not be updated. Considering the consistency of the metadata in the previous transaction, We should use the size in the previous transaction to check if the super block is beyond the boundary of the device. Though it is not big problem because we don't use it now, but anyway it is better that we make it be consistent with the common metadata, maybe we will use it in the future. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r--fs/btrfs/dev-replace.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 7877b0fc6a8d..1be03d85d267 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -172,6 +172,8 @@ no_valid_dev_replace_entry_found:
172 dev_replace->srcdev->commit_total_bytes; 172 dev_replace->srcdev->commit_total_bytes;
173 dev_replace->tgtdev->bytes_used = 173 dev_replace->tgtdev->bytes_used =
174 dev_replace->srcdev->bytes_used; 174 dev_replace->srcdev->bytes_used;
175 dev_replace->tgtdev->commit_bytes_used =
176 dev_replace->srcdev->commit_bytes_used;
175 } 177 }
176 dev_replace->tgtdev->is_tgtdev_for_dev_replace = 1; 178 dev_replace->tgtdev->is_tgtdev_for_dev_replace = 1;
177 btrfs_init_dev_replace_tgtdev_for_resume(fs_info, 179 btrfs_init_dev_replace_tgtdev_for_resume(fs_info,
@@ -558,6 +560,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
558 ASSERT(list_empty(&src_device->resized_list)); 560 ASSERT(list_empty(&src_device->resized_list));
559 tgt_device->commit_total_bytes = src_device->commit_total_bytes; 561 tgt_device->commit_total_bytes = src_device->commit_total_bytes;
560 tgt_device->bytes_used = src_device->bytes_used; 562 tgt_device->bytes_used = src_device->bytes_used;
563 tgt_device->commit_bytes_used = src_device->bytes_used;
561 if (fs_info->sb->s_bdev == src_device->bdev) 564 if (fs_info->sb->s_bdev == src_device->bdev)
562 fs_info->sb->s_bdev = tgt_device->bdev; 565 fs_info->sb->s_bdev = tgt_device->bdev;
563 if (fs_info->fs_devices->latest_bdev == src_device->bdev) 566 if (fs_info->fs_devices->latest_bdev == src_device->bdev)