aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2019-11-29 14:02:32 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2019-11-29 14:02:32 +0000
commitfdc6b10d44c201f6ed52c1f323b2b4ca2eb64662 (patch)
tree80e4edb52cb5e8abe1b3f799e6eda5f292c3f5e6 /sys
parent9698d992306dee298e1f130fcf437a0ce9add73e (diff)
downloadsrc-fdc6b10d44c201f6ed52c1f323b2b4ca2eb64662.tar.gz
src-fdc6b10d44c201f6ed52c1f323b2b4ca2eb64662.zip
Add a VN_OPEN_INVFS flag.
vn_open_cred() assumes that it is called from the top-level of a VFS syscall. Writers must call bwillwrite() before locking any VFS resource to wait for cleanup of dirty buffers. ZFS getextattr() and setextattr() VOPs do call vn_open_cred(), which results in wait for unrelated buffers while owning ZFS vnode lock (and ZFS does not use buffer cache). VN_OPEN_INVFS allows caller to skip bwillwrite. Note that ZFS is still incorrect there, because it starts write on an mp and locks a vnode while holding another vnode lock. Reported by: Willem Jan Withagen <wjw@digiware.nl> Sponsored by: The FreeBSD Foundation MFC after: 1 week
Notes
Notes: svn path=/head/; revision=355211
Diffstat (limited to 'sys')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c5
-rw-r--r--sys/kern/vfs_vnops.c3
-rw-r--r--sys/sys/vnode.h1
3 files changed, 6 insertions, 3 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
index ebcc0ad92e0f..ae37dd1fba12 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
@@ -5490,7 +5490,7 @@ vop_getextattr {
flags = FREAD;
NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname,
xvp, td);
- error = vn_open_cred(&nd, &flags, 0, 0, ap->a_cred, NULL);
+ error = vn_open_cred(&nd, &flags, VN_OPEN_INVFS, 0, ap->a_cred, NULL);
vp = nd.ni_vp;
NDFREE(&nd, NDF_ONLY_PNBUF);
if (error != 0) {
@@ -5627,7 +5627,8 @@ vop_setextattr {
flags = FFLAGS(O_WRONLY | O_CREAT);
NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname,
xvp, td);
- error = vn_open_cred(&nd, &flags, 0600, 0, ap->a_cred, NULL);
+ error = vn_open_cred(&nd, &flags, 0600, VN_OPEN_INVFS, ap->a_cred,
+ NULL);
vp = nd.ni_vp;
NDFREE(&nd, NDF_ONLY_PNBUF);
if (error != 0) {
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index a0c018deb324..c69010dd9995 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -219,7 +219,8 @@ restart:
ndp->ni_cnd.cn_flags |= AUDITVNODE1;
if (vn_open_flags & VN_OPEN_NOCAPCHECK)
ndp->ni_cnd.cn_flags |= NOCAPCHECK;
- bwillwrite();
+ if ((vn_open_flags & VN_OPEN_INVFS) == 0)
+ bwillwrite();
if ((error = namei(ndp)) != 0)
return (error);
if (ndp->ni_vp == NULL) {
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index 8472bc0fb7be..27dbcbc58b18 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -579,6 +579,7 @@ typedef void vop_getpages_iodone_t(void *, vm_page_t *, int, int);
#define VN_OPEN_NOAUDIT 0x00000001
#define VN_OPEN_NOCAPCHECK 0x00000002
#define VN_OPEN_NAMECACHE 0x00000004
+#define VN_OPEN_INVFS 0x00000008
/*
* Public vnode manipulation functions.