Basics of LUN and Target discovery on Windows

Image result for windows logoDuring my work with multipathing driver, I came across multiple situations where once devices were removed and added but they did not come back in time. Multi pathing driver would eventually be blamed for not presenting the paths (Since device is not back).

I thought to pen down some of the scenarios on how the LUN / target disovery happens
What happens when you remove/add cable from HBA to switch?

  1. HBA(miniport) driver raises “BusChangeDetected” notification to storport driver.
  2. Port driver generates “IoInvalidateDeviceRelations” which asks PNP to delete current device list
  3. Bus rescan happens and fresh list of LUNs is rebuilt for every target by sending a REPORT_LUNS request to LUN 0 of each target.
  4. If the above request fails then storport sends an INQUIRY to LUN 0.
  5. If inquiry is successful, INQUIRY will be sent to other luns as well and the list will be built.
  6. If INQUIRY fails on LUN 0 then storport moves to next target.
  7. Storport then compares this new list with the old and finds out the difference.
  8. For the difference of LUNs a PNP is generated to communicate that change to upper layer drivers on the stack.

To know more email: marketing@calsoftinc.com

Contributed by: Himanshu Sonkar | Calsoft Inc.
Himanshu Sonkar

Himanshu Sonkar

Sr. Principal Dev Engg at Calsoft Inc.
Himanshu have 12 years of experience in working on windows platform (C/C++/MFC) writing storage, networking, security drivers, services and desktop application.
Himanshu Sonkar

Latest posts by Himanshu Sonkar (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *