Move zfs_onexit_fd_hold to platform code

FreeBSD has a very different implementation.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9442
This commit is contained in:
Matthew Macy
2019-10-13 19:19:39 -07:00
committed by Brian Behlendorf
parent c324701332
commit cdbba101f4
3 changed files with 70 additions and 33 deletions
-33
View File
@@ -111,39 +111,6 @@ zfs_onexit_minor_to_state(minor_t minor, zfs_onexit_t **zo)
return (0);
}
/*
* Consumers might need to operate by minor number instead of fd, since
* they might be running in another thread (e.g. txg_sync_thread). Callers
* of this function must call zfs_onexit_fd_rele() when they're finished
* using the minor number.
*/
int
zfs_onexit_fd_hold(int fd, minor_t *minorp)
{
file_t *fp;
zfs_onexit_t *zo;
int error;
fp = getf(fd);
if (fp == NULL)
return (SET_ERROR(EBADF));
error = zfsdev_getminor(fp->f_file, minorp);
if (error == 0)
error = zfs_onexit_minor_to_state(*minorp, &zo);
if (error)
zfs_onexit_fd_rele(fd);
return (error);
}
void
zfs_onexit_fd_rele(int fd)
{
releasef(fd);
}
/*
* Add a callback to be invoked when the calling process exits.
*/