Hi Amit,
Your analysis and fix looks correct to me that the hotplug processing may run on a single
core but other operations may cause race condition.
Will you submit a patch to Gerrit for this issue? It may be better to post an issue to
Github together.
Thanks,
Shuhei
________________________________
差出人: SPDK <spdk-bounces(a)lists.01.org> が Kumar, Amit1 <amit1.kumar(a)intel.com>
の代理で送信
送信日時: 2019年6月24日 21:02
宛先: Storage Performance Development Kit
件名: [!][SPDK] Race condition in drive hot plug being handled twice.
Hi,
Looks like there is a race condition while handling the case to avoid drive hot plug twice
in below SPDK code, bdev_nvme.c -
Existing code -
pthread_mutex_lock(&g_bdev_nvme_mutex);
TAILQ_FOREACH(nvme_bdev_ctrlr, &g_nvme_bdev_ctrlrs, tailq) {
if (nvme_bdev_ctrlr->ctrlr == ctrlr) {
/* The controller's destruction was already started */
if (nvme_bdev_ctrlr->destruct) {
pthread_mutex_unlock(&g_bdev_nvme_mutex);
return;
}
pthread_mutex_unlock(&g_bdev_nvme_mutex);
for (i = 0; i < nvme_bdev_ctrlr->num_ns; i++) {
uint32_t nsid = i + 1;
nvme_bdev = &nvme_bdev_ctrlr->bdevs[nsid - 1];
if (nvme_bdev->active) {
assert(nvme_bdev->id == nsid);
spdk_bdev_unregister(&nvme_bdev->disk,
NULL, NULL);
}
}
pthread_mutex_lock(&g_bdev_nvme_mutex);
nvme_bdev_ctrlr->destruct = true;
I think "destruct" variable needs to be set with in first block of mutex lock
before calling "spdk_bdev_unregister".
pthread_mutex_lock(&g_bdev_nvme_mutex);
TAILQ_FOREACH(nvme_bdev_ctrlr, &g_nvme_bdev_ctrlrs, tailq) {
if (nvme_bdev_ctrlr->ctrlr == ctrlr) {
/* The controller's destruction was already started */
if (nvme_bdev_ctrlr->destruct) {
pthread_mutex_unlock(&g_bdev_nvme_mutex);
return;
}
nvme_bdev_ctrlr->destruct = true; --> this should be set
before releasing the lock.
pthread_mutex_unlock(&g_bdev_nvme_mutex);
Please let me know your inputs on this.
Thanks,
Amit
_______________________________________________
SPDK mailing list
SPDK(a)lists.01.org
https://clicktime.symantec.com/35huGd19KJkhRntCNN94w3g7Vc?u=https%3A%2F%2...