nvme: add the shared mutex init function for g_spdk_nvme_driver

Change-Id: Ib2a89beffb58004fdfd5a308feb6de2307dd5b81
Signed-off-by: GangCao <gang.cao@intel.com>
This commit is contained in:
GangCao 2016-08-23 23:25:18 -04:00 committed by Daniel Verkamp
parent 6e09a48e42
commit dcd19bdb23
2 changed files with 19 additions and 0 deletions

View File

@ -156,6 +156,23 @@ nvme_free_request(struct nvme_request *req)
nvme_dealloc_request(req);
}
int
nvme_mutex_init_shared(pthread_mutex_t *mtx)
{
pthread_mutexattr_t attr;
int rc = 0;
if (pthread_mutexattr_init(&attr)) {
return -1;
}
if (pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED) ||
pthread_mutex_init(mtx, &attr)) {
rc = -1;
}
pthread_mutexattr_destroy(&attr);
return rc;
}
struct nvme_enum_ctx {
spdk_nvme_probe_cb probe_cb;
void *cb_ctx;

View File

@ -580,4 +580,6 @@ bool nvme_intel_has_quirk(struct pci_id *id, uint64_t quirk);
void spdk_nvme_ctrlr_opts_set_defaults(struct spdk_nvme_ctrlr_opts *opts);
int nvme_mutex_init_shared(pthread_mutex_t *mtx);
#endif /* __NVME_INTERNAL_H__ */