]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
btrfs: replace: Reset on-disk dev stats value after replace
authorMisono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Tue, 31 Jul 2018 07:20:21 +0000 (16:20 +0900)
committerDavid Sterba <dsterba@suse.com>
Mon, 6 Aug 2018 11:13:01 +0000 (13:13 +0200)
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 <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/dev-replace.c

index 5a72f9933e58233622fd5eea02f6d2b0322a80aa..dec01970d8c581cb1efe3a8fad59a075542ffa9e 100644 (file)
@@ -671,6 +671,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