blob: 1b8c299a0c35e6f7574da318ea4b02296d834f51 [file] [log] [blame]
From 497628fed9ce5170462be60dbef902f9a86d5e1e Mon Sep 17 00:00:00 2001
From: Anand Jain <>
Date: Fri, 10 Jan 2020 12:26:34 +0800
Subject: [PATCH] btrfs: device stats, log when stats are zeroed
commit a69976bc69308aa475d0ba3b8b3efd1d013c0460 upstream.
We had a report indicating that some read errors aren't reported by the
device stats in the userland. It is important to have the errors
reported in the device stat as user land scripts might depend on it to
take the reasonable corrective actions. But to debug these issue we need
to be really sure that request to reset the device stat did not come
from the userland itself. So log an info message when device error reset
For example:
BTRFS info (device sdc): device stats zeroed by btrfs(9223)
Reviewed-by: Josef Bacik <>
Signed-off-by: Anand Jain <>
Reviewed-by: David Sterba <>
Signed-off-by: David Sterba <>
Signed-off-by: Paul Gortmaker <>
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 8eb6178b1d16..548fc697adfa 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7523,6 +7523,8 @@ int btrfs_get_dev_stats(struct btrfs_fs_info *fs_info,
btrfs_dev_stat_reset(dev, i);
+ btrfs_info(fs_info, "device stats zeroed by %s (%d)",
+ current->comm, task_pid_nr(current));
} else {
for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++)
if (stats->nr_items > i)