-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DAOS-14985 bio: Handle NVMe unplugged in list devs #13614
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
15a47c4
DAOS-14985 bio: Handle NVMe unplugged in list devs
tanabarr 42dc80a
Merge remote-tracking branch 'origin/master' into tanabarr/bio-unplug…
tanabarr 14846c2
address review comments from mjmac
tanabarr 444019d
Merge remote-tracking branch 'origin/master' into tanabarr/bio-unplug…
tanabarr 7b86208
add NvmeController helpers to detect acceptable state
tanabarr 8c95d78
don't populate pci address if unplugged
tanabarr a9c9ece
Merge remote-tracking branch 'origin/master' into tanabarr/bio-unplug…
tanabarr b423777
address memory leak as per code review comment from wangshilong
tanabarr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -338,11 +338,8 @@ ctrlr_reset_str_fields(Ctl__NvmeController *ctrlr) | |
static int | ||
add_ctrlr_details(Ctl__NvmeController *ctrlr, struct bio_dev_info *dev_info) | ||
{ | ||
int rc; | ||
int rc = 0; | ||
|
||
rc = copy_str2ctrlr(&ctrlr->pci_addr, dev_info->bdi_traddr); | ||
if (rc != 0) | ||
return rc; | ||
rc = copy_str2ctrlr(&ctrlr->model, dev_info->bdi_ctrlr->model); | ||
if (rc != 0) | ||
return rc; | ||
|
@@ -364,6 +361,32 @@ add_ctrlr_details(Ctl__NvmeController *ctrlr, struct bio_dev_info *dev_info) | |
ctrlr->model, ctrlr->serial, ctrlr->fw_rev, ctrlr->vendor_id, ctrlr->pci_dev_type, | ||
ctrlr->socket_id); | ||
|
||
/* Populate NVMe namespace id and capacity */ | ||
|
||
if (dev_info->bdi_ctrlr->nss == NULL) { | ||
D_ERROR("nss not initialized in bio_dev_info"); | ||
return -DER_INVAL; | ||
} | ||
D_ASSERT(dev_info->bdi_ctrlr->nss->next == NULL); | ||
|
||
/* When describing a SMD, only one NVMe namespace is relevant */ | ||
D_ALLOC_ARRAY(ctrlr->namespaces, 1); | ||
if (ctrlr->namespaces == NULL) { | ||
return -DER_NOMEM; | ||
} | ||
D_ALLOC_PTR(ctrlr->namespaces[0]); | ||
if (ctrlr->namespaces[0] == NULL) { | ||
return -DER_NOMEM; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [defect] ctrlr->namespaces leaked? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, thanks for spotting, fixed in the relevant free function |
||
} | ||
ctrlr->n_namespaces = 1; | ||
ctl__nvme_controller__namespace__init(ctrlr->namespaces[0]); | ||
|
||
ctrlr->namespaces[0]->id = dev_info->bdi_ctrlr->nss->id; | ||
ctrlr->namespaces[0]->size = dev_info->bdi_ctrlr->nss->size; | ||
|
||
D_DEBUG(DB_MGMT, "ns id/size: '%d' '%ld'\n", ctrlr->namespaces[0]->id, | ||
ctrlr->namespaces[0]->size); | ||
|
||
return 0; | ||
} | ||
|
||
|
@@ -426,12 +449,6 @@ ds_mgmt_smd_list_devs(Ctl__SmdDevResp *resp) | |
for (j = 0; j < dev_info->bdi_tgt_cnt; j++) | ||
resp->devices[i]->tgt_ids[j] = dev_info->bdi_tgts[j]; | ||
|
||
if (dev_info->bdi_ctrlr == NULL) { | ||
D_ERROR("ctrlr not initialized in bio_dev_info"); | ||
rc = -DER_INVAL; | ||
break; | ||
} | ||
|
||
/* Populate NVMe controller details */ | ||
|
||
D_ALLOC_PTR(resp->devices[i]->ctrlr); | ||
|
@@ -443,48 +460,25 @@ ds_mgmt_smd_list_devs(Ctl__SmdDevResp *resp) | |
/* Set string fields to NULL to allow D_FREE to work as expected on cleanup */ | ||
ctrlr_reset_str_fields(resp->devices[i]->ctrlr); | ||
|
||
rc = add_ctrlr_details(resp->devices[i]->ctrlr, dev_info); | ||
rc = copy_str2ctrlr(&resp->devices[i]->ctrlr->pci_addr, dev_info->bdi_traddr); | ||
if (rc != 0) | ||
break; | ||
|
||
/* Populate NVMe namespace id and capacity */ | ||
|
||
if (dev_info->bdi_ctrlr->nss == NULL) { | ||
D_ERROR("nss not initialized in bio_dev_info"); | ||
rc = -DER_INVAL; | ||
break; | ||
} | ||
D_ASSERT(dev_info->bdi_ctrlr->nss->next == NULL); | ||
|
||
/* When describing a SMD, only one NVMe namespace is relevant */ | ||
D_ALLOC_ARRAY(resp->devices[i]->ctrlr->namespaces, 1); | ||
if (resp->devices[i]->ctrlr->namespaces == NULL) { | ||
rc = -DER_NOMEM; | ||
break; | ||
} | ||
D_ALLOC_PTR(resp->devices[i]->ctrlr->namespaces[0]); | ||
if (resp->devices[i]->ctrlr->namespaces[0] == NULL) { | ||
rc = -DER_NOMEM; | ||
break; | ||
if (dev_info->bdi_ctrlr != NULL) { | ||
rc = add_ctrlr_details(resp->devices[i]->ctrlr, dev_info); | ||
if (rc != 0) | ||
break; | ||
resp->devices[i]->ctrlr_namespace_id = dev_info->bdi_ctrlr->nss->id; | ||
} else { | ||
D_DEBUG(DB_MGMT, "ctrlr not initialized in bio_dev_info, unplugged?"); | ||
} | ||
resp->devices[i]->ctrlr->n_namespaces = 1; | ||
ctl__nvme_controller__namespace__init(resp->devices[i]->ctrlr->namespaces[0]); | ||
|
||
resp->devices[i]->ctrlr->namespaces[0]->id = dev_info->bdi_ctrlr->nss->id; | ||
resp->devices[i]->ctrlr->namespaces[0]->size = dev_info->bdi_ctrlr->nss->size; | ||
resp->devices[i]->ctrlr_namespace_id = dev_info->bdi_ctrlr->nss->id; | ||
|
||
D_DEBUG(DB_MGMT, "ns id/size: '%d' '%ld'\n", | ||
resp->devices[i]->ctrlr->namespaces[0]->id, | ||
resp->devices[i]->ctrlr->namespaces[0]->size); | ||
|
||
/* Populate NVMe device state */ | ||
|
||
if ((dev_info->bdi_flags & NVME_DEV_FL_PLUGGED) == 0) { | ||
resp->devices[i]->ctrlr->dev_state = CTL__NVME_DEV_STATE__UNPLUGGED; | ||
goto next_dev; | ||
} | ||
|
||
if ((dev_info->bdi_flags & NVME_DEV_FL_FAULTY) != 0) | ||
resp->devices[i]->ctrlr->dev_state = CTL__NVME_DEV_STATE__EVICTED; | ||
else if ((dev_info->bdi_flags & NVME_DEV_FL_INUSE) == 0) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work, but if it were me I'd add a method to check this on
NvmeController
, e.g.sd.Ctrlr.Scannable()
. That keeps the definition of what makes the controller scannable in one place, so it's easier to maintain when the inevitable future changes happen (e.g. to protobufs, etc).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do this, probably should also do the same for the list of states that can be queried for health as that is different.