Skip to content

Commit

Permalink
FileFsSizeInformation was returning bogus data
Browse files Browse the repository at this point in the history
Plumb it the same as FileFsFullSizeInformation

Signed-off-by: Jorgen Lundman <[email protected]>
  • Loading branch information
lundman committed Dec 14, 2023
1 parent 00d3696 commit 2ac0ef0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions module/os/windows/zfs/zfs_vnops_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,7 @@ query_volume_information(PDEVICE_OBJECT DeviceObject, PIRP Irp,
Status = STATUS_NOT_IMPLEMENTED;
int space;
int error = 0;
uint64_t refdbytes, availbytes, usedobjs, availobjs;

mount_t *zmo = DeviceObject->DeviceExtension;
if (!zmo ||
Expand Down Expand Up @@ -2275,6 +2276,7 @@ query_volume_information(PDEVICE_OBJECT DeviceObject, PIRP Irp,
ASSERT(Irp->IoStatus.Information <=
IrpSp->Parameters.QueryVolume.Length);
break;

case FileFsControlInformation:
dprintf("* %s: FileFsControlInformation NOT IMPLEMENTED\n",
__func__);
Expand All @@ -2296,6 +2298,7 @@ query_volume_information(PDEVICE_OBJECT DeviceObject, PIRP Irp,
dprintf("* %s: FileFsDriverPathInformation NOT IMPLEMENTED\n",
__func__);
break;

case FileFsFullSizeInformation:
dprintf("* %s: FileFsFullSizeInformation\n", __func__);
if (IrpSp->Parameters.QueryVolume.Length <
Expand All @@ -2305,7 +2308,7 @@ query_volume_information(PDEVICE_OBJECT DeviceObject, PIRP Irp,
Status = STATUS_BUFFER_TOO_SMALL;
break;
}
uint64_t refdbytes, availbytes, usedobjs, availobjs;

dmu_objset_space(zfsvfs->z_os,
&refdbytes, &availbytes, &usedobjs, &availobjs);

Expand All @@ -2323,6 +2326,7 @@ query_volume_information(PDEVICE_OBJECT DeviceObject, PIRP Irp,
sizeof (FILE_FS_FULL_SIZE_INFORMATION);
Status = STATUS_SUCCESS;
break;

case FileFsObjectIdInformation:
dprintf("* %s: FileFsObjectIdInformation\n", __func__);
FILE_FS_OBJECTID_INFORMATION* ffoi =
Expand All @@ -2334,6 +2338,7 @@ query_volume_information(PDEVICE_OBJECT DeviceObject, PIRP Irp,
sizeof (FILE_FS_OBJECTID_INFORMATION);
Status = STATUS_OBJECT_NAME_NOT_FOUND; // returned by NTFS
break;

case FileFsVolumeInformation:
dprintf("* %s: FileFsVolumeInformation\n", __func__);
if (IrpSp->Parameters.QueryVolume.Length <
Expand Down Expand Up @@ -2373,6 +2378,7 @@ query_volume_information(PDEVICE_OBJECT DeviceObject, PIRP Irp,
Status = STATUS_SUCCESS;

break;

case FileFsSizeInformation:
dprintf("* %s: FileFsSizeInformation\n", __func__);
if (IrpSp->Parameters.QueryVolume.Length <
Expand All @@ -2383,15 +2389,21 @@ query_volume_information(PDEVICE_OBJECT DeviceObject, PIRP Irp,
break;
}

dmu_objset_space(zfsvfs->z_os,
&refdbytes, &availbytes, &usedobjs, &availobjs);

FILE_FS_SIZE_INFORMATION *ffsi =
Irp->AssociatedIrp.SystemBuffer;
ffsi->TotalAllocationUnits.QuadPart = 1024 * 1024 * 1024;
ffsi->AvailableAllocationUnits.QuadPart = 1024 * 1024 * 1024;
ffsi->TotalAllocationUnits.QuadPart =
(refdbytes + availbytes) / 512ULL;
ffsi->AvailableAllocationUnits.QuadPart =
availbytes / 512ULL;
ffsi->SectorsPerAllocationUnit = 1;
ffsi->BytesPerSector = 512;
Irp->IoStatus.Information = sizeof (FILE_FS_SIZE_INFORMATION);
Status = STATUS_SUCCESS;
break;

case FileFsSectorSizeInformation:
dprintf("* %s: FileFsSectorSizeInformation\n", __func__);
if (IrpSp->Parameters.QueryVolume.Length <
Expand Down

0 comments on commit 2ac0ef0

Please sign in to comment.