Informatics

F2FS with ACLs on Raspbmc

I’ve always been kind of reluctant to adopt new file systems.

A file system is for me a fundamental part of an OS, one which failure is an inconceivable circumstance.

Nonetheless, I gladly used F2FS for the raspbmc installation on my Raspberry Pi when this distribution adopted it. And in fact it ran in very well condition…

Until the distribution reached kernel 3.12.21 which included new f2fs functions that I was expecting eagerly to explore (inline xattrs mainly).

Unfortunately some undesirable side effects conducted me to discover that in fact the new update had mangled the ACL behaviour to the point that any operation on a file with ACL permissions resulted on a filesystem hang, which was unrecoverable without reboot.

The problem can be easily replicated with last raspbmc distribution (as of August-October 2014) on a system with f2fs:

setfacl is needed and it’s included in “acl” package. Last version is 2.2.51-8:

# apt-get install acl
# mkdir hello
# chown daemon hello
# setfacl -m d:u:pi:rwx hello
# cd hello
# touch HELLO

Beware! this commands on a kernel 3.12.21 with F2FS fs can provoke the console to hang and the system can be unusable until reboot.

It’s been a very unexpected discovery… accented by the fact that raspbmc abandoned f2fs in favor of ext3fs again. I cannot say this latter has been unexpected. It is very difficult for a new filesystem to reach the point of tests and stability of ext3…

Well, I’m not sure where’s exactly the problem… the kernel itself? f2fs? Is other linux distributions with the same kernel and F2FS affected? dunno.

Also shutdowns and reboots seem to be affected as filesystem is not properly quieted and sometimes files are recovered… and they shouldn’t have been lost in the first place:

F2FS-fs (mmcblk0p2): recover_inode: ino = 8e56, name = gencache.tdb
F2FS-fs (mmcblk0p2): recover_inode: ino = 8e57, name = gencache_notrans.tdb
F2FS-fs (mmcblk0p2): recover_data: ino = 8e56, recovered_data = 5 blocks, err = 0
F2FS-fs (mmcblk0p2): recover_data: ino = 8e57, recovered_data = 104 blocks, err = 0
F2FS-fs (mmcblk0p2): recover_data: ino = 8e57, recovered_data = 0 blocks, err = 0
F2FS-fs (mmcblk0p2): recover_data: ino = 8e57, recovered_data = 1 blocks, err = 0

I found some info related to a fix for recursive lock on f2fs xattr operations which could be related (because ACLs are xattr’s?). Unfortunately kernel 3.16 seems pretty far from raspbmc (more if we take into account the fact that this distribution has reached its end of life!).


PS:

Last raspbmc’s October 2014 update which upgrades to kernel 3.12.31 also exhibits the same ACL behaviour.


PS:

I’ve upgraded on March 2015 my RPi to kernel 3.18.9, and as I supposed… now ACLs work flawlessly!

To upgrade the kernel I used Hexxeh github project which uses a bash script to do all the work using github’s github.com/Hexxeh/rpi-update:

$ sudo su –

# apt-get update

# sudo apt-get install -y git curl binutils ca-certificates

# wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update -O /usr/bin/rpi-update && chmod +x /usr/bin/rpi-update

# rpi-update
You appear to be trying to update firmware on an incompatible distribution. To force update, run the following:
sudo -E RPI_UPDATE_UNSUPPORTED=0 rpi-update

# sudo -E RPI_UPDATE_UNSUPPORTED=0 rpi-update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** Performing self-update
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100  8107  100  8107    0     0  16459      0 –:–:– –:–:– –:–:– 22645
*** Relaunching after update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** We’re running for the first time
*** Backing up files (this will take a few minutes)
*** Backing up firmware
*** Backing up modules 3.12.31
*** Downloading specific firmware revision (this will take a few minutes)
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100   168    0   168    0     0    249      0 –:–:– –:–:– –:–:–   357
100 43.5M  100 43.5M    0     0   636k      0  0:01:10  0:01:10 –:–:–  746k
*** Updating firmware
*** Updating kernel modules
*** depmod 3.18.9+
*** depmod 3.18.9-v7+
*** Updating VideoCore libraries
*** Using HardFP libraries
*** Updating SDK
*** Running ldconfig
*** Storing current firmware revision
*** Deleting downloaded files
*** Syncing changes to disk
*** If no errors appeared, your firmware was successfully updated to 704ae38d749579a9fca20da8d7e48ce5a86c6ea1
*** A reboot is needed to activate the new firmware

# reboot

$ uname -a
Linux raspbmc 3.18.9+ #768 PREEMPT Sun Mar 15 18:59:03 GMT 2015 armv6l GNU/Linux

With this kernel it is possible to safely play with extended attributes on F2FS. Install “attr” and mount your filesystem with “user_xattr” option AND “acl”, the latter not to lose your ACLs, because using user_xattr option makes acl option no more the default…

$ sudo apt-get install attr

$ sudo mount -o remount,user_xattr,acl /

$ touch hello

$ setfattr -n user.testing -v “this is the content of an extended attribute” hello

$ getfattr –dump hello
# file: hello
user.testing=”this is the content of an extended attribute”

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s