Skip to content

Commit

Permalink
FsTeardown should be in CLOSE and zil_commit iocount
Browse files Browse the repository at this point in the history
Following fastfat, we should not FsRtlTeardownPerStreamContexts in
CLEANUP but rather in CLOSE.

zil_commit via zfs_fsync() / FLUSH_BUFFERS calls zget with WITHOUT_VNODE
and such should not release zp in zfs_get_data().

make some fileobjects spinlock tighter, to avoid calling kmem_alloc
in between. Should consider rwlocks, since spinlocks are expensive.
  • Loading branch information
lundman committed Nov 30, 2018
1 parent 5087f6e commit e54d0af
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions ZFSin/spl/module/spl/spl-rwlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ rw_init(krwlock_t *rwlp, char *name, krw_type_t type, /*__unused*/ void *arg)
{
ASSERT(type != RW_DRIVER);

#ifdef DEBUG
VERIFY3U(rwlp->rw_pad, != , 0x012345678);
#endif
ExInitializeResourceLite(&rwlp->rw_lock);
rwlp->rw_owner = NULL;
rwlp->rw_readers = 0;
Expand All @@ -67,7 +70,9 @@ void
rw_destroy(krwlock_t *rwlp)
{
// Confirm it was initialised, and is unlocked, and not already destroyed.
#ifdef DEBUG
VERIFY3U(rwlp->rw_pad, == , 0x012345678);
#endif
VERIFY3U(rwlp->rw_owner, ==, 0);
VERIFY3U(rwlp->rw_readers, ==, 0);

Expand Down
2 changes: 2 additions & 0 deletions ZFSin/spl/module/spl/spl-vnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1159,10 +1159,12 @@ int vnode_fileobject_add(vnode_t *vp, void *fo)
KeReleaseSpinLock(&vp->v_spinlock, OldIrql);
return 0;
}
KeReleaseSpinLock(&vp->v_spinlock, OldIrql);

node = kmem_alloc(sizeof(*node), KM_SLEEP);
node->fileobject = fo;

KeAcquireSpinLock(&vp->v_spinlock, &OldIrql);
if (avl_find(&vp->v_fileobjects, node, &idx) == NULL) {
avl_insert(&vp->v_fileobjects, node, idx);
KeReleaseSpinLock(&vp->v_spinlock, OldIrql);
Expand Down
6 changes: 6 additions & 0 deletions ZFSin/zfs/module/zfs/dnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ dnode_dest(void *arg, void *unused)
{
int i;
dnode_t *dn = arg;
#ifdef _KERNEL
if (!rw_isinit(&dn->dn_struct_rwlock)) {
dprintf("%s: weird dnode/kmem bug\n", __func__);
return;
}
#endif

rw_destroy(&dn->dn_struct_rwlock);
mutex_destroy(&dn->dn_mtx);
Expand Down
2 changes: 2 additions & 0 deletions ZFSin/zfs/module/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1214,9 +1214,11 @@ zfs_get_done(zgd_t *zgd, int error)
* allocate new vnode, we don't (ZGET_FLAG_WITHOUT_VNODE), and it is
* attached after zfs_get_data() is finished (and immediately released).
*/
#ifndef _WIN32
if (ZTOV(zp)) {
VN_RELE_ASYNC(ZTOV(zp), dsl_pool_vnrele_taskq(dmu_objset_pool(os)));
}
#endif
if (error == 0 && zgd->zgd_bp)
zil_lwb_add_block(zgd->zgd_lwb, zgd->zgd_bp);

Expand Down
10 changes: 4 additions & 6 deletions ZFSin/zfs/module/zfs/zfs_vnops_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -3989,9 +3989,10 @@ NTSTATUS flush_buffers(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION
return STATUS_INVALID_PARAMETER;

struct vnode *vp = FileObject->FsContext;
VN_HOLD(vp);
Status = zfs_fsync(vp, 0, NULL, NULL);
VN_RELE(vp);
if (VN_HOLD(vp) == 0) {
Status = zfs_fsync(vp, 0, NULL, NULL);
VN_RELE(vp);
}
return Status;
}

Expand Down Expand Up @@ -4821,9 +4822,6 @@ fsDispatcher(
CcPurgeCacheSection(section, NULL, 0, FALSE);
}

FsRtlTeardownPerStreamContexts(&vp->FileHeader);
FsRtlUninitializeFileLock(&vp->lock);

if (IrpSp->FileObject->SectionObjectPointer != NULL)
CcUninitializeCacheMap(IrpSp->FileObject, NULL, NULL);

Expand Down

0 comments on commit e54d0af

Please sign in to comment.