Skip to content

Commit

Permalink
We need to call FsRtlEnterFileSystem() from fastio
Browse files Browse the repository at this point in the history
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
  • Loading branch information
lundman committed Jun 26, 2024
1 parent a449e26 commit f67433c
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions module/os/windows/zfs/zfs_vnops_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -6636,12 +6636,6 @@ _Function_class_(DRIVER_DISPATCH)
dprintf("Unknown IRP_MJ_PNP(ioctl): 0x%x\n", IrpSp->MinorFunction);
break;
}
if (DeviceObject->NextDevice != NULL) {
dprintf("Calling down\n");
IoSkipCurrentIrpStackLocation(Irp);
Status = IoCallDriver(DeviceObject->NextDevice, Irp);
return (STATUS_PENDING); // So we dont IoComplete this Irp
}
break;

}
Expand Down Expand Up @@ -6892,12 +6886,6 @@ _Function_class_(DRIVER_DISPATCH)
dprintf("Unknown IRP_MJ_PNP(disk): 0x%x\n", IrpSp->MinorFunction);
break;
}
if (DeviceObject->NextDevice != NULL) {
dprintf("Calling down2\n");
IoSkipCurrentIrpStackLocation(Irp);
Status = IoCallDriver(DeviceObject->NextDevice, Irp);
return (STATUS_PENDING); // So we dont IoComplete this Irp
}
break;

}
Expand Down Expand Up @@ -7293,12 +7281,6 @@ _Function_class_(DRIVER_DISPATCH)
dprintf("Unknown IRP_MJ_PNP(fs): 0x%x\n", IrpSp->MinorFunction);
break;
}
if (DeviceObject->NextDevice != NULL) {
dprintf("Calling down3\n");
IoSkipCurrentIrpStackLocation(Irp);
Status = IoCallDriver(DeviceObject->NextDevice, Irp);
return (STATUS_PENDING); // So we dont IoComplete this Irp
}
break;
case IRP_MJ_QUERY_VOLUME_INFORMATION:
Status = query_volume_information(DeviceObject, Irp, IrpSp);
Expand Down Expand Up @@ -8008,10 +7990,11 @@ fastio_acquire_file_for_ntsection(
if (!vp || VN_HOLD(vp) != 0)
return;

FsRtlEnterFileSystem();
ExAcquireResourceExclusiveLite(vp->FileHeader.Resource, TRUE);
vnode_ref(vp);
VN_RELE(vp);

FsRtlExitFileSystem();
}

static void
Expand All @@ -8030,9 +8013,11 @@ fastio_release_file_for_ntsection(
if (!vp || VN_HOLD(vp) != 0)
return;

FsRtlEnterFileSystem();
ExReleaseResourceLite(vp->FileHeader.Resource);
vnode_rele(vp);
VN_RELE(vp);
FsRtlExitFileSystem();
}

static BOOLEAN
Expand Down Expand Up @@ -8102,12 +8087,17 @@ fastio_acquire_for_mod_write(PFILE_OBJECT FileObject,
return (STATUS_INVALID_PARAMETER);
}

if (vfs_busy(zfsvfs->z_vfs, 0) != 0)
FsRtlEnterFileSystem();

if (vfs_busy(zfsvfs->z_vfs, 0) != 0) {
FsRtlExitFileSystem();
return (STATUS_INVALID_PARAMETER);
}

if (zfsvfs->z_unmounted ||
zfs_enter(zfsvfs, FTAG) != 0) {
vfs_unbusy(zfsvfs->z_vfs);
FsRtlExitFileSystem();
return (STATUS_INVALID_PARAMETER);
}

Expand All @@ -8119,6 +8109,7 @@ fastio_acquire_for_mod_write(PFILE_OBJECT FileObject,
VTOZ(vp) == NULL ||
VN_HOLD(vp) != 0) {
zfs_exit(zfsvfs, FTAG);
FsRtlExitFileSystem();
return (STATUS_INVALID_PARAMETER);
}
zfs_exit(zfsvfs, FTAG);
Expand All @@ -8141,6 +8132,7 @@ fastio_acquire_for_mod_write(PFILE_OBJECT FileObject,
// No zfs_exit(zfsvfs, FTAG) until below

dprintf("%s: returning STATUS_SUCCESS\n", __func__);
FsRtlExitFileSystem();

return (Status);
}
Expand All @@ -8155,6 +8147,8 @@ fastio_release_for_mod_write(PFILE_OBJECT FileObject,

dprintf("%s:\n", __func__);

FsRtlEnterFileSystem();

ExReleaseResourceLite(ResourceToRelease);

vp = FileObject->FsContext;
Expand All @@ -8164,10 +8158,12 @@ fastio_release_for_mod_write(PFILE_OBJECT FileObject,
vnode_rele(vp);
VN_RELE(vp);

FsRtlExitFileSystem();
return (STATUS_SUCCESS);
}

dprintf("%s WARNING FAILED\n", __func__);
FsRtlExitFileSystem();
return (STATUS_SUCCESS);
}

Expand Down Expand Up @@ -8242,6 +8238,9 @@ fastio_query_open(PIRP Irp,
if (IrpSp->FileObject->FsContext == NULL)
return (FALSE);
#endif

FsRtlEnterFileSystem();

if (IrpSp->FileObject->FileName.Buffer != NULL &&
IrpSp->FileObject->FileName.Length > 0) {

Expand All @@ -8258,6 +8257,7 @@ fastio_query_open(PIRP Irp,
"input len %d\n",
error, IrpSp->FileObject->FileName.Length);
kmem_free(filename, PATH_MAX);
FsRtlExitFileSystem();
Irp->IoStatus.Status = STATUS_OBJECT_NAME_INVALID;
Irp->IoStatus.Information = 0;
return (FALSE);
Expand Down Expand Up @@ -8289,6 +8289,7 @@ fastio_query_open(PIRP Irp,
if (vp)
VN_RELE(vp);

FsRtlExitFileSystem();
return (TRUE);
}

Expand All @@ -8297,6 +8298,8 @@ fastio_query_open(PIRP Irp,

}

FsRtlExitFileSystem();

/* Probably can skip setting these, we return FALSE */
Irp->IoStatus.Status = error;
// if (error == STATUS_REPARSE)
Expand Down

0 comments on commit f67433c

Please sign in to comment.