From 238b41dbef9d24ef61b716ccca690872b0896675 Mon Sep 17 00:00:00 2001 From: Jorgen Lundman Date: Mon, 11 Sep 2023 14:34:25 +0900 Subject: [PATCH] Do not hold parentvp for XATTRs Signed-off-by: Jorgen Lundman --- module/os/windows/spl/spl-vnode.c | 7 ++----- module/os/windows/zfs/zfs_vnops_windows.c | 9 ++++++++- module/os/windows/zfs/zfs_vnops_windows_lib.c | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/module/os/windows/spl/spl-vnode.c b/module/os/windows/spl/spl-vnode.c index b9dd98d8e73d..d031d2efa1cd 100644 --- a/module/os/windows/spl/spl-vnode.c +++ b/module/os/windows/spl/spl-vnode.c @@ -987,6 +987,7 @@ vnode_setparent(vnode_t *vp, vnode_t *newparent) vnode_rele(oldparent); if (!error) VN_RELE(oldparent); + VN_RELE(oldparent); } } @@ -1294,7 +1295,7 @@ vnode_create(mount_t *mp, struct vnode *dvp, void *v_data, int type, int flags, *vpp = vp; vp->v_flags = 0; vp->v_mount = mp; - vp->v_parent = dvp; + vp->v_parent = NULL; vp->v_data = v_data; vp->v_type = type; vp->v_id = atomic_inc_64_nv(&(vnode_vid_counter)); @@ -1312,10 +1313,6 @@ vnode_create(mount_t *mp, struct vnode *dvp, void *v_data, int type, int flags, if (flags & VNODE_MARKROOT) vp->v_flags |= VNODE_MARKROOT; - /* We also get here with xdvp on the file, can be NULL */ - if (dvp != NULL && vnode_isdir(dvp)) - vnode_ref(dvp); - // Initialise the Windows specific data. memset(&vp->SectionObjectPointers, 0, sizeof (vp->SectionObjectPointers)); diff --git a/module/os/windows/zfs/zfs_vnops_windows.c b/module/os/windows/zfs/zfs_vnops_windows.c index bfcbd4c5988e..f024399bbd56 100644 --- a/module/os/windows/zfs/zfs_vnops_windows.c +++ b/module/os/windows/zfs/zfs_vnops_windows.c @@ -1962,8 +1962,15 @@ zfs_znode_getvnode(znode_t *zp, znode_t *dzp, zfsvfs_t *zfsvfs) vnode_create(zfsvfs->z_vfs, parentvp, zp, IFTOVT((mode_t)zp->z_mode), flags, &vp); - if (parentvp != NULL) + /* We also get here with xdvp on the file, can be NULL */ + if (parentvp != NULL) { + + if (vnode_isdir(parentvp) && + !(zp->z_mode & ZFS_XATTR)) + vnode_setparent(vp, parentvp); + VN_RELE(parentvp); + } atomic_inc_64(&vnop_num_vnodes); diff --git a/module/os/windows/zfs/zfs_vnops_windows_lib.c b/module/os/windows/zfs/zfs_vnops_windows_lib.c index 9618d6e441f4..5ebafd2dec5d 100644 --- a/module/os/windows/zfs/zfs_vnops_windows_lib.c +++ b/module/os/windows/zfs/zfs_vnops_windows_lib.c @@ -2836,6 +2836,7 @@ zfs_parent(struct vnode *vp) if (error) return (SET_ERROR(NULL)); + vnode_setparent(vp, ZTOV(dzp)); return (ZTOV(dzp)); }