All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>
To: Joerg Schilling <Joerg.Schilling@fokus.fraunhofer.de>,
	praiskup@redhat.com, adilger@dilger.ca
Cc: linux-btrfs@vger.kernel.org, bug-tar@gnu.org
Subject: Re: [Bug-tar] stat() on btrfs reports the st_blocks with delay (data loss in archivers)
Date: Wed, 6 Jul 2016 07:37:15 -0400	[thread overview]
Message-ID: <78b3f192-ec4b-6da2-91b4-7369c5eceadc@gmail.com> (raw)
In-Reply-To: <577b7dd1.tgcc3Oz1nmHZ676h%Joerg.Schilling@fokus.fraunhofer.de>

On 2016-07-05 05:28, Joerg Schilling wrote:
> Andreas Dilger <adilger@dilger.ca> wrote:
>
>> I think in addition to fixing btrfs (because it needs to work with existing
>> tar/rsync/etc. tools) it makes sense to *also* fix the heuristics of tar
>> to handle this situation more robustly.  One option is if st_blocks == 0 then
>> tar should also check if st_mtime is less than 60s in the past, and if yes
>> then it should call fsync() on the file to flush any unwritten data to disk,
>> or assume the file is not sparse and read the whole file, so that it doesn't
>> incorrectly assume that the file is sparse and skip archiving the file data.
>
> A broken filesystem is a broken filesystem.
>
> If you try to change gtar to work around a specific problem, it may fail in
> other situations.
The problem with this is that tar is assuming things that are not 
guaranteed to be true.  There is absolutely nothing that says that 
st_blocks has to be non-zero if there's data in the file.  In fact, the 
behavior that BTRFS used to have of reporting st_blocks to be 0 for 
files entirely inlined in the metadata is absolutely correct given the 
description of the field by POSIX, because there _are_ no blocks 
allocated to the file (because the metadata block is technically 
equivalent to the inode, which isn't counted by st_blocks).  This is yet 
another example of an old interface (in this case, sparse file 
detection) being short-sighted (read in this case as non-existent).

The proper fix for this is that tar (and anything else that handles 
sparse files differently) should be parsing the file regardless.  It has 
to anyway for a normal sparse file to figure out where the sparse 
regions are, and optimizing for a file that's completely sparse (and 
therefore probably pre-allocated with fallocate) is not all that 
reasonable considering that this is going to be a very rare case in 
normal usage.


  reply	other threads:[~2016-07-06 11:37 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-02  7:18 stat() on btrfs reports the st_blocks with delay (data loss in archivers) Pavel Raiskup
2016-07-04 19:35 ` [Bug-tar] " Andreas Dilger
2016-07-05  9:28   ` Joerg Schilling
2016-07-06 11:37     ` Austin S. Hemmelgarn [this message]
2016-07-06 11:49       ` Joerg Schilling
2016-07-06 14:43         ` Antonio Diaz Diaz
2016-07-06 14:53           ` Joerg Schilling
2016-07-06 15:01             ` Paul Eggert
2016-07-06 15:09               ` Joerg Schilling
2016-07-06 15:11                 ` Paul Eggert
2016-07-06 15:12             ` Austin S. Hemmelgarn
2016-07-06 15:22               ` Joerg Schilling
2016-07-06 16:05                 ` Austin S. Hemmelgarn
2016-07-06 16:11                   ` Austin S. Hemmelgarn
2016-07-06 16:33                   ` Joerg Schilling
2016-07-06 17:35                     ` Andreas Dilger
2016-07-07  8:08   ` Pavel Raiskup
2016-07-11 14:41 ` David Sterba
2016-07-11 15:00   ` Chris Mason
2016-07-11 15:16     ` David Sterba
2016-07-11 17:30       ` Chris Mason

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=78b3f192-ec4b-6da2-91b4-7369c5eceadc@gmail.com \
    --to=ahferroin7@gmail.com \
    --cc=Joerg.Schilling@fokus.fraunhofer.de \
    --cc=adilger@dilger.ca \
    --cc=bug-tar@gnu.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=praiskup@redhat.com \
    /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 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.