Skip to contentSkip to conversation

btrfs: device stat, log when zeroed assist audit

PATCH In review Anand Jain 4 participants 5 messages Jan 10, 2020 – Jan 13, 2020 Btrfs file system

lore
Share & tools
lore

Anand Jain

author
#0 lore raw

PATCH 1/1 btrfs: device stat, log when zeroed assist audit

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 happens.

For example:
BTRFS info (device sdc): device stats zeroed by btrfs (9223)

---
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(+)
fs/btrfs/volumes.c +2 -0
index eb55df0d4038..6fd90270e2c7 100644
@@ -7324,6 +7324,8 @@ int btrfs_get_dev_stats(struct btrfs_fs_info *fs_info,
 			else
 				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)
Signature · 1 line
2.23.0
#1 lore raw
Quoted 14 lines · Anand Jain

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 happens.

For example:
BTRFS info (device sdc): device stats zeroed by btrfs (9223)

Quoted 6 lines

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

I think name(pid) makes sense, similar to what drop_caches does

pr_info("%s (%d): drop_caches: %d\n",

	current->comm, task_pid_nr(current),

Thanks,

Josef

author
#2 lore raw
Quoted 22 lines · Josef Bacik
Quoted 14 lines · Anand Jain

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 happens.

For example:
  BTRFS info (device sdc): device stats zeroed by btrfs (9223)

Quoted 6 lines

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

Quoted 4 lines

I think name(pid) makes sense, similar to what drop_caches does

pr_info("%s (%d): drop_caches: %d\n",
    current->comm, task_pid_nr(current),

There is a small deviation to what we already have in device_list_add(), name (pid) is at the end the log message..

------
pr_info(
"BTRFS: device label %s devid %llu transid %llu %s scanned by
%s (%d)\n",

                                disk_super->label, devid, 
found_transid, path,
                                current->comm, task_pid_nr(current));

--------

I am not sure. Can David can tweak during merge ?

Thanks, Anand

Quoted 3 lines

Thanks,

Josef

#3 lore raw
Quoted 35 lines · Anand Jain
Quoted 22 lines · Josef Bacik
Quoted 14 lines · Anand Jain

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 happens.

For example:
  BTRFS info (device sdc): device stats zeroed by btrfs (9223)

Quoted 6 lines

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

Quoted 4 lines

I think name(pid) makes sense, similar to what drop_caches does

pr_info("%s (%d): drop_caches: %d\n",
    current->comm, task_pid_nr(current),

There is a small deviation to what we already have in device_list_add(), name (pid) is at the end the log message..

------
pr_info(
"BTRFS: device label %s devid %llu transid %llu %s scanned by
%s (%d)\n",

Quoted 6 lines
                                 disk_super->label, devid, 
found_transid, path,
                                 current->comm, task_pid_nr(current));

--------

I am not sure. Can David can tweak during merge ?

Yes, no problem.

#4 lore raw
In reply to Anand Jain
Quoted 14 lines · Anand Jain

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 happens.

For example:
BTRFS info (device sdc): device stats zeroed by btrfs (9223)

Quoted 6 lines

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

This patch itself is OK but is not related to what Philip has reported. The issue there is the fact we only record errors for 2 specific retvals from block layer.

Quoted 18 lines
 fs/btrfs/volumes.c | 2 ++
 1 file changed, 2 insertions(+)
fs/btrfs/volumes.c +2 -0
index eb55df0d4038..6fd90270e2c7 100644
@@ -7324,6 +7324,8 @@ int btrfs_get_dev_stats(struct btrfs_fs_info *fs_info,
 			else
 				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)