FreeBSD Bugzilla – Attachment 228815 Details for
Bug 258208
[zfs] locks up when using rollback or destroy on both 13.0-RELEASE & sysutils/openzfs port
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
second attempt
zfs.diff (text/plain), 5.64 KB, created by
Mark Johnston
on 2021-10-19 01:00:17 UTC
(
hide
)
Description:
second attempt
Filename:
MIME Type:
Creator:
Mark Johnston
Created:
2021-10-19 01:00:17 UTC
Size:
5.64 KB
patch
obsolete
>commit 9ab0b3c874ef802b7636b9fa06b755e2db6949fb >Author: Mark Johnston <markj@FreeBSD.org> >Date: Mon Oct 18 17:13:44 2021 -0400 > > wip > >diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h >index ccbbf4f73224..c48711ba0be8 100644 >--- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h >+++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h >@@ -140,7 +140,7 @@ struct zfsvfs { > #define ZFS_TEARDOWN_ENTER_WRITE(zfsvfs, tag) \ > rms_wlock(&(zfsvfs)->z_teardown_lock) > >-#define ZFS_TEARDOWN_EXIT_WRITE(zfsvfs) \ >+#define ZFS_TEARDOWN_EXIT_WRITE(zfsvfs, tag) \ > rms_wunlock(&(zfsvfs)->z_teardown_lock) > > #define ZFS_TEARDOWN_EXIT(zfsvfs, tag) \ >@@ -173,7 +173,7 @@ struct zfsvfs { > #define ZFS_TEARDOWN_ENTER_WRITE(zfsvfs, tag) \ > rrm_enter(&(zfsvfs)->z_teardown_lock, RW_WRITER, tag) > >-#define ZFS_TEARDOWN_EXIT_WRITE(zfsvfs) \ >+#define ZFS_TEARDOWN_EXIT_WRITE(zfsvfs, tag) \ > rrm_exit(&(zfsvfs)->z_teardown_lock, tag) > > #define ZFS_TEARDOWN_EXIT(zfsvfs, tag) \ >diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c >index 42e11eeb183d..892c99be7ccf 100644 >--- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c >+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c >@@ -1405,7 +1405,7 @@ zfs_mount(vfs_t *vfsp) > ZFS_TEARDOWN_ENTER_WRITE(zfsvfs, FTAG); > zfs_unregister_callbacks(zfsvfs); > error = zfs_register_callbacks(vfsp); >- ZFS_TEARDOWN_EXIT(zfsvfs, FTAG); >+ ZFS_TEARDOWN_EXIT_WRITE(zfsvfs, FTAG); > goto out; > } > >@@ -1587,7 +1587,7 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting) > */ > if (!unmounting && (zfsvfs->z_unmounted || zfsvfs->z_os == NULL)) { > ZFS_TEARDOWN_INACTIVE_EXIT_WRITE(zfsvfs); >- ZFS_TEARDOWN_EXIT(zfsvfs, FTAG); >+ ZFS_TEARDOWN_EXIT_WRITE(zfsvfs, FTAG); > return (SET_ERROR(EIO)); > } > >@@ -1615,7 +1615,7 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting) > if (unmounting) { > zfsvfs->z_unmounted = B_TRUE; > ZFS_TEARDOWN_INACTIVE_EXIT_WRITE(zfsvfs); >- ZFS_TEARDOWN_EXIT(zfsvfs, FTAG); >+ ZFS_TEARDOWN_EXIT_WRITE(zfsvfs, FTAG); > } > > /* >@@ -1677,7 +1677,7 @@ zfs_umount(vfs_t *vfsp, int fflag) > */ > ZFS_TEARDOWN_ENTER_WRITE(zfsvfs, FTAG); > zfsvfs->z_unmounted = B_TRUE; >- ZFS_TEARDOWN_EXIT(zfsvfs, FTAG); >+ ZFS_TEARDOWN_EXIT_WRITE(zfsvfs, FTAG); > } > > /* >@@ -1976,7 +1976,7 @@ zfs_resume_fs(zfsvfs_t *zfsvfs, dsl_dataset_t *ds) > bail: > /* release the VOPs */ > ZFS_TEARDOWN_INACTIVE_EXIT_WRITE(zfsvfs); >- ZFS_TEARDOWN_EXIT(zfsvfs, FTAG); >+ ZFS_TEARDOWN_EXIT_WRITE(zfsvfs, FTAG); > > if (err) { > /* >@@ -2109,7 +2109,7 @@ zfs_end_fs(zfsvfs_t *zfsvfs, dsl_dataset_t *ds) > > /* release the VOPs */ > ZFS_TEARDOWN_INACTIVE_EXIT_WRITE(zfsvfs); >- ZFS_TEARDOWN_EXIT(zfsvfs, FTAG); >+ ZFS_TEARDOWN_EXIT_WRITE(zfsvfs, FTAG); > > /* > * Try to force unmount this file system. >diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c >index c0d68ea0532f..8fe8065084ed 100644 >--- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c >+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c >@@ -5174,6 +5174,8 @@ zfs_freebsd_reclaim(struct vop_reclaim_args *ap) > else > zfs_zinactive(zp); > ZFS_TEARDOWN_INACTIVE_EXIT_READ(zfsvfs); >+ /* XXXMJ */ >+ ZFS_EXIT(zfsvfs); > > vp->v_data = NULL; > return (0); >@@ -6110,6 +6112,84 @@ zfs_deallocate(struct vop_deallocate_args *ap) > } > #endif > >+static int >+zfs_freebsd_lock(struct vop_lock1_args *ap) >+{ >+ zfsvfs_t *zfsvfs; >+ struct vnode *vp; >+ int error, flags, type; >+ >+ vp = ap->a_vp; >+ flags = ap->a_flags & LK_EATTR_MASK; >+ type = ap->a_flags & LK_TYPE_MASK; >+ zfsvfs = VTOZ(vp)->z_zfsvfs; >+ >+ KASSERT(type != LK_RELEASE && type != LK_DRAIN && type != LK_EXCLOTHER, >+ ("%s: invalid operation type %#x", __func__, type)); >+ >+ if (type == LK_UPGRADE) >+ ZFS_TEARDOWN_EXIT_READ(zfsvfs, NULL); >+ >+ error = vop_lock(ap); >+ if (error != 0) >+ return (error); >+ >+ if (!ZFS_TEARDOWN_WRITE_HELD(zfsvfs)) { >+ switch (type) { >+ case LK_DOWNGRADE: >+ break; >+ case LK_EXCLUSIVE: >+ case LK_SHARED: >+ case LK_UPGRADE: >+ if ((flags & LK_NOWAIT) == 0) { >+ ZFS_TEARDOWN_ENTER_READ(zfsvfs, NULL); >+ break; >+ } >+ /* FALLTHROUGH */ >+ case LK_TRYUPGRADE: >+ if (!ZFS_TEARDOWN_TRY_ENTER_READ(zfsvfs)) { >+ /* XXXMJ coupled to vop_unlock impl */ >+ /* XXXMJ do we need to reacquire interlock? */ >+ lockmgr_unlock(&vp->v_lock); >+ return (EBUSY); >+ } >+ break; >+ } >+ } >+ >+ return (0); >+} >+ >+/* XXXMJ can't release teardown lock before vnode lock */ >+static int >+zfs_freebsd_unlock(struct vop_unlock_args *ap) >+{ >+ zfsvfs_t *zfsvfs; >+ struct vnode *vp; >+ int error; >+ >+ vp = ap->a_vp; >+ zfsvfs = VTOZ(ap->a_vp)->z_zfsvfs; >+ error = vop_unlock(ap); >+ if (!ZFS_TEARDOWN_WRITE_HELD(zfsvfs)) >+ ZFS_TEARDOWN_EXIT_READ(zfsvfs, NULL); >+ return (error); >+} >+ >+static int >+zfs_freebsd_islocked(struct vop_islocked_args *ap) >+{ >+ struct vnode *vp; >+ int status; >+ >+ vp = ap->a_vp; >+ status = vop_islocked(ap); >+ if (status != 0) >+ VNASSERT(ZFS_TEARDOWN_HELD(VTOZ(vp)->z_zfsvfs), vp, >+ ("teardown lock not held")); >+ return (status); >+} >+ > struct vop_vector zfs_vnodeops; > struct vop_vector zfs_fifoops; > struct vop_vector zfs_shareops; >@@ -6166,9 +6246,9 @@ struct vop_vector zfs_vnodeops = { > .vop_putpages = zfs_freebsd_putpages, > .vop_vptocnp = zfs_vptocnp, > #if __FreeBSD_version >= 1300064 >- .vop_lock1 = vop_lock, >- .vop_unlock = vop_unlock, >- .vop_islocked = vop_islocked, >+ .vop_lock1 = zfs_freebsd_lock, >+ .vop_unlock = zfs_freebsd_unlock, >+ .vop_islocked = zfs_freebsd_islocked, > #endif > }; > VFS_VOP_VECTOR_REGISTER(zfs_vnodeops);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 258208
:
227959
|
228714
|
228715
|
228813
| 228815