New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ioctl version of OpenSolaris open(path, O_XATTR, mode)
and openat(fd, name, O_XATTR, mode)
#4437
Comments
You realize that XATTRs and alternate data streams have different semantics, I assume? Streams are files and you can seek on them, read at any location for any amount of data. XATTRs do not offer that semantic. Why O_XATTR, why not O_STREAM? This would be very attractive to Samba users who also use ZFS On Linux, although an alternative stream VFS module for Samba would have to be written, which is not hard. |
@RichardSharpe Solaris-style extended attributes are alternative data streams, which are full fledged files with their own file handles (if open), owner, group, mode, ACLs, etcetera. Things like alternative datastreams of alternative datastreams, For some time, ZoL has been mapping its Solaris-style extended attributes to the Linux's IRIX-style extended attribute interface. There is a ZoL-specific extension enabled by setting the One consequence of this at the moment is that you cannot call As for why I picked the name |
Hmmm, while we are at it, are there IOCTLs to retrieve and set CREATE TIME and also the ATTRIBUTES field? I have specified them locally ... |
@RichardSharpe Not presently. ZFS does not have an internal create time. As for file attributes, I implemented support for setting appendonly, immutable and nodump via the kernel's existing interface and thought about implementing an ioctl for changing the full set of file attributes. However, no one ever asked for it, so I did not bother. |
Hmmm, in zfs_mknode I see:
In any event, I want those features. |
@RichardSharpe My recollection was wrong. Thanks for catching that. It should be possible to make an ioctl for that, although I would opt to fix the code to make the implementation consistent with OpenSolaris: |
Unfortunately, Linux's struct stat does not contain an st_crtime field :-( |
@RichardSharpe By fixing the code, I meant making it report mtime if crtime is not set instead of making it an alias for ctime. Anyway, I think ext4 is in the same boat with regard to crtime. You might want to email Ted T'so to let him know that the 5 year moratorium expired. Please put me on CC. https://moiseevigor.github.io/software/2015/01/30/get-file-creation-time-on-linux-with-ext4/ By the way, we probably should make separate issues for these things. |
@ryao: Correct. I will create a separate issue. With respect to alternate streams and XATTRs, the only use for XATTRs by Samba on a system that has ZFS (where CRTIME and ATTRIBUTES are available) is for storing Security Descriptors (SDs) (AKA ACLs). Since you cannot convert Windows SDs to NFSv4 ACLs without losing functionality, many such users will likely continue using XATTRs only for that. They would be easy to filter out. |
@ryao If we need to fix fsync, just fix it internally. We can just explicitly call zil_commit to the XATTR znode belongs to the file. By the way, switching between xattr=sa and xattr=dir is still not in one transaction, which I think also should be fixed. |
It's almost three years later. During these three years ZoL has gone more or less main stream (imho). As a result, I think many people would be fine using this functionality and simply require use of ZFS. For me, I have a use case for a feature of alternate data streams on linux for building a FUSE fs, where I'd like to put some extra metadata/journalling inside something like ADS. I was already planning to base this on ZFS so ZoL-only functionality would be perfectly fine. I realise my own use case is awfully specific, but there will probably be many more use cases once a feature like this lands. |
I'm thinking about testing the waters and sending an RFC on LKML to see whether there would be any chance for a patch set being accepted for laying the ground for resource forks / alternate streams in the Linux kernel. It's probably not realistic to get a dedicated API set for this in the Linux kernel right from the start. But for the beginning one could use the original minimalistic approach of Solaris by just adding a new However wouldn't it make sense to use a different name for a enum in Linux, as the term "XATTR" is already quite confusingly used for multiple things? IMO an enum named What I am wondering on ZFS side: Did I get it right that ZFS already uses forks for |
It looks like we can implement the functionality offered by
O_XATTR
on OpenSolaris via an ioctl. That would allow us to offer the equivalent toopen(path, O_XATTR, mode)
for opening the extended attribute directory andopenat(fd, name, O_XATTR, mode)
for opening an extended attribute. We would need to implement support for doing these operations on SA-based extended attributes, but that should allow us to get that code merged into illumos.We would need to reimplement the open/openat syscalls, but the symbols that we need to manipulate file descriptors for this are available for our use:
get_unused_fd_flags
fd_install
put_unused_fd
The ioctl would pass a packed struct containing the arguments for
openat()
that looks something like this:The ZPL write functions would need to be modified to check for writes to an extended attribute and call
fsnotify_xattr(dentry)
on the parent.In the case of
open()
,filedes
could be-1
, which should be an illegal file descriptor.With extended attribute support implemented via an
ioctl
, it should be possible to write a compatibility shim that would allowO_XATTR
to work. The open flag values differ between Illumos and Linux, so such a compatibility shim would need to pick a value in the hope that it does not conflict with anything:http://lxr.free-electrons.com/source/include/uapi/asm-generic/fcntl.h#L18
https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/sys/fcntl.h#L57
Once we pick a value, we could make our own fcntl.h header that defines
O_XATTR
and then includes the real fcntl.h header. Then we could use function interposition in userland to intercept calls toopen()
and redirect those usingO_XATTR
to ourioctl()
. jemalloc uses this technique for things that link to it (or that useLD_PRELOAD
) and it is documented at various places:http://jayconrod.com/posts/23/tutorial-function-interposition-in-linux
https://stackoverflow.com/questions/998464/function-interposition-in-linux-without-dlsym
This sort of thing should matter for the NFSv4 driver, so we might want to get their input on it if we do it.
The text was updated successfully, but these errors were encountered: