Problems with xattr / v2.1.6 Monterey (Intel)

All your general support questions for OpenZFS on OS X.

Problems with xattr / v2.1.6 Monterey (Intel)

Postby o3x_prokyon » Sun Dec 11, 2022 6:23 am

I found some issues with xattr, OpenZFS on OS X v2.1.6, macOS Monterey 12.6.1, Intel:

1. It's not possible to set or change directory icons. The following image is taken from my local apfs volume. On the external ZFS pool only the blue standard directory icon is shown.

Icon_Directory.png
Set/change directory icon
Icon_Directory.png (77.91 KiB) Viewed 297242 times


2. It's not possible to lock directories (image from local apfs volume):

Lock_Directory.png
Lock directory
Lock_Directory.png (71.57 KiB) Viewed 297242 times


3. rsync to my ZFS pool (encrypted dataset) complains about xattr:

My settings (zfs get ...) are:
aclmode=discard
aclinherit=restricted
xattr=sa
utf8only=on
normalization=formD
acltype=ntfsv4
encryption=aes-128-gcm
com.apple.mimic=apfs (no differnce if set to hfs)

There's a new tunable „kstat.zfs.darwin.tunable.zfs.xattr_compat“. By default this is set to „0“ (zero) which results in a lot of messages from rsync like this one:

rsync: [generator] get_xattr_data:
lgetxattr("/Volumes/R1_Backup-Z/R1_Safe-Z/Users/[…]/2010-12-24_18-38-09.NEF.cop","com.apple.system.Security",0)
failed: Operation not permitted (1)

None of these files are locked and they belong to the same user/group who invoked rsync. The same rsync to an apfs volume is running fine without errors.

If I set „kstat.zfs.darwin.tunable.zfs.xattr_compat=1“ the rsync message changes as follows:

rsync: [receiver] rsync_xal_set:
lremovexattr("/Volumes/R1_Backup-Z/R1_Safe-Z/Users/[…]/2022_04_28__10_43_39.NEF","macos:co.eclecticlight.dintch.hash#S")
failed: Attribute not found (93)

Even if rsync states an error, the xattr seems to be correct on the ZFS pool destination. Maybe it tries to remove that xattr („lremovexattr“) on the ZFS pool, but fails. The result is the expected behaviour: the xattr is synced too. But then this error message is a little confusing...

[By the way... the app „Dintch“ from eclecticlight calculates a hash value of a file and saves it as an extended attribute. With this hash value one can detect bit rot and other file changes on apfs or hfs file systems. Not so comfortable like ZFS... ;-) but better than nothing.]

The rsync error is not only restricted to those hash values:
rsync: [receiver] rsync_xal_set:
lremovexattr("/Volumes/R1_Backup-Z/R1_Safe-Z/Users/[…]/2018_08_22__10_17_35.NEF.cos","macos:com.apple.TextEncoding")
failed: Attribute not found (93)

Does anybody know what I am doing wrong? Or are those issues related to the new xattr handling of OpenZFS 2.1.6?
o3x_prokyon
 
Posts: 33
Joined: Thu Dec 01, 2022 1:17 pm

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby lundman » Mon Dec 12, 2022 12:30 am

Sorry for the terse reply, yes there is new xattr code in 2.1.6, but I think you can disable that and go back to the legacy style; by
setting "zfs_xattr_compat" to 0 (zero).

sysctl -a | grep zfs_xattr_compat

sysctl thefullname.zfs_xattr_compat=0

could you check if it works more like expected if you change that?
User avatar
lundman
 
Posts: 1335
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby 0xdeadbeef » Mon Dec 12, 2022 8:10 am

Hi,

@Lundman wrote:
Sorry for the terse reply, yes there is new xattr code in 2.1.6, but I think you can disable that and go back to the legacy style; by
setting "zfs_xattr_compat" to 0 (zero).

sysctl -a | grep zfs_xattr_compat

sysctl thefullname.zfs_xattr_compat=0

could you check if it works more like expected if you change that?


Is "=0" a typo? On 2.1.6 on Intel and Arm it seems 0 is the default.
0xdeadbeef
 
Posts: 8
Joined: Tue Feb 23, 2016 11:23 pm

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby o3x_prokyon » Mon Dec 12, 2022 9:53 am

Hi,

tunable.zfs.xattr_compat=0 is the default and with that default it's not possible to set directory icons or lock directories and rsync (v3.2.7) complains:
rsync: [generator] get_xattr_data: lgetxattr("…") failed: Operation not permitted (1)

If I switch to xattr_compat=1 setting directory icons and locking directories is still not possible, rsync now complains:
rsync: [receiver] rsync_xal_set: lremovexattr("…") failed: Attribute not found (93)

Is there any documentation about the new way extended attributes are handled and what the tunable xattr_compat exactly does?

By the way: maybe it's a typo but on my Mac the tunable is "zfs(dot)xattr_compat" and not "zfs(underscore)xattr_compat"... or is this actually the problem???
o3x_prokyon
 
Posts: 33
Joined: Thu Dec 01, 2022 1:17 pm

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby lundman » Thu Dec 15, 2022 2:02 am

Sorry, I was on the road when I replied so I didn't have time to check I said the correct things :)

I believe with xattr_compat on it adds "macos_" in front of xattrs, like "macos_myxattr", I think so that
you can import pool on another system and have separate namespaces.

XNU doesn't like macos_com.apple.xattr though, so I am not sure how that is supposed to work for us.
User avatar
lundman
 
Posts: 1335
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby o3x_prokyon » Sat Dec 17, 2022 5:47 am

Ok, so keeping all xattrs in sync and identical to those of the files on my internal disk, it should be better to set xattr_compat=0. I don't use any other operating system with my zfs-pool so this shouldn't be a problem.

Nevertheless, locking directories and changing directory icons isn't working either way with xattr_compat, so there must be another change concerning file flags....
o3x_prokyon
 
Posts: 33
Joined: Thu Dec 01, 2022 1:17 pm

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby lundman » Sat Dec 17, 2022 4:33 pm

Lets pick one of those to look at, say, "locking directories" - do you know what it does under the hood? Or what commands is used to locking?
User avatar
lundman
 
Posts: 1335
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby Haravikk » Sun Dec 18, 2022 4:34 am

Just wanted to note that this issue also exists on v2.1.0, it's not new to v2.1.6; seems to be the same general xattr problem that affects a whole bunch of apps such as Xcode.app, Photos.app etc. so the xattr_compact tunable may be a red-herring in this case (it doesn't exist on v2.1.0).
Haravikk
 
Posts: 75
Joined: Tue Mar 17, 2015 4:52 am

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby o3x_prokyon » Thu Dec 22, 2022 9:11 am

Sorry for the delay...

Locking directories is realized via file flags, so no xattr(??). It's the user immutable flag:
set flag:
Code: Select all
chflags uchg directory

clear flag:
Code: Select all
chflags nouchg directory


Other popular flags are:
schg: system immutable flag
hidden: a macOS way for hiding files or directories next to the unix dot-files
arch: archived
and some more. See
Code: Select all
man chflags

for all flags.

To see which files or directories have file flags, one can use
Code: Select all
ls -lO
(capital O, not zero!)

Extended attributes are listed with:
Code: Select all
ls -l@


File flags and xattr together:
Code: Select all
ls -lO@


Setting a directory icon seems to be realized via a combination of xattr and file flags. The xattr is
Code: Select all
com.apple.FinderInfo

It has a size of 32 bytes and with
Code: Select all
xattr -lx directory

the content is shown as a hex dump:

Code: Select all
com.apple.FinderInfo:
00000000  00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00  |................|
00000010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000020


Inside the directory is a file called
Code: Select all
.Icon?
with the "hidden" flag set (dot-file plus macOS flag!).

Maybe this helps....?
o3x_prokyon
 
Posts: 33
Joined: Thu Dec 01, 2022 1:17 pm

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby lundman » Mon Dec 26, 2022 4:06 pm

OK so you are having issues with flags? If it's immutable are we supposed to be able to change other flags? How does zfs operate compared to hfs?
User avatar
lundman
 
Posts: 1335
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Next

Return to General Help

Who is online

Users browsing this forum: No registered users and 24 guests

cron