All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: replace: Reset on-disk dev stats value after replace
       [not found] <cover.1533020736.git.misono.tomohiro@jp.fujitsu.com>
@ 2018-07-31  7:20 ` Misono Tomohiro
  2018-08-01 13:06   ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Misono Tomohiro @ 2018-07-31  7:20 UTC (permalink / raw)
  To: linux-btrfs

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(+)

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
-- 
2.14.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs: replace: Reset on-disk dev stats value after replace
  2018-07-31  7:20 ` [PATCH] btrfs: replace: Reset on-disk dev stats value after replace Misono Tomohiro
@ 2018-08-01 13:06   ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2018-08-01 13:06 UTC (permalink / raw)
  To: Misono Tomohiro; +Cc: linux-btrfs

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-01 14:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1533020736.git.misono.tomohiro@jp.fujitsu.com>
2018-07-31  7:20 ` [PATCH] btrfs: replace: Reset on-disk dev stats value after replace Misono Tomohiro
2018-08-01 13:06   ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.