kdave / btrfs-progs

Development of userspace BTRFS tools
GNU General Public License v2.0
562 stars 245 forks source link

Questions about extended file attributes (xattrs) #917

Open pjotrek-b opened 2 weeks ago

pjotrek-b commented 2 weeks ago

Hello everyone :smile:

It's about btrfs-documentation: I'd like to ask about technical details on extended attributes (xattrs) on btrfs, and found these pages:

Which both don't really list or mention extended file attributes handling (xattrs). I know btrfs can do xattrs, and ArchWiki mentions possible size-constraints, but I'm interested in the specific limits and settings for xattrs on btrfs :smile:

I'm moving this as issue as question here, following advice from @kdave in https://github.com/btrfs/linux/issues/1455

If anyone wants to talk about this or point me towards some code/docs, I'd be very grateful! :cake:

adam900710 commented 2 weeks ago

XATTRS is stored with key (<inode number> XATTR_ITEM 0), its related data is btrfs_file_extent_item but only in the inline extent mode.

And xattrs are stored as inline data extents, meaning it's limited by two things:

pjotrek-b commented 2 weeks ago

@adam900710 : This is great information, thank you!

Do I understand this correctly:

1) 4k sector size: Every xattr byte (all keys + all values) must stay below 4k? "Soft limit" means: Theoretically adjustable - but not really tested or really laid out for?

2) "16kiB as node size" I don't yet fully understand this. Do you mean: Internally btrfs could handle up-to-16kiB xattrs - if the sector size would be that big?

So if I'd like to use xattrs like BeFS or HFS/APFS where even binary-data (eg images) are stored: would btrfs' defaults be capped to 4k in total right now?

Thank you so much! :smile: