linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to remount btrfs without compression?
@ 2011-11-07  0:53 dima
  2011-11-07 12:19 ` Martin Steigerwald
  0 siblings, 1 reply; 19+ messages in thread
From: dima @ 2011-11-07  0:53 UTC (permalink / raw)
  To: linux-btrfs

Hello,

Is there any possibility to remount a compressed btrfs without any 
compression at all?

Syslinux bootloader does not understand any btrfs compression and 
whenever I edit syslinux.cfg on my compressed / subvolume, the file 
becomes compressed and thus unreadable by syslinux on the next boot.

I tried to remount / without the 'compress' option (and edit 
syslinux.cfg in uncompressed state) and while the "mount" command would 
not show compression any more, I can see in the /proc/mounts that 
compression is still there and the file still gets compressed after 
editing. But there seem to be no mount option like compress=none or 
something.

The only workaround I found is to boot from a live CD mount / without 
any compression and re-save syslinux.cfg. Then it the file gets 
uncompressed.

Are there any other options except for this workaround to temporarily 
remount btrfs without compression?

thanks

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-07  0:53 How to remount btrfs without compression? dima
@ 2011-11-07 12:19 ` Martin Steigerwald
  2011-11-08  0:55   ` dima
  0 siblings, 1 reply; 19+ messages in thread
From: Martin Steigerwald @ 2011-11-07 12:19 UTC (permalink / raw)
  To: linux-btrfs

Am Montag, 7. November 2011 schrieb dima:
> Hello,

Hi Dima,
=20
> Is there any possibility to remount a compressed btrfs without any
> compression at all?
>=20
> Syslinux bootloader does not understand any btrfs compression and
> whenever I edit syslinux.cfg on my compressed / subvolume, the file
> becomes compressed and thus unreadable by syslinux on the next boot.
>=20
> I tried to remount / without the 'compress' option (and edit
> syslinux.cfg in uncompressed state) and while the "mount" command wou=
ld
> not show compression any more, I can see in the /proc/mounts that
> compression is still there and the file still gets compressed after
> editing. But there seem to be no mount option like compress=3Dnone or
> something.
>=20
> The only workaround I found is to boot from a live CD mount / without
> any compression and re-save syslinux.cfg. Then it the file gets
> uncompressed.
>=20
> Are there any other options except for this workaround to temporarily
> remount btrfs without compression?

What does lsattr show on the file? Have you tried chattr -c on the file=
? It=20
might help to do a btrfs filesystem defrag on the file to remove=20
compression, cause I don=C2=B4t think chattr -c itself will uncompress =
it.

As far as I understand it is possible to individually set compression=20
on/off on single files. Although the global thing should work as well I=
MHO=20
as least when the file is rewritten.

Ciao,
--=20
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-07 12:19 ` Martin Steigerwald
@ 2011-11-08  0:55   ` dima
  2011-11-08  1:06     ` Eric Griffith
  0 siblings, 1 reply; 19+ messages in thread
From: dima @ 2011-11-08  0:55 UTC (permalink / raw)
  To: linux-btrfs

On 11/07/2011 09:19 PM, Martin Steigerwald wrote:
> Am Montag, 7. November 2011 schrieb dima:
>> Hello,
>
> Hi Dima,
>
>> Is there any possibility to remount a compressed btrfs without any
>> compression at all?
>>
>> Syslinux bootloader does not understand any btrfs compression and
>> whenever I edit syslinux.cfg on my compressed / subvolume, the file
>> becomes compressed and thus unreadable by syslinux on the next boot.
>>
>> I tried to remount / without the 'compress' option (and edit
>> syslinux.cfg in uncompressed state) and while the "mount" command wo=
uld
>> not show compression any more, I can see in the /proc/mounts that
>> compression is still there and the file still gets compressed after
>> editing. But there seem to be no mount option like compress=3Dnone o=
r
>> something.
>>
>> The only workaround I found is to boot from a live CD mount / withou=
t
>> any compression and re-save syslinux.cfg. Then it the file gets
>> uncompressed.
>>
>> Are there any other options except for this workaround to temporaril=
y
>> remount btrfs without compression?
>
> What does lsattr show on the file? Have you tried chattr -c on the fi=
le? It
> might help to do a btrfs filesystem defrag on the file to remove
> compression, cause I don=C2=B4t think chattr -c itself will uncompres=
s it.

Hi Martin,
Thanks for your reply.
Yes, I did check out lsattr. It shows that no flags are set. Setting=20
chattr +c then chattr -c and re-saving file has no effect either.

I also tried to defragment the file itself and the directory where it=20
was in without setting -c but it would not have any effect because / is=
=20
mounted with compression.

> As far as I understand it is possible to individually set compression
> on/off on single files.

Could not find how to turn it off though.

thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-08  0:55   ` dima
@ 2011-11-08  1:06     ` Eric Griffith
  2011-11-08  1:52       ` Fajar A. Nugraha
  0 siblings, 1 reply; 19+ messages in thread
From: Eric Griffith @ 2011-11-08  1:06 UTC (permalink / raw)
  To: dima; +Cc: linux-btrfs

On 11/7/2011 7:55 PM, dima wrote:
> On 11/07/2011 09:19 PM, Martin Steigerwald wrote:
>> Am Montag, 7. November 2011 schrieb dima:
>>> Hello,
>>
>> Hi Dima,
>>
>>> Is there any possibility to remount a compressed btrfs without any
>>> compression at all?
>>>
>>> Syslinux bootloader does not understand any btrfs compression and
>>> whenever I edit syslinux.cfg on my compressed / subvolume, the file
>>> becomes compressed and thus unreadable by syslinux on the next boot=
=2E
>>>
>>> I tried to remount / without the 'compress' option (and edit
>>> syslinux.cfg in uncompressed state) and while the "mount" command w=
ould
>>> not show compression any more, I can see in the /proc/mounts that
>>> compression is still there and the file still gets compressed after
>>> editing. But there seem to be no mount option like compress=3Dnone =
or
>>> something.
>>>
>>> The only workaround I found is to boot from a live CD mount / witho=
ut
>>> any compression and re-save syslinux.cfg. Then it the file gets
>>> uncompressed.
>>>
>>> Are there any other options except for this workaround to temporari=
ly
>>> remount btrfs without compression?
>>
>> What does lsattr show on the file? Have you tried chattr -c on the
>> file? It
>> might help to do a btrfs filesystem defrag on the file to remove
>> compression, cause I don=C2=B4t think chattr -c itself will uncompre=
ss it.
>
> Hi Martin,
> Thanks for your reply.
> Yes, I did check out lsattr. It shows that no flags are set. Setting
> chattr +c then chattr -c and re-saving file has no effect either.
>
> I also tried to defragment the file itself and the directory where it
> was in without setting -c but it would not have any effect because / =
is
> mounted with compression.
>
>> As far as I understand it is possible to individually set compressio=
n
>> on/off on single files.
>
> Could not find how to turn it off though.
>
> thanks
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs=
" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html


Hey Dima, I know if you install a system without the compress flag=20
already done, you can force BTRFS to compress everything post-install b=
y=20
teling it to "rebalance" the filesystem. I'm under Win7 right now so I=20
dont know the exact command. Check btrfs --help for that.

I dont know if it works in reverse, but you can definitely try it. Edit=
=20
your fstab, remove the compress flag, reboot. Tell btrfs to rebalance=20
the system, reboot again. And I -THINK- that'll decompress all the file=
s
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-08  1:06     ` Eric Griffith
@ 2011-11-08  1:52       ` Fajar A. Nugraha
  2011-11-08  1:54         ` Eric Griffith
  0 siblings, 1 reply; 19+ messages in thread
From: Fajar A. Nugraha @ 2011-11-08  1:52 UTC (permalink / raw)
  To: Eric Griffith; +Cc: dima, linux-btrfs

On Tue, Nov 8, 2011 at 8:06 AM, Eric Griffith <egriffith92@gmail.com> wrote:
> Edit your
> fstab, remove the compress flag, reboot. Tell btrfs to rebalance the system,
> reboot again. And I -THINK- that'll decompress all the files

I think the original question was how to force uncompressed mode,
whether specific to a file or to a whole filesystem, without having to
reboot :)

AFAIK there's no way to do that.

-- 
Fajar

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-08  1:52       ` Fajar A. Nugraha
@ 2011-11-08  1:54         ` Eric Griffith
  2011-11-08  2:00           ` dima
  0 siblings, 1 reply; 19+ messages in thread
From: Eric Griffith @ 2011-11-08  1:54 UTC (permalink / raw)
  To: linux-btrfs

On 11/7/2011 8:52 PM, Fajar A. Nugraha wrote:
> On Tue, Nov 8, 2011 at 8:06 AM, Eric Griffith<egriffith92@gmail.com>  wrote:
>> Edit your
>> fstab, remove the compress flag, reboot. Tell btrfs to rebalance the system,
>> reboot again. And I -THINK- that'll decompress all the files
>
> I think the original question was how to force uncompressed mode,
> whether specific to a file or to a whole filesystem, without having to
> reboot :)
>
> AFAIK there's no way to do that.
>

Whoops! Misunderstood the question haha. Yeah, as far as decompressing 
just a single file; from what I've read, thats impossible.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-08  1:54         ` Eric Griffith
@ 2011-11-08  2:00           ` dima
  2011-11-08 15:01             ` Chris Mason
  0 siblings, 1 reply; 19+ messages in thread
From: dima @ 2011-11-08  2:00 UTC (permalink / raw)
  To: linux-btrfs

On 11/08/2011 10:54 AM, Eric Griffith wrote:
> On 11/7/2011 8:52 PM, Fajar A. Nugraha wrote:
>> On Tue, Nov 8, 2011 at 8:06 AM, Eric Griffith<egriffith92@gmail.com>
>> wrote:
>>> Edit your
>>> fstab, remove the compress flag, reboot. Tell btrfs to rebalance the
>>> system,
>>> reboot again. And I -THINK- that'll decompress all the files
>>
>> I think the original question was how to force uncompressed mode,
>> whether specific to a file or to a whole filesystem, without having to
>> reboot :)
>>
>> AFAIK there's no way to do that.
>>
>
> Whoops! Misunderstood the question haha. Yeah, as far as decompressing
> just a single file; from what I've read, thats impossible.


Eric, Fajar,
Thanks. Understood.

Yes, it is possible to remove the compress flag from fstab, reboot and 
even do not do any defragmentation/rebalancing - just re-save the file 
and it will be saved uncompressed. This works. But only with reboot...

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-08  2:00           ` dima
@ 2011-11-08 15:01             ` Chris Mason
  2011-11-08 15:12               ` Chris Mason
  0 siblings, 1 reply; 19+ messages in thread
From: Chris Mason @ 2011-11-08 15:01 UTC (permalink / raw)
  To: dima; +Cc: linux-btrfs

On Tue, Nov 08, 2011 at 11:00:42AM +0900, dima wrote:
> On 11/08/2011 10:54 AM, Eric Griffith wrote:
> >On 11/7/2011 8:52 PM, Fajar A. Nugraha wrote:
> >>On Tue, Nov 8, 2011 at 8:06 AM, Eric Griffith<egriffith92@gmail.com>
> >>wrote:
> >>>Edit your
> >>>fstab, remove the compress flag, reboot. Tell btrfs to rebalance the
> >>>system,
> >>>reboot again. And I -THINK- that'll decompress all the files
> >>
> >>I think the original question was how to force uncompressed mode,
> >>whether specific to a file or to a whole filesystem, without having to
> >>reboot :)
> >>
> >>AFAIK there's no way to do that.
> >>
> >
> >Whoops! Misunderstood the question haha. Yeah, as far as decompressing
> >just a single file; from what I've read, thats impossible.
> 
> 
> Eric, Fajar,
> Thanks. Understood.
> 
> Yes, it is possible to remove the compress flag from fstab, reboot
> and even do not do any defragmentation/rebalancing - just re-save
> the file and it will be saved uncompressed. This works. But only
> with reboot...

chattr -c on the file should work (followed by defrag or rewriting the
file).  I just retested and it seems to be broken right now.

I'll track it down.

-chris


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-08 15:01             ` Chris Mason
@ 2011-11-08 15:12               ` Chris Mason
  2011-11-09  1:01                 ` dima
  0 siblings, 1 reply; 19+ messages in thread
From: Chris Mason @ 2011-11-08 15:12 UTC (permalink / raw)
  To: dima; +Cc: linux-btrfs

On Tue, Nov 08, 2011 at 10:01:51AM -0500, Chris Mason wrote:
> On Tue, Nov 08, 2011 at 11:00:42AM +0900, dima wrote:
> > On 11/08/2011 10:54 AM, Eric Griffith wrote:
> > >On 11/7/2011 8:52 PM, Fajar A. Nugraha wrote:
> > >>On Tue, Nov 8, 2011 at 8:06 AM, Eric Griffith<egriffith92@gmail.com>
> > >>wrote:
> > >>>Edit your
> > >>>fstab, remove the compress flag, reboot. Tell btrfs to rebalance the
> > >>>system,
> > >>>reboot again. And I -THINK- that'll decompress all the files
> > >>
> > >>I think the original question was how to force uncompressed mode,
> > >>whether specific to a file or to a whole filesystem, without having to
> > >>reboot :)
> > >>
> > >>AFAIK there's no way to do that.
> > >>
> > >
> > >Whoops! Misunderstood the question haha. Yeah, as far as decompressing
> > >just a single file; from what I've read, thats impossible.
> > 
> > 
> > Eric, Fajar,
> > Thanks. Understood.
> > 
> > Yes, it is possible to remove the compress flag from fstab, reboot
> > and even do not do any defragmentation/rebalancing - just re-save
> > the file and it will be saved uncompressed. This works. But only
> > with reboot...
> 
> chattr -c on the file should work (followed by defrag or rewriting the
> file).  I just retested and it seems to be broken right now.
> 
> I'll track it down.

Ok, I had forgotten.  chattr -c clears the compression flag bug doesn't
set the no compress flag.  We looks like we need to patch chattr for
this.

-chris


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-08 15:12               ` Chris Mason
@ 2011-11-09  1:01                 ` dima
  2011-11-09  7:48                   ` Lubos Kolouch
  2011-11-10  0:11                   ` David Sterba
  0 siblings, 2 replies; 19+ messages in thread
From: dima @ 2011-11-09  1:01 UTC (permalink / raw)
  To: linux-btrfs

On 11/09/2011 12:12 AM, Chris Mason wrote:
> On Tue, Nov 08, 2011 at 10:01:51AM -0500, Chris Mason wrote:
>> On Tue, Nov 08, 2011 at 11:00:42AM +0900, dima wrote:
>>> On 11/08/2011 10:54 AM, Eric Griffith wrote:
>>>> On 11/7/2011 8:52 PM, Fajar A. Nugraha wrote:
>>>>> On Tue, Nov 8, 2011 at 8:06 AM, Eric Griffith<egriffith92@gmail.com>
>>>>> wrote:
>>>>>> Edit your
>>>>>> fstab, remove the compress flag, reboot. Tell btrfs to rebalance the
>>>>>> system,
>>>>>> reboot again. And I -THINK- that'll decompress all the files
>>>>>
>>>>> I think the original question was how to force uncompressed mode,
>>>>> whether specific to a file or to a whole filesystem, without having to
>>>>> reboot :)
>>>>>
>>>>> AFAIK there's no way to do that.
>>>>>
>>>>
>>>> Whoops! Misunderstood the question haha. Yeah, as far as decompressing
>>>> just a single file; from what I've read, thats impossible.
>>>
>>>
>>> Eric, Fajar,
>>> Thanks. Understood.
>>>
>>> Yes, it is possible to remove the compress flag from fstab, reboot
>>> and even do not do any defragmentation/rebalancing - just re-save
>>> the file and it will be saved uncompressed. This works. But only
>>> with reboot...
>>
>> chattr -c on the file should work (followed by defrag or rewriting the
>> file).  I just retested and it seems to be broken right now.
>>
>> I'll track it down.
>
> Ok, I had forgotten.  chattr -c clears the compression flag bug doesn't
> set the no compress flag.  We looks like we need to patch chattr for
> this.
>
> -chris
>


Just for the record - I could find a solution thanks to the btrfs wiki 
being online again. In Gotchas it says

mount -o nodatacow also disables compression

and indeed it does. Remounting with this option and re-saving the file 
makes it uncompressed. However, I could not find how to remount the 
filesystem afterwards without nodatacow.

~dima

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-09  1:01                 ` dima
@ 2011-11-09  7:48                   ` Lubos Kolouch
  2011-11-09  8:03                     ` Dmitry Olenin
  2011-11-09  8:04                     ` Fajar A. Nugraha
  2011-11-10  0:11                   ` David Sterba
  1 sibling, 2 replies; 19+ messages in thread
From: Lubos Kolouch @ 2011-11-09  7:48 UTC (permalink / raw)
  To: linux-btrfs

dima, Wed, 09 Nov 2011 10:01:13 +0900:

> On 11/09/2011 12:12 AM, Chris Mason wrote:
>> On Tue, Nov 08, 2011 at 10:01:51AM -0500, Chris Mason wrote:
>>> On Tue, Nov 08, 2011 at 11:00:42AM +0900, dima wrote:
>>>> On 11/08/2011 10:54 AM, Eric Griffith wrote:
>>>>> On 11/7/2011 8:52 PM, Fajar A. Nugraha wrote:
>>>>>> On Tue, Nov 8, 2011 at 8:06 AM, Eric
>>>>>> Griffith<egriffith92@gmail.com> wrote:
>>>>>>> Edit your fstab, remove the compress flag, reboot. Tell btrfs to
>>>>>>> rebalance the system,
>>>>>>> reboot again. And I -THINK- that'll decompress all the files
>>>>>>
>>>>>> I think the original question was how to force uncompressed mode,
>>>>>> whether specific to a file or to a whole filesystem, without having
>>>>>> to reboot :)
>>>>>>
>>>>>> AFAIK there's no way to do that.
>>>>>>
>>>>>>
>>>>> Whoops! Misunderstood the question haha. Yeah, as far as
>>>>> decompressing just a single file; from what I've read, thats
>>>>> impossible.
>>>>
>>>>
>>>> Eric, Fajar,
>>>> Thanks. Understood.
>>>>
>>>> Yes, it is possible to remove the compress flag from fstab, reboot
>>>> and even do not do any defragmentation/rebalancing - just re-save the
>>>> file and it will be saved uncompressed. This works. But only with
>>>> reboot...
>>>
>>> chattr -c on the file should work (followed by defrag or rewriting the
>>> file).  I just retested and it seems to be broken right now.
>>>
>>> I'll track it down.
>>
>> Ok, I had forgotten.  chattr -c clears the compression flag bug doesn't
>> set the no compress flag.  We looks like we need to patch chattr for
>> this.
>>
>> -chris
>>
>>
> 
> Just for the record - I could find a solution thanks to the btrfs wiki
> being online again. In Gotchas it says
> 
> mount -o nodatacow also disables compression
> 
> and indeed it does. Remounting with this option and re-saving the file
> makes it uncompressed. However, I could not find how to remount the
> filesystem afterwards without nodatacow.
> 
> ~dima

Sorry for possibly OT question - when I have historical btrfs system
mounted with zlib compression,

can I remount it with lzo ? What will happen? Will the COW be broken
and the files taking duplicate space? Or will the Universe explode and
be replaced with something even more bizzare?

Thank you 

Lubos


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-09  7:48                   ` Lubos Kolouch
@ 2011-11-09  8:03                     ` Dmitry Olenin
  2011-11-10  6:57                       ` Lubos Kolouch
  2011-11-09  8:04                     ` Fajar A. Nugraha
  1 sibling, 1 reply; 19+ messages in thread
From: Dmitry Olenin @ 2011-11-09  8:03 UTC (permalink / raw)
  To: linux-btrfs

On 11/09/2011 04:48 PM, Lubos Kolouch wrote:
> Sorry for possibly OT question - when I have historical btrfs system
> mounted with zlib compression,
>
> can I remount it with lzo ? What will happen? Will the COW be broken
> and the files taking duplicate space? Or will the Universe explode and
> be replaced with something even more bizzare?

Hello Lubos
If you have a kernel that supports lzo (don't quite remember when it got 
in), why can't you?
Absolutely nothing will happen, and only the new/updated files will be 
with lzo compression. You can remount on the fly switching b/w the two 
compression options without any problems.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-09  7:48                   ` Lubos Kolouch
  2011-11-09  8:03                     ` Dmitry Olenin
@ 2011-11-09  8:04                     ` Fajar A. Nugraha
  2011-11-09 13:01                       ` Chris Mason
  1 sibling, 1 reply; 19+ messages in thread
From: Fajar A. Nugraha @ 2011-11-09  8:04 UTC (permalink / raw)
  To: Lubos Kolouch; +Cc: linux-btrfs

On Wed, Nov 9, 2011 at 2:48 PM, Lubos Kolouch <lubos.kolouch@gmail.com> wrote:
> Sorry for possibly OT question - when I have historical btrfs system
> mounted with zlib compression,
>
> can I remount it with lzo ?

yes

> What will happen? Will the COW be broken
> and the files taking duplicate space? Or will the Universe explode and
> be replaced with something even more bizzare?

New written block/extents will use lzo compression (if it's
compressible, or if it's mounted with compress-force). Old, unmodified
block/extents will remain unchanged, using zlib or uncompressed.

-- 
Fajar

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-09  8:04                     ` Fajar A. Nugraha
@ 2011-11-09 13:01                       ` Chris Mason
  0 siblings, 0 replies; 19+ messages in thread
From: Chris Mason @ 2011-11-09 13:01 UTC (permalink / raw)
  To: Fajar A. Nugraha; +Cc: Lubos Kolouch, linux-btrfs

On Wed, Nov 09, 2011 at 03:04:01PM +0700, Fajar A. Nugraha wrote:
> On Wed, Nov 9, 2011 at 2:48 PM, Lubos Kolouch <lubos.kolouch@gmail.com> wrote:
> > Sorry for possibly OT question - when I have historical btrfs system
> > mounted with zlib compression,
> >
> > can I remount it with lzo ?
> 
> yes
> 
> > What will happen? Will the COW be broken
> > and the files taking duplicate space? Or will the Universe explode and
> > be replaced with something even more bizzare?
> 
> New written block/extents will use lzo compression (if it's
> compressible, or if it's mounted with compress-force). Old, unmodified
> block/extents will remain unchanged, using zlib or uncompressed.

This is correct, your old stuff will be zlib and your new stuff lzo.
The compression type is recorded on a per-extent basis and the global
switch just decides what type of compression to use for new writes.

-chris


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-09  1:01                 ` dima
  2011-11-09  7:48                   ` Lubos Kolouch
@ 2011-11-10  0:11                   ` David Sterba
  2011-11-10  2:23                     ` dima
  1 sibling, 1 reply; 19+ messages in thread
From: David Sterba @ 2011-11-10  0:11 UTC (permalink / raw)
  To: dima; +Cc: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 2193 bytes --]

On Wed, Nov 09, 2011 at 10:01:13AM +0900, dima wrote:
> Just for the record - I could find a solution thanks to the btrfs wiki 
> being online again. In Gotchas it says
> 
> mount -o nodatacow also disables compression
> 
> and indeed it does. Remounting with this option and re-saving the file 
> makes it uncompressed. However, I could not find how to remount the 
> filesystem afterwards without nodatacow.

I saw this mentioned on irc today (that nodatacow diasables
compression). There is a way how to turn off compression on a file --
with help of the NOCOW _file_ attribute, ie. you don't have to remount.

* create the file, compression enabled
* set NOCOW (with the attached single-purpose nocow.c utility)
* btrfs fi defrag the_file

Make sure you have enough free space for the uncompressed file size. You
can compare the extent layout before and after the defrag with
"filefrag -v" .

I did a test first, here's what I saw with a ~60M file (filled with
zeros, suitable for compression):

# filefrag -v zerofile2
Filesystem type is: 9123683e
File size of zerofile2 is 69927424 (17073 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0     2700              32
   1      32     2942     2731     32
   2      64     2943     2973     32
   3      96     2944     2974     32
   4     128     2945     2975     32
...
 533   17039     2641     2671     32
 534   17071     2643     2672      2 eof
zerofile2: 535 extents found

# btrfs fi defrag zerofile2

# filefrag -v zerofile2
Filesystem type is: 9123683e
File size of zerofile2 is 69927424 (17073 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0    20992            2107
   1    2107    23552    23098   1581
   2    3688    16400    25132   1185
   3    4873    12410    17584    889
   4    5762    14762    13298    667
   5    6429    15881    15428    500
   6    6929    17585    16380    751
   7    7680    23099    18335    375
   8    8055    25133    23473    376
   9    8431     3072    25508   2160
  10   10591     5632     5231   1620
  11   12211     8192     7251   2431
  12   14642    18432    10622   2431 eof
zerofile2: 13 extents found


david

[-- Attachment #2: nocow.c --]
[-- Type: text/plain, Size: 1220 bytes --]

#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <string.h>

#include <linux/types.h>
#include <stdio.h>
#include <errno.h>

#ifndef FS_IOC_SETFLAGS
#define FS_IOC_SETFLAGS                 _IOW('f', 2, long)
#warning defining SETFLAGS locally
#endif

#ifndef FS_IOC_GETFLAGS
#define FS_IOC_GETFLAGS                 _IOR('f', 1, long)
#warning defining GETFLAGS locally
#endif

#ifndef FS_NOCOW_FL
#define FS_NOCOW_FL                     0x00800000 /* Do not cow file */
#endif

int main(int argc, char **argv)
{
        int fd;
        int r;
	long flags;

	if (argc < 2) {
		printf("usage: %s file\n", argv[0]);
		exit(1);
	}

        fd = open(argv[1], O_RDONLY);
	if (fd == -1) {
		perror("open()");
		return 1;
	}
	printf("GETFLAGS ioctl 0x%x\n", FS_IOC_GETFLAGS);
	printf("SETFLAGS ioctl 0x%x\n", FS_IOC_SETFLAGS);

	r = ioctl(fd, FS_IOC_GETFLAGS, &flags);
	if (r == -1) {
		perror("ioctl(GETFLAGS)");
		return 1;
	} else {
		printf("file flags: 0x%lx\n", flags);
	}

	printf("Set NOCOW flag for %s\n", argv[1]);
	flags |= FS_NOCOW_FL;
        r = ioctl(fd, FS_IOC_SETFLAGS, &flags);
	printf("ioctl returned: %d\n", r);
	if (r == -1) {
		perror("ioctl()");
		return 1;
	}

        return 0;
}

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-10  0:11                   ` David Sterba
@ 2011-11-10  2:23                     ` dima
  2011-11-11 13:29                       ` dima
  0 siblings, 1 reply; 19+ messages in thread
From: dima @ 2011-11-10  2:23 UTC (permalink / raw)
  To: linux-btrfs

On 11/10/2011 09:11 AM, David Sterba wrote:
> On Wed, Nov 09, 2011 at 10:01:13AM +0900, dima wrote:
>> Just for the record - I could find a solution thanks to the btrfs wiki
>> being online again. In Gotchas it says
>>
>> mount -o nodatacow also disables compression
>>
>> and indeed it does. Remounting with this option and re-saving the file
>> makes it uncompressed. However, I could not find how to remount the
>> filesystem afterwards without nodatacow.
>
> I saw this mentioned on irc today (that nodatacow diasables
> compression). There is a way how to turn off compression on a file --
> with help of the NOCOW _file_ attribute, ie. you don't have to remount.
>
> * create the file, compression enabled
> * set NOCOW (with the attached single-purpose nocow.c utility)
> * btrfs fi defrag the_file
>
> Make sure you have enough free space for the uncompressed file size. You
> can compare the extent layout before and after the defrag with
> "filefrag -v" .


Hello David,

Thank you, I will try it out tonight. Is there any way to see if nocow 
attribute was set on a particular file, and is there any way to unset it?

thanks
~dima

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-09  8:03                     ` Dmitry Olenin
@ 2011-11-10  6:57                       ` Lubos Kolouch
  2011-11-10  7:04                         ` Dmitry Olenin
  0 siblings, 1 reply; 19+ messages in thread
From: Lubos Kolouch @ 2011-11-10  6:57 UTC (permalink / raw)
  To: linux-btrfs

Dmitry Olenin, Wed, 09 Nov 2011 17:03:39 +0900:

> On 11/09/2011 04:48 PM, Lubos Kolouch wrote:
>> Sorry for possibly OT question - when I have historical btrfs system
>> mounted with zlib compression,
>>
>> can I remount it with lzo ? What will happen? Will the COW be broken
>> and the files taking duplicate space? Or will the Universe explode and
>> be replaced with something even more bizzare?
> 
> Hello Lubos If you have a kernel that supports lzo (don't quite remember
> when it got in), why can't you?
> Absolutely nothing will happen, and only the new/updated files will be
> with lzo compression. You can remount on the fly switching b/w the two
> compression options without any problems.

Hello Dmitry,

By the way, this is interesting question to me - I mounted the filesystem
with -o compress=lzo, in dmesg showed btrfs: use lzo compression,

but - the lzo module was not loaded (not shown in lsmod - and yes, I have
it as a module).

When I do modprobe lzo, it shows there.

Isn't it a bit strange? So btrfs is using lzo module that was not loaded?
(and says so in the dmesg output)?

Thank you

Lubos


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-10  6:57                       ` Lubos Kolouch
@ 2011-11-10  7:04                         ` Dmitry Olenin
  0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Olenin @ 2011-11-10  7:04 UTC (permalink / raw)
  To: linux-btrfs

On 11/10/2011 03:57 PM, Lubos Kolouch wrote:
> Dmitry Olenin, Wed, 09 Nov 2011 17:03:39 +0900:
>
>> On 11/09/2011 04:48 PM, Lubos Kolouch wrote:
>>> Sorry for possibly OT question - when I have historical btrfs system
>>> mounted with zlib compression,
>>>
>>> can I remount it with lzo ? What will happen? Will the COW be broken
>>> and the files taking duplicate space? Or will the Universe explode and
>>> be replaced with something even more bizzare?
>>
>> Hello Lubos If you have a kernel that supports lzo (don't quite remember
>> when it got in), why can't you?
>> Absolutely nothing will happen, and only the new/updated files will be
>> with lzo compression. You can remount on the fly switching b/w the two
>> compression options without any problems.
>
> Hello Dmitry,
>
> By the way, this is interesting question to me - I mounted the filesystem
> with -o compress=lzo, in dmesg showed btrfs: use lzo compression,
>
> but - the lzo module was not loaded (not shown in lsmod - and yes, I have
> it as a module).
>
> When I do modprobe lzo, it shows there.
>
> Isn't it a bit strange? So btrfs is using lzo module that was not loaded?
> (and says so in the dmesg output)?

Hello Lubos
Yes, I was wondering about this too when I started doing lzo.
The lzo module you load most likely has nothing to do with btrfs. This 
is the only explanation. I would think that lzo for btrfs is built into 
kernel. Unfortunately I don't have my .config with me at the moment to 
check it.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: How to remount btrfs without compression?
  2011-11-10  2:23                     ` dima
@ 2011-11-11 13:29                       ` dima
  0 siblings, 0 replies; 19+ messages in thread
From: dima @ 2011-11-11 13:29 UTC (permalink / raw)
  To: linux-btrfs

On 11/10/2011 11:23 AM, dima wrote:
> On 11/10/2011 09:11 AM, David Sterba wrote:
>> On Wed, Nov 09, 2011 at 10:01:13AM +0900, dima wrote:
>>> Just for the record - I could find a solution thanks to the btrfs wiki
>>> being online again. In Gotchas it says
>>>
>>> mount -o nodatacow also disables compression
>>>
>>> and indeed it does. Remounting with this option and re-saving the file
>>> makes it uncompressed. However, I could not find how to remount the
>>> filesystem afterwards without nodatacow.
>>
>> I saw this mentioned on irc today (that nodatacow diasables
>> compression). There is a way how to turn off compression on a file --
>> with help of the NOCOW _file_ attribute, ie. you don't have to remount.
>>
>> * create the file, compression enabled
>> * set NOCOW (with the attached single-purpose nocow.c utility)
>> * btrfs fi defrag the_file
>>
>> Make sure you have enough free space for the uncompressed file size. You
>> can compare the extent layout before and after the defrag with
>> "filefrag -v" .
>
>
> Hello David,
>
> Thank you, I will try it out tonight. Is there any way to see if nocow
> attribute was set on a particular file, and is there any way to unset it?


Hi David
I tried the nocow utility. It worked.
First I made sure to re-save the syslinux.cfg file while btrfs was 
mounted with lzo to ensure that it is compressed, then I set the NOCOW 
flag with your utility. Then I checked fragmentation of the file and 
since it was a small one it was not fragmented. So when I ran btrfs fi 
defrag syslinux.cfg it did not have any effect and file was not 
uncompressed. Then I simply re-saved the file and it got uncompressed 
fine since bootloader could read it on reboot.

thanks

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-11-11 13:29 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-07  0:53 How to remount btrfs without compression? dima
2011-11-07 12:19 ` Martin Steigerwald
2011-11-08  0:55   ` dima
2011-11-08  1:06     ` Eric Griffith
2011-11-08  1:52       ` Fajar A. Nugraha
2011-11-08  1:54         ` Eric Griffith
2011-11-08  2:00           ` dima
2011-11-08 15:01             ` Chris Mason
2011-11-08 15:12               ` Chris Mason
2011-11-09  1:01                 ` dima
2011-11-09  7:48                   ` Lubos Kolouch
2011-11-09  8:03                     ` Dmitry Olenin
2011-11-10  6:57                       ` Lubos Kolouch
2011-11-10  7:04                         ` Dmitry Olenin
2011-11-09  8:04                     ` Fajar A. Nugraha
2011-11-09 13:01                       ` Chris Mason
2011-11-10  0:11                   ` David Sterba
2011-11-10  2:23                     ` dima
2011-11-11 13:29                       ` dima

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).