All of
 help / color / mirror / Atom feed
* [PATCH] btrfs: device stat, log when zeroed assist audit
@ 2020-01-10  4:26 Anand Jain
  2020-01-10 15:07 ` Josef Bacik
  2020-01-10 19:47 ` Nikolay Borisov
  0 siblings, 2 replies; 5+ messages in thread
From: Anand Jain @ 2020-01-10  4:26 UTC (permalink / raw)
  To: linux-btrfs

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)

Signed-off-by: Anand Jain <>
 BTRFS info (device sdc): device stats zeroed by btrfs (9223)
The last words are name and pid of the process, unfortunately it came out
as 'by btrfs'. At some point if there is a python and lib to reset it
would change, otherwise its going to be 'by btrfs', I am ok with it,
if otherwise please suggest the alternative.

 fs/btrfs/volumes.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index eb55df0d4038..6fd90270e2c7 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7324,6 +7324,8 @@ int btrfs_get_dev_stats(struct btrfs_fs_info *fs_info,
 				btrfs_dev_stat_set(dev, i, 0);
+		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)

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

end of thread, other threads:[~2020-01-13 16:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10  4:26 [PATCH] btrfs: device stat, log when zeroed assist audit Anand Jain
2020-01-10 15:07 ` Josef Bacik
2020-01-11  8:50   ` Anand Jain
2020-01-13 16:59     ` David Sterba
2020-01-10 19:47 ` Nikolay Borisov

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.