All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert White <rwhite@pobox.com>
To: Roman Mamedov <rm@romanrm.net>, linux-btrfs@vger.kernel.org
Subject: Re: Can't cp --reflink files on a Ext4-converted FS w/o checksums
Date: Wed, 26 Nov 2014 15:18:26 -0800	[thread overview]
Message-ID: <54765FC2.2050309@pobox.com> (raw)
In-Reply-To: <20141127005527.42a7fe59@natsu>

On 11/26/2014 11:55 AM, Roman Mamedov wrote:
> Is there really a good reason to stop these files without checksums from being
> cloneable? It's not like they have the noCoW attribute, so I'd assume any new
> write to these files would cause a CoW and proper checksums for all new blocks
> anyways.

The problem seems to be that you are trying to clone a NODATASUM file to 
a file that would have data checsums. The resulting file _might_ then 
end up with some extents with, and others without, checksums if that 
target file were modified.

So you _could_ reflink the file but you'd have to do it to another file 
with no data checksums -- which basically means a NOCOW file, or 
mounting with nodatasum while you do the reflink, but now you have more 
problem files.

linux/fs/btrfs/ioctl.c @ ~ line 2930
         /* don't make the dst file partly checksummed */
         if ((BTRFS_I(src)->flags & BTRFS_INODE_NODATASUM) !=
             (BTRFS_I(dst)->flags & BTRFS_INODE_NODATASUM)) {
                 ret = -EINVAL;
                 goto out_unlock;
         }

Basically if the system allowed you to reflink from a no-data-sum to a 
data-sum file the results would be instantly unreadable for failing 
every single data checksum test. That or the entire checksum system 
would have to be advisory instead of functional.

So yes, there is a good reason.


David Foster Wallace famously said "act in haste, repent in leasure". 
You kind-of shot yourself in the foot while attempting to save time. You 
promised yourself that you didn't need the checksums.

Now at this point I'm going to make a few guesses...

I don't see _anywhere_ in the kernel source or btrfs-progs where 
BTRFS_INODE_NODATASUM is explicitly cleared from any inode ever. It 
might be implicitly cleared somewhere but I couldn't find it. So all 
those unsummed files are probably unsummed for life.

I also don't see anything in the code that says "this ioctl will create 
the checksums for the selected file" so you may have to do the copy you 
tried to avoid.

Sorry man...

If you haven't done much with the file system yet, you might want to 
reverse the conversion and do it again.

Otherwise, you will want to copy the files long-hand, possibly in 
batches if you are more than 50% full on disk space.

On the bright side...

This would be the perfect moment to think about your backup/snapshot 
scheme. I always have a /whatever (e.g. /__System for a root partition) 
as my default subvolume that I normally mount. When I do my backups I 
mount -o subvol=/ /dev/whathaveyou /mnt/maintenance and then do my 
snapshots in /mnt/maintenance. That way every file in my N snapshots 
doesn't show up in the output of locate N+1 times. (e.g. this lets me 
"hide" my local snapshots/backups from normal operations)

Also, now would be the perfect time to add compression to your default 
regime. Compressing the files only happens on write and so using 
compression involves a copy anyway.

-- Rob.

  reply	other threads:[~2014-11-26 23:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-26 19:55 Can't cp --reflink files on a Ext4-converted FS w/o checksums Roman Mamedov
2014-11-26 23:18 ` Robert White [this message]
2014-11-26 23:33   ` Roman Mamedov
2014-11-27  0:00     ` Robert White
2014-11-27  0:20       ` Roman Mamedov
2014-11-27  0:31         ` Robert White
2014-11-27  0:57           ` Robert White
2014-11-27  0:20     ` Robert White
2014-11-27  0:28       ` Roman Mamedov
2014-11-27  0:45         ` Robert White
2014-11-27  9:27   ` Duncan
2014-11-28  7:12     ` Robert White
2014-11-27  3:31 ` Liu Bo

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=54765FC2.2050309@pobox.com \
    --to=rwhite@pobox.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=rm@romanrm.net \
    /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.