cloudbase / wnbd

Windows Ceph RBD NBD driver
GNU Lesser General Public License v2.1
58 stars 26 forks source link

Does rbd-wnbd device support trim? #137

Closed luckyho closed 3 months ago

luckyho commented 3 months ago

Does rbd-wnbd device support fstrim? How to check it in the win client?

luckyho commented 3 months ago

The win system already supports the trim function, but I'm not sure if it works with rbd-wnbd? image

petrutlucian94 commented 3 months ago

DisableDeleteNotify = 0 means that Windows is configured to use TRIM, if supported by the disk.

WNBD offers partial TRIM support. One easy way of checking is by using sg3_utils. Note that the most recent sg3_utils releases seem to be broken on Windows, but 1.44 works fine.

PS E:\tools\sg3_utils_144\sg3ut_mgw64\bin> .\sg_vpd.exe --page=0xb2 \\.\physicaldrive3
Logical block provisioning VPD page (SBC):
  Unmap command supported (LBPU): 1
  Write same (16) with unmap bit supported (LBPWS): 0
  Write same (10) with unmap bit supported (LBPWS10): 0
  Logical block provisioning read zeros (LBPRZ): 0
  Anchored LBAs supported (ANC_SUP): 0
  Threshold exponent: 0 [threshold sets not supported]
  Descriptor present (DP): 0
  Minimum percentage: 0 [not reported]
  Provisioning type: 2 (thin provisioned)
  Threshold percentage: 0 [percentages not supported]
petrutlucian94 commented 3 months ago

You can even check individual SCSI requests by increasing the WNBD log level:

rbd-wnbd map -f test_1g --wnbd-log-level=10

2024-06-26T09:34:16.139+0000 25  0 libwnbd.dll!WnbdHandleRequest DEBUG Dispatching UNMAP # b0.
2024-06-26T09:34:16.139+0000 1d  0 libwnbd.dll!WnbdSendResponseEx DEBUG Sending response: [UNMAP] : (SS:0, SK:0, ASC:0, I:0) # b0 @ 0000000000000000~0x0.

Windows will use UNMAP/TRIM when quick formatting or when using the following command to unmap deleted blocks.

Optimize-Volume -DriveLetter f -ReTrim
petrutlucian94 commented 3 months ago

For what is worth, wnbd-client also reports if UNMAP support is enabled.

 wnbd-client show rbd/test_1g

Connection info
InstanceName              : rbd/test_1g
SerialNumber              : rbd/test_1g
Owner                     : ceph-rbd-wnbd
ReadOnly                  : 0
FlushSupported            : 0
FUASupported              : 0
UnmapSupported            : 1
UnmapAnchorSupported      : 0
UseUserspaceNbd           : 0
BlockCount                : 2097152
BlockSize                 : 512
MaxUnmapDescCount         : 1
Pid                       : 2068
DiskNumber                : 3
PNPDeviceID               : SCSI\Disk&Ven_WNBD&Prod_WNBD_DISK\1&2afd7d61&60&000000
BusNumber                 : 0
TargetId                  : 0
Lun                       : 0
MaxIOReqPerLun            : 255
MaxIOReqPerAdapter        : 1000
luckyho commented 3 months ago

Thanks for the help, recently, we found out in our tests that rbd-wnbd seems to support trim