Commit bbfbadf5 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Jim Harris
Browse files

vhost: add spdk_vhost_trylock()



We'll make use of it inside the vhost device backend
code. The function itself is generic enough to be put
in the public vhost.h header rather than vhost_internal.h.

Change-Id: I60602c61d8bba665dcf9c6d27af2e910c208a7be
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448226


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 0d076e26
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -109,10 +109,17 @@ void spdk_vhost_shutdown_cb(void);
struct spdk_vhost_dev;

/**
 * Lock the global vhost mutex, which synchronizes all the vhost device accesses.
 * Lock the global vhost mutex synchronizing all the vhost device accesses.
 */
void spdk_vhost_lock(void);

/**
 * Lock the global vhost mutex synchronizing all the vhost device accesses.
 *
 * \return 0 if the mutex could be locked immediately, negative errno otherwise.
 */
int spdk_vhost_trylock(void);

/**
 * Unlock the global vhost mutex.
 */
+6 −0
Original line number Diff line number Diff line
@@ -1403,6 +1403,12 @@ spdk_vhost_lock(void)
	pthread_mutex_lock(&g_spdk_vhost_mutex);
}

int
spdk_vhost_trylock(void)
{
	return -pthread_mutex_trylock(&g_spdk_vhost_mutex);
}

void
spdk_vhost_unlock(void)
{