This discussion is archived
4 Replies Latest reply: Oct 17, 2012 4:49 PM by Dude! RSS

Btrfs nodatacow

Dude! Guru
Currently Being Moderated
https://btrfs.wiki.kernel.org/index.php/FAQ

Can copy-on-write be turned off for data blocks?

Yes, you can disable it by mounting with -o nodatacow. This implies -o nodatasum as well. COW may still happen if a snapshot is taken.

I was wondering why there is such an option. Isn't COW required for Btrfs in order to support snapshots? Since COW can be disabled, does it mean that COW is happening all the time, regardless of snapshots?
  • 1. Re: Btrfs nodatacow
    Avi Miller Guru
    Currently Being Moderated
    Dude wrote:
    I was wondering why there is such an option. Isn't COW required for Btrfs in order to support snapshots? Since COW can be disabled, does it mean that COW is happening all the time, regardless of snapshots?
    COW is happening all the time. That's the whole point of btrfs. Everything is COW'd unless/except if you mount with nodatacow (or flag a particular file as not to be COW'd).
  • 2. Re: Btrfs nodatacow
    Dude! Guru
    Currently Being Moderated
    Doesn't this mean data will end up pretty much scattered all around in case there are a lot of changes to files?
    If there are no snapshots, is Btrfs reusing data blocks/metadata when the disk runs out of fresh/unused blocks?
    Is Btrfs suitable for multimedia editing, storing VM images, swapfile, datafiles, etc.?
  • 3. Re: Btrfs nodatacow
    Avi Miller Guru
    Currently Being Moderated
    Dude wrote:
    Doesn't this mean data will end up pretty much scattered all around in case there are a lot of changes to files?
    Yes.
    If there are no snapshots, is Btrfs reusing data blocks/metadata when the disk runs out of fresh/unused blocks?
    Yes. btfrs also maintains a space cache to know where it can write.
    Is Btrfs suitable for multimedia editing, storing VM images, swapfile, datafiles, etc.?
    Yes and no. A lot of work has been done in the mainline btrfs development that's not in UEK2 (yet) that improves btrfs' performance in a lot of areas, particularly with direct I/O, but it probably won't beat XFS or ASM for a while yet. Unless you turn off datacow, I guess. But that kinda defeats the purpose of btrfs. You could flag particular files as nodatacow though, to get the benefits generally, but not specifically for some files.
  • 4. Re: Btrfs nodatacow
    Dude! Guru
    Currently Being Moderated
    Thanks for clearing up my doubts!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points