Commit d7a3a052 authored by Vitaliy Mysak's avatar Vitaliy Mysak Committed by Tomasz Zawadzki
Browse files

ocf: update ocf submodule to v20.3

New OCF version is ready, so update our submodule.
There were a lot of API changes so
we need to adjust our bdev/ocf and lib/ocf_env code.

Description of code changes:
- env: added small functions like ENV_BUILD_BUG_ON, env_vzalloc_flags
- env: added "destroy" method for all locks
- env: added "execution context" interface
- cache/core "id" field made private
- signature of "ocf_io_configure" changed
- "io->volume" field made private

List of changes to OCF is available at
https://github.com/Open-CAS/ocf/releases


But no new features were implemented for our
OCF module since 19.6

Change-Id: I1ac2b6db0aad2a9840e4fa73d65608c5638fcb23
Signed-off-by: default avatarVitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1801


Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent e316ec90
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2,6 +2,12 @@

## v20.04: (Upcoming Release)

### ocf

Update OCF submodule to OCF v20.03

New version of OCF comes with API changes and bug fixes

### nvme

Export internal nvme_ctrlr_cmd_security_receive/send() APIs as public APIs with "spdk_"
+59 −0
Original line number Diff line number Diff line
@@ -115,3 +115,62 @@ env_crc32(uint32_t crc, uint8_t const *message, size_t len)
{
	return spdk_crc32_ieee_update(message, len, crc);
}

/* EXECUTION CONTEXTS */
pthread_mutex_t *exec_context_mutex;

static void __attribute__((constructor)) init_execution_context(void)
{
	unsigned count = env_get_execution_context_count();
	unsigned i;

	ENV_BUG_ON(count == 0);
	exec_context_mutex = malloc(count * sizeof(exec_context_mutex[0]));
	ENV_BUG_ON(exec_context_mutex == NULL);
	for (i = 0; i < count; i++) {
		ENV_BUG_ON(pthread_mutex_init(&exec_context_mutex[i], NULL));
	}
}

static void __attribute__((destructor)) deinit_execution_context(void)
{
	unsigned count = env_get_execution_context_count();
	unsigned i;

	ENV_BUG_ON(count == 0);
	ENV_BUG_ON(exec_context_mutex == NULL);

	for (i = 0; i < count; i++) {
		ENV_BUG_ON(pthread_mutex_destroy(&exec_context_mutex[i]));
	}
	free(exec_context_mutex);
}

/* get_execuction_context must assure that after the call finishes, the caller
 * will not get preempted from current execution context. For userspace env
 * we simulate this behavior by acquiring per execution context mutex. As a
 * result the caller might actually get preempted, but no other thread will
 * execute in this context by the time the caller puts current execution ctx. */
unsigned env_get_execution_context(void)
{
	unsigned cpu;

	cpu = sched_getcpu();
	cpu = (cpu == -1) ?  0 : cpu;

	ENV_BUG_ON(pthread_mutex_lock(&exec_context_mutex[cpu]));

	return cpu;
}

void env_put_execution_context(unsigned ctx)
{
	pthread_mutex_unlock(&exec_context_mutex[ctx]);
}

unsigned env_get_execution_context_count(void)
{
	int num = sysconf(_SC_NPROCESSORS_ONLN);

	return (num == -1) ? 0 : num;
}
+38 −1
Original line number Diff line number Diff line
@@ -112,6 +112,9 @@ typedef uint64_t sector_t;
		} \
	})

#define ENV_BUILD_BUG_ON(cond)		_Static_assert(!(cond), "static "\
					"assertion failure")

#define container_of(ptr, type, member) SPDK_CONTAINEROF(ptr, type, member)

static inline void *env_malloc(size_t size, int flags)
@@ -145,6 +148,11 @@ static inline void *env_vzalloc(size_t size)
			    SPDK_MALLOC_DMA);
}

static inline void *env_vzalloc_flags(size_t size, int flags)
{
	return env_vzalloc(size);
}

static inline void *env_secure_alloc(size_t size)
{
	return spdk_zmalloc(size, 0, NULL, SPDK_ENV_LCORE_ID_ANY,
@@ -228,6 +236,15 @@ static inline int env_mutex_is_locked(env_mutex *mutex)
	return 1;
}

static inline int env_mutex_destroy(env_mutex *mutex)
{
	if (pthread_mutex_destroy(&mutex->m)) {
		return 1;
	}

	return 0;
}

/* *** RECURSIVE MUTEX *** */

typedef env_mutex env_rmutex;
@@ -268,6 +285,11 @@ static inline int env_rmutex_is_locked(env_rmutex *rmutex)
	return env_mutex_is_locked(rmutex);
}

static inline int env_rmutex_destroy(env_rmutex *rmutex)
{
	return env_mutex_destroy(rmutex);
}

/* *** RW SEMAPHORE *** */
typedef struct {
	pthread_rwlock_t lock;
@@ -327,6 +349,11 @@ static inline int env_rwsem_down_write_interruptible(env_rwsem *s)
	return pthread_rwlock_wrlock(&s->lock);
}

static inline int env_rwsem_destroy(env_rwsem *s)
{
	return pthread_rwlock_destroy(&s->lock);
}

/* *** ATOMIC VARIABLES *** */

typedef int env_atomic;
@@ -510,6 +537,11 @@ static inline void env_completion_complete(env_completion *completion)
	sem_post(&completion->sem);
}

static inline void env_completion_destroy(env_completion *completion)
{
	sem_destroy(&completion->sem);
}

/* *** SPIN LOCKS *** */

typedef struct {
@@ -752,7 +784,7 @@ static inline int env_strncpy(char *dest, size_t dmax, const char *src, size_t l
	return 0;
}

#define env_strncmp strncmp
#define env_strncmp(s1, slen1, s2, slen2) strncmp(s1, s2, min(slen1, slen2))

static inline char *env_strdup(const char *src, int flags)
{
@@ -795,4 +827,9 @@ static inline void env_touch_softlockup_wd(void)

uint32_t env_crc32(uint32_t crc, uint8_t const *data, size_t len);

/* EXECUTION CONTEXTS */
unsigned env_get_execution_context(void);
void env_put_execution_context(unsigned ctx);
unsigned env_get_execution_context_count(void);

#endif /* __OCF_ENV_H__ */
+2 −2
Original line number Diff line number Diff line
@@ -36,8 +36,8 @@

#include "spdk/stdinc.h"

#define OCF_VERSION_MAIN 3
#define OCF_VERSION_MAJOR 8
#define OCF_VERSION_MAIN 20
#define OCF_VERSION_MAJOR 3
#define OCF_VERSION_MINOR 0

#endif /* __OCF_ENV_HEADERS_H__ */
+3 −3
Original line number Diff line number Diff line
@@ -35,12 +35,12 @@
#include "stats.h"

int
vbdev_ocf_stats_get(ocf_cache_t cache, ocf_core_id_t core_id, struct vbdev_ocf_stats *stats)
vbdev_ocf_stats_get(ocf_cache_t cache, char *core_name, struct vbdev_ocf_stats *stats)
{
	int status;
	ocf_core_t core;

	status = ocf_core_get(cache, core_id, &core);
	status = ocf_core_get_by_name(cache, core_name, strlen(core_name), &core);
	if (status) {
		return status;
	}
@@ -52,7 +52,7 @@ vbdev_ocf_stats_get(ocf_cache_t cache, ocf_core_id_t core_id, struct vbdev_ocf_s
	spdk_json_write_named_object_begin(w, #field); \
	spdk_json_write_named_uint64(w, "count", stats->group.field.value); \
	spdk_json_write_named_string_fmt(w, "percentage", "%lu.%lu", \
		stats->group.field.percent / 10, stats->group.field.percent % 10); \
		stats->group.field.fraction / 100, stats->group.field.fraction % 100); \
	spdk_json_write_named_string(w, "units", units); \
	spdk_json_write_object_end(w);

Loading