openzfsonwindows / ZFSin

OpenZFS on Windows port
https://openzfsonwindows.org
1.2k stars 69 forks source link

TargetId and Lun is created for zvol before it is fully open #341

Closed datacore-rm closed 2 years ago

datacore-rm commented 2 years ago

In function zvol_create_minor_impl(), the TargetId and Lun is created for zvol before it is fully setup/initialized.

zvol_create_minor_impl(const char *name) { ... // Assign new TargetId and Lun (1) wzvol_assign_targetid(zv); ... ... // This method setup additional zvol state like zv_volsize etc. So zvol state is not complete till this method. (2) error = zvol_open_impl(zv, FWRITE, 0, NULL);

 can the targetId and Lun be assigned here?
//wzvol_assign_targetid(zv);

}

I understand that StorPortNotification(BusChangeDetected) is called after this method returns. But if suppose for some reason (say disk rescan), SCSIOP_REPORT_LUNS request is received in between 1 & 2 then ScsiOpReportLuns() would also report this partially initialized zvol?

lundman commented 2 years ago

I should think we can probably just move the assign down to under the open