HomeFreeBSD

zfs_onexit_fd_hold: return EBADF even if devfs_get_cdevpriv gave ENOENT

Description

zfs_onexit_fd_hold: return EBADF even if devfs_get_cdevpriv gave ENOENT

/dev/zfs always has per-open data, so when it is missing the file
descriptor is for some other file. Returning ENOENT in this case
is confusing as a variety of other conditions (like a missing dataset)
may result in the same error. It's better to consistently return
EBADF for any problems with the file descriptor.

Note that zfs_onexit_fd_hold() is used with 'automatic cleanup fd'

  • when that fd is closed, typically because a process is terminated,

some cleanup action is taken by ZFS driver. E.g. a temporary
snapshot hold is released.

Perhaps, it would even be worthwhile changing devfs_get_cdevpriv()
to return EBADF if there is no associated data.

Differential Revision: https://reviews.freebsd.org/D2370
Reviewed by: delphij, smh
MFC after: 12 days

Details

Provenance
avgAuthored on
Reviewer
delphij
Differential Revision
D2370: zfs_onexit_fd_hold: return EBADF even if devfs_get_cdevpriv gave ENOENT
Parents
rS282129: Update Amlogic MMC driver:
Branches
Unknown
Tags
Unknown