zfsonlinux/zfs — pull request #2809 by dweeezil (2014-10-19 05:14:08+00:00)
Title: Store common Linux xattrs as native SA with xattr=sa

There are 2 commits here. The first, dweeezil/zfs@c53847e, fixes deletion of system attributes.

The second is a intended to be the foundation for fixing #2718 but it should otherwise be able to stand on its own.

I've given this patch stack fairly light manual testing as well as running the "pjd" posixacl test suite and some short ztest runs.

I'm submitting this now as a functional WIP to get feedback from other developers regarding the overall concept and its implementation. There are a handful of issues I'll point out about the code:
- The list of xattrs to store as native SAs is stored statically in ```zpl_xattr.c``` which made it difficult to share with ```zdb```. The same list (in a different format) exists within ```zdb.c``` as part of the new ```dump_znode_native_sa_xattr()``` function.
- The management of existing ZPL_DXATTR SAs required a helper function to translate from a ```zpl_attr_t``` to its name. As far as I could tell, there were no existing "upcalls" from the ZoL ZPL to the native Solaris ZPL. Rather than trying to ```#include``` the ZPL definitions in ```zfs_sa.c```, I simply added an appropriate ```extern``` declaration. This goes against the current coding style.
- The ZPL_DXATTR SA cleanup performed by ```zfs_sa_remove_xattr``` adds overhead which could be avoided if it was known that no ZPL_DXATTRs exist. To that end, it's only invoked after determining whether a ZPL_DXATTR exists (which should be a low-overhead operation).
- I'd like to add a feature flag which is activated when a Native SA xattr is set for the first time; the feature flag would not be able to be deactivated. We might also want a feature flag to do the same with the existing ZPL_DXATTR SAs.

I'd also like feedback on the first commit in this stack. I discovered the problem during testing. My concern is that all other OpenZFS implementations likely share the identical code. I think the problem isn't seen often because SAs are rarely deleted. My test system created sort of a "perfect storm" by "stacking" all the variably-sized SAs at the ends of the registration.