Page MenuHomeFreeBSD

zfs_onexit_fd_hold: return EBADF even if devfs_get_cdevpriv gave ENOENT
ClosedPublic

Authored by avg on Apr 25 2015, 5:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 11:16 PM
Unknown Object (File)
Fri, Dec 20, 7:13 PM
Unknown Object (File)
Fri, Dec 20, 1:38 PM
Unknown Object (File)
Sat, Dec 7, 11:56 PM
Unknown Object (File)
Nov 23 2024, 7:10 PM
Unknown Object (File)
Nov 23 2024, 2:13 AM
Unknown Object (File)
Nov 22 2024, 10:47 AM
Unknown Object (File)
Nov 17 2024, 4:57 PM
Subscribers

Details

Summary

/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.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

avg retitled this revision from to zfs_onexit_fd_hold: return EBADF even if devfs_get_cdevpriv gave ENOENT.
avg updated this object.
avg edited the test plan for this revision. (Show Details)
avg added reviewers: smh, delphij, kib.
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_onexit.c
140 ↗(On Diff #5003)

Perhaps SET_ERROR(EBADF) instead?

smh requested changes to this revision.Apr 27 2015, 11:15 PM
smh edited edge metadata.

As mentioned by delphij we should make use of SET_ERROR for all new errors to help aid dtrace investigation of issues.

This revision now requires changes to proceed.Apr 27 2015, 11:15 PM
avg edited edge metadata.

use SET_ERROR()

delphij edited edge metadata.
This revision was automatically updated to reflect the committed changes.