chattr: Invalid argument while setting flags on (compression on btrfs)

chattr refuses to add the c (compression) flag to some files on a btrfs filesystem (openSUSE 12.2 with 64bit Kernel:stable, i.e. 3.7.1-1-default):

> chattr +c *
chattr: Invalid argument while setting flags on …

More specifically: 2467 of 277000 files show this error, but I cannot see any pattern. All 277000 files are text files, with sizes between 0 B and 1.5 MB. btrfs is mounted as follows (reported by mount): rw,relatime,compress=lzo,space_cache

Please, when you want to tell what the computer tells you, do copy/paste all (from the prompt, including the command used, the output and the next promt) between CODE tags in a post here. You can get those tags by using the # button in the toolbar of the post editor.

That is much better then you telling stories with important computer facts mixed in those stories without proper border against the stories. And the are many more advantages like keeping of computer formatting, no smiley inetrpretation, etc.

The problem still exists in openSUSE 12.3 (64bit, default kernel).
Here are steps to reproduce the problem:


cd /your-btrfs-dir-with-mount-option-compresslzo
cp -a /usr/share/man .
cd man
find . -type l | xargs rm
gunzip -r .
chattr -R +c .

This leads to


chattr: Invalid argument while setting flags on ./man2/swapon.2

and some 600 more warnings (your number will vary because the
man directory depends on your package selection).

And chattr has not changed the attributes of the files mentioned in the above warnings:


> lsattr  ./man2/swapon.2
---------------- ./man2/swapon.2

i can find neither of your 12.2 nor 12.3 bugzilla entry…probably i
didn’t look enough…but, please return the URL or bug number to
this thread, thanks.


dd
openSUSE®, the “German Engineered Automobile” of operating systems!

Back in openSUSE 12.2, I had no reproducible example. Furthermore, the only reply I got was that I should use the CODE tag; which I tried to use above :slight_smile:

So, do you recommend to file a bug now against openSUSE 12.3?

On 2013-04-30 15:26, sven1999 wrote:
>
> Back in openSUSE 12.2, I had no reproducible example. Furthermore, the
> only reply I got was that I should use the CODE tag; which I tried to
> use above :slight_smile:
>
> So, do you recommend to file a bug now against openSUSE 12.3?

Obviously :slight_smile: (but read ahead)

If it is a bug, the only way to solve them is to report on Bugzilla. As
you are the person most interested in this feature, maybe if you had
replied to the post and reported last time, it /might/ have been solved :slight_smile:

By the way, what we expected you to do is something like this:


cer@Telcontar:~/tmp/args> chattr -R +c .
chattr: Operation not supported while setting flags on .
cer@Telcontar:~/tmp/args> chattr -R +c text
chattr: Operation not supported while setting flags on text
cer@Telcontar:~/tmp/args> l
total 8
drwxr-xr-x  2 cer users   17 Apr 30 16:51 ./
drwxr-xr-x 54 cer users 4096 Apr 30 16:50 ../
-rw-r--r--  1 cer users   25 Apr 30 16:51 text
cer@Telcontar:~/tmp/args> lsattr *
--------------- text
cer@Telcontar:~/tmp/args>

See? No stories, just commands and responses, so no interpretations by
anybody. Of course, in my case it fails because I do not have btrfs, I
just did that to show you how to do it :wink:

However, I see this in the manual:

+++···················
A file with the `c’ attribute set is automatically
compressed on the disk by the kernel. A read from
this file returns uncompressed data. A write to this
file compresses data before storing them on the disk.
Note: please make sure to read the bugs and limita-
tions section at the end of this document.

BUGS AND LIMITATIONS
The c', 's', and u’ attributes are not honored by
the ext2 and ext3 filesystems as implemented in the
current mainline Linux kernels. These attributes
may be implemented in future versions of the ext2 and
ext3 filesystems.

E2fsprogs version 1.41.1December 2010 CHATTR(1)

···················+±

So, maybe this program applies to ext2/3/4 filessystems only, no mention
of other types. Where did you read that it applies to btrfs filesystems?
Maybe it is supposed to work, but the devs will want you to make sure
first, or they will just gruff at us for using the wrong command and
wasting their time :wink:

Also, if you show us the link where you read about this method/feature,
maybe we can tell if it applies or not.

(and don’t keep silent another 4 months, please - speak up! We don’t
bite. We just eat you alive :-p )


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

On 04/30/2013 05:18 PM, Carlos E. R. wrote:
> maybe if you had > replied to the post and reported last time

exactly.

i saw the original post and the request for real computer output
inside code tags…and, i would have seen the reply with info had
it been forth coming…

afaik, no one here will beg the help seeker to help us help…if
the help seeker falls silent, so will most all potential helpers.


dd
openSUSE®, the “German Engineered Automobile” of operating systems!

Please excuse my slowness, but I was somewhat unsure about the problem in the meantime (after all, it is related to btrfs, which many people don’t want to hear about :slight_smile: ).

Anyway, let’s get to work; here is my bug report:https://bugzilla.novell.com/show_bug.cgi?id=818373

On 2013-05-03 16:26, sven1999 wrote:
>
> Please excuse my slowness, but I was somewhat unsure about the problem
> in the meantime (after all, it is related to btrfs, which many people
> don’t want to hear about :slight_smile: ).
>
> Anyway, let’s get to work; here is my bug report:’
> https://bugzilla.novell.com/show_bug.cgi?id=818373
> (https://bugzilla.novell.com/show_bug.cgi?id=818373)

Ok, I have created a virtual machine with 12.3, and I have a small btrfs
partition.


eleanor3:/data/btrfs/tmp # chattr +c pepe
eleanor3:/data/btrfs/tmp # l
total 8
drwxr-xr-x 1 root root   8 May  4 01:35 ./
dr-xr-xr-x 1 root root   6 May  4 01:35 ../
-rw-r--r-- 1 root root 320 May  4 01:35 pepe
eleanor3:/data/btrfs/tmp # lsattr *
--------c------- pepe
eleanor3:/data/btrfs/tmp # mount  | grep bt
/dev/sda9 on /data/btrfs type btrfs (rw,relatime,space_cache)
eleanor3:/data/btrfs/tmp # chattr -R +c .
eleanor3:/data/btrfs/tmp #

So the attribute is accepted. I do not know if there is actual
compression or how to find out.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

On 2013-05-04 01:53, Carlos E. R. wrote:

> So the attribute is accepted. I do not know if there is actual
> compression or how to find out.

I copied the /usr/bin directory, then, did:


eleanor3:/data/btrfs # chattr -R +c bin
chattr: Operation not supported while reading flags on bin/mclasserase
chattr: Operation not supported while reading flags on bin/mcd
chattr: Operation not supported while reading flags on bin/pnmarith
chattr: Operation not supported while reading flags on bin/man
chattr: Operation not supported while reading flags on bin/roff2html
chattr: Operation not supported while reading flags on bin/unxz
chattr: Operation not supported while reading flags on bin/roff2dvi
....

eleanor3:/data/btrfs # lsattr -v bin/
....
lsattr: Operation not supported While reading flags on bin/pamon
lsattr: Operation not supported While reading flags on bin/paplay
lsattr: Operation not supported While reading flags on bin/parec
20 --------c------- bin/pax11publish
20 --------c------- bin/pasuspender
20 --------c------- bin/start-pulseaudio-kde
20 --------c------- bin/start-pulseaudio-x11
eleanor3:/data/btrfs #

Some files are accepted, other not. However:


eleanor3:/data/btrfs # l bin/pamon bin/paplay bin/parec
lrwxrwxrwx 1 root root 5 May  4 01:59 bin/pamon -> pacat*
lrwxrwxrwx 1 root root 5 May  4 01:59 bin/paplay -> pacat*
lrwxrwxrwx 1 root root 5 May  4 01:59 bin/parec -> pacat*
eleanor3:/data/btrfs #

They are not files, they are symlinks. Symlinks can not be compressed.
Now you go and verify those on the bugzilla :wink:


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

Hi Carlos.

Thanks for your experiments.
I double checked that in both test cases (Dec and Apr) the reported files were normal files, no soft or hard links.

Ciao
Sven

Thanks for investigating …

As no compression is shown in this line, it is disabled. You must add the mount option compress=lzo in your fstab entry.

Ciao
Sven

On 2013-05-06 19:56, sven1999 wrote:
>
> robin_listas;2553650 Wrote:
>>
>> Ok, I have created a virtual machine with 12.3, and I have a small
>> btrfs partition.
>>
>
> Thanks for investigating …

Welcome… I do want a reliable filesystem with compression, I have
wanted it for years. MsDOS had it in the 80s, so why not Linux?

But I do not want the versioning or snapshots that btrfs has.

> robin_listas;2553650 Wrote:
>>
>> /dev/sda9 on /data/btrfs type btrfs (rw,relatime,space_cache)
>>
> As no compression is shown in this line, it is disabled. You must add
> the mount option compress=lzo in your fstab entry.

I thought so. But there must be some command to show the actual
compression achieved on each file :-?


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)