Message ID | e913d7ad-24b0-d361-9841-e15882b521fc@jp.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: replace: Reset on-disk dev stats value after replace | expand |
On Tue, Jul 31, 2018 at 04:20:21PM +0900, Misono Tomohiro wrote: > 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). 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. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index e2ba0419297a..d20b244623f2 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -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
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. Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> --- fs/btrfs/dev-replace.c | 6 ++++++ 1 file changed, 6 insertions(+)