Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

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

craniumratcraniumrat Member Posts: 4
edited April 12 in NTDEV

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.

Comments

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,223

    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

    Peter Viscarola
    OSR
    @OSRDrivers

  • craniumratcraniumrat Member Posts: 4

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

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,223

    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

    Peter Viscarola
    OSR
    @OSRDrivers

  • craniumratcraniumrat Member Posts: 4

    Thank you! I will try that.

  • SweetLowSweetLow Member Posts: 22
    edited April 23

    @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

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,223

    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

    Peter Viscarola
    OSR
    @OSRDrivers

  • SweetLowSweetLow Member Posts: 22

    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.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,223

    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

    Peter Viscarola
    OSR
    @OSRDrivers

  • SweetLowSweetLow Member Posts: 22
    edited April 24

    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 ;)
    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"
    https://us.v-cdn.net/6030753/uploads/editor/p2/gq281uplog7y.txt

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,223

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

    Yes... very clever.

    Fun stuff. Thanks, Mr. SweetLow.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Developing Minifilters 29 July 2019 OSR Seminar Space
Writing WDF Drivers 23 Sept 2019 OSR Seminar Space
Kernel Debugging 21 Oct 2019 OSR Seminar Space
Internals & Software Drivers 18 Nov 2019 Dulles, VA