Determine if a disk is an SSD in an upper filter driver

Sorry if this is obvious, but I tried very hard to get an answer.

In my disk upper filter driver, I want to know if the disk is a SSD. Am I supposed to send a STORAGE_PROPERTY_QUERY with STORAGE_PROPERTY_ID with StorageDeviceTrimProperty? I only want to differentiate between “rotational media” and “memory media”. As long I get a “yes” for most current gen SSDs, that is a good enough answer for me.

Regards,
Mridul.

That should work.

What many folks do is watch for IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES with DeviceDsmAction_Trim to be sent by the NTFS and processed by the underlying device.

A lot depends on the specific devices you’re trying to detect. Do you include USB flash drives?

Peter

No USB flash drives. Just the usual internal SSDs via SATA cable or SSD in an external USB enclosure.

Yeah, so… as above. I haven’t done either in a looooong time, but I would say whichever is more convenient.

Since your filter is above Disk Class, you should see the IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES go by during initialization… just watch for the completion. Try that…

Peter

Thank you! I will try that.

@craniumrat

Am I supposed to send a STORAGE_PROPERTY_QUERY with STORAGE_PROPERTY_ID with StorageDeviceTrimProperty? I only want to **differentiate between “rotational media” and “memory media”. **

You are almost right, but slightly wrong with StorageDeviceTrimProperty. Use StorageDeviceSeekPenaltyProperty and DEVICE_SEEK_PENALTY_DESCRIPTOR.IncursSeekPenalty

StorageDeviceSeekPenaltyProperty

Interesting. Never noticed that one before.

Can you tell us when StorageDeviceSeekPenaltyProperty will be set to TRUE but StorageTrimProperty or DeviceDsmAction_Trim will be set to FALSE for an SSD?

Peter

Can you tell us when StorageDeviceSeekPenaltyProperty will be set to TRUE but StorageTrimProperty … will be set to FALSE for an SSD?

  1. Never seen such condition on ATA or NVME flash drives. Probably it can appear on non flash devices like Optane, but i still don’t have this beast in my hand. But such devices definitely exist right now: virtual HDD drives (see attachment).
  2. No matter (1) - ATA IDENTIFY, field “Nominal media rotation rate” (word 217) translates to StorageDeviceSeekPenaltyProperty, AFAIK. So initial request “differentiate between “rotational media” and “memory media”” has one right answer, IMHO.

or DeviceDsmAction_Trim
Never used this.

Thank you, and again… very interesting.

But, didn’t the IDENTIFY you attached show a good reason not to use Incurs Seek Penalty? This is a virtual disk, not an SSD, and it sets Seek Penalty to FALSE (we can argue about whether that’s correct or not, but no matter). But I bet this “device” does not indicate support for trim. I dunno, maybe it does?

I am glad to know about the Seek Penalty field, I hadn’t seen it before… and it will be interesting to what sets it vs trim in future.

Peter

This is a virtual disk, not an SSD, and it sets Seek Penalty to FALSE (we can argue about whether that’s correct or not, but no matter).
Read exact name of attachment :wink:
Then look at the second attachment and pay attention to its name too. Someone smart enough did this thing!
P.S. Attachment don’t appear at post, but its link is below and its name “FileBackedVirtualOnHDD.txt”
/uploads/db2714/original/1X/96c5f1575f7848aaf47fe7bc76eb7b61aa2823fe.txt

Ahhh! The second attachment didn’t show up. NOW I get your point.

Yes… very clever.

Fun stuff. Thanks, Mr. SweetLow.

Peter

JFYI
@SweetLow said:

Can you tell us when StorageDeviceSeekPenaltyProperty will be set to TRUE but StorageTrimProperty … will be set to FALSE for an SSD?
Probably it can appear on non flash devices like Optane, but i still don’t have this beast in my hand.

Intel NVMe Optane M.2, MEMPEK1W016GA

--------- Device Trim Descriptor ---------------------
TrimEnabled = Yes

So this kind of devices supports trim (or, probably more precisely, NVMe DSM Deallocate Logical Block).