btrfs: replace: Reset on-disk dev stats value after replace
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 btrfs: replace: Reset on-disk dev stats value after replace
on-disk devs stats value is updated in btrfs_run_dev_stats(), which is called during commit transaction, if device->dev_stats_ccnt is not zero.
Since current replace operation does not touch dev_stats_ccnt, on-disk dev stats value is not updated. Therefore "btrfs device stats" may return old device's value after umount/mount
(Example: See "btrfs ins dump-t -t DEV $DEV" after btrfs/100 finish).
Fix this by just increment dev_stats_ccnt in btrfs_dev_replace_finishing() when replace is succeeded.
--- fs/btrfs/dev-replace.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/btrfs/dev-replace.c +6 -0
@@ -676,6 +676,12 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,btrfs_rm_dev_replace_unblocked (fs_info); +/* +* Increment dev_stats_ccnt so that btrfs_run_dev_stats() will +* update on-disk dev stats value during commit transaction +*/ +atomic_inc (&tgt_device->dev_stats_ccnt); +/* * this is again a consistent state where no dev_replace procedure * is running, the target device is part of the filesystem, the
Signature · 1 line
2.14.4
Quoted 8 lines · Misono Tomohiro
on-disk devs stats value is updated in
btrfs_run_dev_stats(), which is called during commit transaction, ifdevice->dev_stats_ccntis not zero.Since current replace operation does not touch
dev_stats_ccnt, on-disk dev stats value is not updated. Therefore "btrfs device stats" may return old device's value after umount/mount
(Example: See "btrfs ins dump-t -t DEV $DEV" after btrfs/100 finish).
In such cases it's good to have a snippet of the output, so it's possible to match the output and check if we see the same thing.
Otherwise looks ok, thanks.