linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>
To: Francesco Turco <fturco@fastmail.fm>, linux-btrfs@vger.kernel.org
Subject: Re: Frequent btrfs corruption on a USB flash drive
Date: Thu, 7 Jul 2016 10:27:05 -0400	[thread overview]
Message-ID: <87efcca5-6871-2dde-e2df-40602f1a24c2@gmail.com> (raw)
In-Reply-To: <0120508a-b9e7-b9e7-4f27-79f982ee07fe@fastmail.fm>

On 2016-07-07 09:49, Francesco Turco wrote:
> I have a USB flash drive with an encrypted Btrfs filesystem where I
> store daily backups. My problem is that this btrfs filesystem gets
> corrupted very often, after a few days of usage. Usually I just reformat
> it and move along, but this time I'd like to understand the root cause
> of the problem and fix it.
>
> I can mount the partition without problems, but then when using commands
> such as rsync or even humble ls I get the following error message:
>
> $ rsync /home/fturco/Buffer/E-book/
> /run/media/fturco/5283147c-b7b4-448f-97b0-b235344a56a3/Buffer/E-book/
> --recursive
> rsync:
> readlink_stat("/run/media/fturco/5283147c-b7b4-448f-97b0-b235344a56a3/Riviste")
> failed: Stale file handle (116)
> rsync:
> readlink_stat("/run/media/fturco/5283147c-b7b4-448f-97b0-b235344a56a3/Backup")
> failed: Stale file handle (116)
> rsync:
> readdir("/run/media/fturco/5283147c-b7b4-448f-97b0-b235344a56a3/Calibre
> (TMSU)"): Input/output error (5)
This seems odd, are you trying to access anything over NFS or some other 
network filesystem protocol here?  If not, then I believe you've found a 
bug, because I'm pretty certain we shouldn't be returning -ESTALE for 
anything.
>
> The previous command gets stuck and I had to manually stop it.
>
> The following command doesn't return any output, but its exit code is 1
> (failure):
>
> $ btrfs filesystem show
> /run/media/fturco/5283147c-b7b4-448f-97b0-b235344a56a3
> $
Something is definitely wrong here.  Unless Parabola has seriously 
modified btrfs-progs, this should be spitting out info about the devices 
and filesystem usage.  This may be a result of the errors seen by check, 
but I doubt that
>
> Btrfs-check reports many errors. I attached the output to this e-mail
> message.
Looking at this, I see a couple of things I know it should fix correctly 
(the 'errors 2001' stuff is fixable, and I'm pretty certain that the 
'errors 200' thing is too, and I think it will fix the bytenr mismatch 
stuff mostly safely), but there's enough I'm not sure about that I can't 
in good conscience recommend that you run check with --repair, as it may 
make things worse.  Hopefully someone who actually understands what the 
other things actually mean can provide more help on that.
>
> Output from dmesg:
>
> $ dmesg | tail
> [18756.159963] BTRFS error (device dm-4): bad tree block start
> 6592115285688248773 35323904
> [18756.160828] BTRFS error (device dm-4): bad tree block start
> 8533404122473270145 35323904
> [18756.161821] BTRFS error (device dm-4): bad tree block start
> 6592115285688248773 35323904
> [18756.163047] BTRFS error (device dm-4): bad tree block start
> 8533404122473270145 35323904
> [18756.163921] BTRFS error (device dm-4): bad tree block start
> 6592115285688248773 35323904
> [18756.164806] BTRFS error (device dm-4): bad tree block start
> 8533404122473270145 35323904
> [18756.165673] BTRFS error (device dm-4): bad tree block start
> 6592115285688248773 35323904
> [18756.166548] BTRFS error (device dm-4): bad tree block start
> 8533404122473270145 35323904
> [18757.950603] BTRFS error (device dm-4): bad tree block start
> 6592115285688248773 35323904
> [18757.951492] BTRFS error (device dm-4): bad tree block start
> 8533404122473270145 35323904
>
> I checked this USB flash drive with badblocks in non-destructive
> read-write mode. No errors.
>
> If I format this partition as Ext4 instead of Btrfs I can use it without
> problems, but my goal is to use Btrfs on all devices.
The question here is: Do you get any data corruption when using ext4? 
Quite often when there's a hardware issue, you won't see _any_ 
indication of it other than corrupted files when using something like 
ext4 or XFS, but it will show up almost immediately with BTRFS because 
we validate checksums on almost everything.  There have been at least a 
couple of times I've found disk issues while converting from ext4 to 
BTRFS that I didn't know existed before, and then going back was able to 
reliable reproduce using other tools.

Also, FWIW, badblocks is not necessarily a reliable test method for 
flash drives, they often handle serialized reads like badblocks does 
very well even when failing.

Just to clarify, you're using BTRFS on top of disk encryption (LUKS? Or 
is it just raw encryption, or even something completely different?), on 
a USB flash drive (not a USB to SATA adapter with an SSD or HDD in it), 
correct?
>
> My GNU/Linux distribution is Parabola GNU/Linux-libre.
> Kernel version is: 4.6.3.
> Btrfs-progs version is: 4.6
>
> Please tell me if you need other details. Thanks.
>


  reply	other threads:[~2016-07-07 14:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-07 13:49 Frequent btrfs corruption on a USB flash drive Francesco Turco
2016-07-07 14:27 ` Austin S. Hemmelgarn [this message]
2016-07-07 14:55   ` Francesco Turco
2016-07-07 15:42     ` Austin S. Hemmelgarn
2016-07-07 18:25     ` Chris Murphy
2016-07-07 18:41       ` Francesco Turco
2016-07-07 17:57 ` Chris Murphy
2016-07-08 16:10   ` Francesco Turco
2016-07-08 16:53     ` Austin S. Hemmelgarn
2016-07-08 18:16       ` Henk Slager
2016-07-07 21:11 ` Andrew E. Mileski
2016-07-07 21:13   ` Francesco Turco
2016-07-07 22:38     ` Andrew E. Mileski
2016-07-07 23:07       ` Chris Murphy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87efcca5-6871-2dde-e2df-40602f1a24c2@gmail.com \
    --to=ahferroin7@gmail.com \
    --cc=fturco@fastmail.fm \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).