aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2021-02-03 11:02:18 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2021-02-12 01:02:20 +0000
commitee965dfa64929227ced8adb68900c35f877480e7 (patch)
tree63364c8c96184277cc78155aca188f45c51c7856
parent08c2dc2841214187a162d5e4475aa1b94d03fd77 (diff)
downloadsrc-ee965dfa64929227ced8adb68900c35f877480e7.tar.gz
src-ee965dfa64929227ced8adb68900c35f877480e7.zip
vn_open(): If the vnode is reclaimed during open(2), do not return error.
Most future operations on the returned file descriptor will fail anyway, and application should be ready to handle that failures. Not forcing it to understand the transient failure mode on open, which is implementation-specific, should make us less special without loss of reporting of errors. Suggested by: chs Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
-rw-r--r--sys/fs/deadfs/dead_vnops.c11
-rw-r--r--sys/kern/vfs_vnops.c2
2 files changed, 9 insertions, 4 deletions
diff --git a/sys/fs/deadfs/dead_vnops.c b/sys/fs/deadfs/dead_vnops.c
index 09c3c996ee0e..324bbafd7caf 100644
--- a/sys/fs/deadfs/dead_vnops.c
+++ b/sys/fs/deadfs/dead_vnops.c
@@ -45,6 +45,7 @@
*/
static vop_lookup_t dead_lookup;
static vop_open_t dead_open;
+static vop_close_t dead_close;
static vop_getwritemount_t dead_getwritemount;
static vop_rename_t dead_rename;
static vop_unset_text_t dead_unset_text;
@@ -55,6 +56,7 @@ struct vop_vector dead_vnodeops = {
.vop_access = VOP_EBADF,
.vop_advlock = VOP_EBADF,
.vop_bmap = VOP_EBADF,
+ .vop_close = dead_close,
.vop_create = VOP_PANIC,
.vop_getattr = VOP_EBADF,
.vop_getwritemount = dead_getwritemount,
@@ -104,13 +106,18 @@ dead_lookup(struct vop_lookup_args *ap)
}
/*
- * Open always fails as if device did not exist.
+ * Silently succeed open and close.
*/
static int
dead_open(struct vop_open_args *ap)
{
+ return (0);
+}
- return (ENXIO);
+static int
+dead_close(struct vop_close_args *ap)
+{
+ return (0);
}
int
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 6c6727c7f372..f70bcdab4208 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -356,8 +356,6 @@ vn_open_vnode_advlock(struct vnode *vp, int fmode, struct file *fp)
fp->f_flag |= FHASLOCK;
vn_lock(vp, lock_flags | LK_RETRY);
- if (error == 0 && VN_IS_DOOMED(vp))
- error = ENOENT;
return (error);
}