From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Mason Subject: Re: What do the arguments of btrfs filesystem defragment do? Date: Wed, 15 Dec 2010 14:57:01 -0500 Message-ID: <1292441925-sup-1105@think> References: <4D08E76B.40400@logtenberg.eu> <1292439708-sup-2951@think> <4D091387.9050905@logtenberg.eu> <1292440771-sup-9278@think> <4D091679.80706@logtenberg.eu> Content-Type: text/plain; charset=UTF-8 Cc: linux-btrfs To: Erik Logtenberg Return-path: In-reply-to: <4D091679.80706@logtenberg.eu> List-ID: Excerpts from Erik Logtenberg's message of 2010-12-15 14:26:49 -0500: > >> Is there a decent way to have btrfs compress already existing files > >> (that were written before compression was enabled) without hurting any > >> of the internal structures such as snapshots? > > > > I'm afraid not yet. There is code for this in the btrfs balance > > routines, but we haven't yet adapted it to the defragment command. > > Okay, just to be 100% sure, if I add -o compress to the mount options, > this will cause btrfs to (try to) compress newly written files, right? Yes > Is this fully compatible with existing snapshots, or will compressing > files always (have a chance to) hurt COW relations? COW references (both via snapshotting and cp --reflink) are broken when you change the file in either copy. While the files are the same, they are shared and the parts that change are private to each copy. If you have a reflink copy of a 1TB file and change only 4K in the middle, the other 1TB-4KB are still shared. This is true for both the default and with compression on. > > The use case is a filesystem used for backups, which are rsynced > nightly, after which a new snapshot is made. After something like 45 > days, the old snapshots are removed. I am assuming that this way, after > 45 days all files will be compressed naturally, but this is only > beneficial if snapshots still fully work. If instead it results in > storing the compressed form of every file 45 times on disk, then it > won't help much. Yes, you'll end up with a fully compressed and fully shared setup after 45 days. -chris