5

I caused some light data corruption on my array. I traced the problem down to bad hardware I swapped in by accident that immediately started acting up, that was involved in just a few writes.

Fortunately no data was lost. After replacing the known bad hardware and running a full scrub, Btrfs found redundant RAID-1 data for all three files involved (according to kern.log), which I later manually verified to be intact. SMART status on all the drives show no concerning issues - and like I said, I know what caused the corruption, the disks are fine, and that cause is gone.

But now when I do sudo btrfs device stats /mnt/arr2, by design it still shows those "permanently" accumulated error counts, whether they were repaired or not. And since they are irrelevant now in this case, I'd like to clear them - to make it easier to spot future actual HDD problems. Here's the list of my non-zero error tallies with that command:

[/dev/sdi].corruption_errs 281 [/dev/sdg].write_io_errs 16 [/dev/sdg].corruption_errs 265 [/dev/sdj].write_io_errs 54 [/dev/sdj].corruption_errs 768 

ZFS has zpool clear poolname, though those counts are more ephemeral anyway. Does Btrfs have anything similar?

Man and doc pages, and google, are mum on it. I've seen one hint that btrfs recover zero-log /mnt/arr2 might do the trick, but it was vague, and the intention of that specific command (according to official docs) goes far beyond that and seems like I would want to stay far away from it unless as a last resort to recover an array that won't mount.

Is there such a command in Btrfs? Thanks.

2
  • @KamilMaciorowski, that did the trick! Funny that so many google searches didn't turn that up, until I included the magic word "reset". I had been using "clear", "zero", practically everything in the thesaurus except "reset". Thanks. Commented Sep 6, 2022 at 4:27
  • Good. You can write an answer then. Commented Sep 6, 2022 at 4:29

1 Answer 1

9

As @KamilMaciorowski pointed out, the solution is:

btrfs device stats --reset /mnt/your-array

The --reset flag being the key.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.