Skip to content

Commit 1e7e1f9

Browse files
t-msnkdave
authored andcommitted
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 incrementing dev_stats_ccnt in btrfs_dev_replace_finishing() when replace is succeeded and this will update the values. Signed-off-by: Misono Tomohiro <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 85c3954 commit 1e7e1f9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/btrfs/dev-replace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,12 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
671671

672672
btrfs_rm_dev_replace_unblocked(fs_info);
673673

674+
/*
675+
* Increment dev_stats_ccnt so that btrfs_run_dev_stats() will
676+
* update on-disk dev stats value during commit transaction
677+
*/
678+
atomic_inc(&tgt_device->dev_stats_ccnt);
679+
674680
/*
675681
* this is again a consistent state where no dev_replace procedure
676682
* is running, the target device is part of the filesystem, the

0 commit comments

Comments
 (0)