Commit 99969b6a authored by Jacek Pruciak's avatar Jacek Pruciak Committed by Jacek Pruciak
Browse files

testing/tcmu-runner: new aport

parent dcc36a16
Pipeline #86716 passed with stages
in 11 minutes and 5 seconds
# Contributor: Jacek Pruciak <alpine@juniorjpdj.pl>
# Maintainer: Jacek Pruciak <alpine@juniorjpdj.pl>
pkgname=tcmu-runner
pkgver=1.5.4
pkgrel=0
pkgdesc="A daemon that handles the userspace side of the LIO TCM-User backstore."
url="https://github.com/open-iscsi/tcmu-runner"
arch="all"
license="Apache-2.0"
makedepends="cmake glib-dev kmod-dev libnl3-dev ceph-dev"
options="!check" # no upstream tests
subpackages="libtcmu:libs libtcmu-dev $pkgname-doc $pkgname-rbd"
source="https://github.com/open-iscsi/tcmu-runner/archive/v$pkgver/tcmu-runner-$pkgver.tar.gz
tcmu-runner-fix-i586-size_t-error.patch
time_t-size-fix.patch
fix-musl-compilation.patch
"
build() {
if [ "$CBUILD" != "$CHOST" ]; then
CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
fi
cmake -B build \
-Dwith-glfs=false \
-Dwith-tcmalloc=false \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=True \
-DCMAKE_BUILD_TYPE=None \
$CMAKE_CROSSOPTS .
cmake --build build
}
check() {
# I asked upstream for tests, so let's leave it here. It's disabled anyway.
cd build
CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}
rbd() {
amove usr/lib/tcmu-runner/handler_rbd.so
}
package() {
DESTDIR="$pkgdir" cmake --install build
}
sha512sums="
e6fad89bd795ca7de38450a94f95fb4f4edb5bca32a34156f5690cf4c236f2f845578f592733a4fba29f64484a909c185b66af87ad92cf3ccff28bf4977ad2c3 tcmu-runner-1.5.4.tar.gz
a26fca68a73e5cc6726e880f5004b96fd0f5d3cbcaf6dd7a6a8a5e03f9089c91ec271b2517ea127b37dcead1499baac7cf6a5f23c0d4a70d13baa0107baefab3 tcmu-runner-fix-i586-size_t-error.patch
8eb7729cc7c89a24f512bb5f206034c8404d96891291fce132d075bd20568f346907185ac70e47d580fc95e9f2112c2695139c66b30e2b37d101988920f21793 time_t-size-fix.patch
2f1e30bbfca685ea05c5481b0e58e3a0bfe15e84652cabe2dabfe081e59313d93ca730754cd6165a848850a782cb273d3ea0976853b3b12a9718b4d3b28a520c fix-musl-compilation.patch
"
Summary: Fixes musl compatibility
Upstream: in progress
diff --git a/api.c b/api.c
index 490e257..d55da0a 100644
--- a/api.c
+++ b/api.c
@@ -28,6 +28,8 @@
#include "libtcmu_priv.h"
#include "be_byteshift.h"
+__thread int __tcmu_is_ework_thread = 0;
+
int tcmu_cdb_get_length(uint8_t *cdb)
{
uint8_t group_code = cdb[0] >> 5;
@@ -74,7 +76,7 @@ uint64_t tcmu_cdb_get_lba(uint8_t *cdb)
case 16:
return be64toh(*((u_int64_t *)&cdb[2]));
default:
- assert_perror(EINVAL);
+ assert(0);
return 0; /* not reached */
}
}
@@ -91,7 +93,7 @@ uint32_t tcmu_cdb_get_xfer_length(uint8_t *cdb)
case 16:
return be32toh(*((u_int32_t *)&cdb[10]));
default:
- assert_perror(EINVAL);
+ assert(0);
return 0; /* not reached */
}
}
diff --git a/libtcmu.c b/libtcmu.c
index c75bb10..1127218 100644
--- a/libtcmu.c
+++ b/libtcmu.c
@@ -843,24 +843,20 @@ const char *tcmu_dev_get_uio_name(struct tcmu_device *dev)
void tcmu_set_thread_name(const char *prefix, struct tcmu_device *dev)
{
const char *uio = dev ? tcmu_dev_get_uio_name(dev) : NULL;
- char cname[TCMU_THREAD_NAME_LEN];
char *pname;
- if (pthread_getname_np(pthread_self(), cname, TCMU_THREAD_NAME_LEN))
- return;
-
/*
* If we are trying to set the pthread name in the
* event work thread, we must ignore it.
*/
- if (!strcmp(cname, "ework-thread")) {
+ if (__tcmu_is_ework_thread) {
tcmu_dev_warn(dev, "Do not set name for event work thread in the callback fn\n");
return;
}
if (!prefix) {
tcmu_dev_err(dev, "Failed to set name for thread %lu\n",
- pthread_self());
+ (long unsigned int)pthread_self());
return;
}
diff --git a/libtcmu_common.h b/libtcmu_common.h
index 350693b..2897e1f 100644
--- a/libtcmu_common.h
+++ b/libtcmu_common.h
@@ -14,6 +14,7 @@
#define __LIBTCMU_COMMON_H
#include <stdbool.h>
+#include <pthread.h>
#ifdef __cplusplus
extern "C" {
@@ -193,6 +194,8 @@ void __tcmu_sense_set_data(uint8_t *sense_buf, uint8_t key, uint16_t asc_ascq);
*/
void tcmu_thread_cancel(pthread_t thread);
+extern __thread int __tcmu_is_ework_thread;
+
#ifdef __cplusplus
}
#endif
diff --git a/libtcmu_log.c b/libtcmu_log.c
index f7b6e2f..fee27a4 100644
--- a/libtcmu_log.c
+++ b/libtcmu_log.c
@@ -403,7 +403,6 @@ static int output_to_fd(int pri, const char *timestamp,
int fd = (intptr_t) data;
char *buf, *msg;
int count, ret, written = 0, r, pid = 0;
- char pname[TCMU_THREAD_NAME_LEN];
if (fd == -1)
return -1;
@@ -412,13 +411,10 @@ static int output_to_fd(int pri, const char *timestamp,
if (pid <= 0)
return -1;
- if (pthread_getname_np(pthread_self(), pname, TCMU_THREAD_NAME_LEN))
- return -1;
-
/*
* format: timestamp pid [loglevel] msg
*/
- ret = asprintf(&msg, "%s %d:%s [%s] %s", timestamp, pid, pname,
+ ret = asprintf(&msg, "%s %d [%s] %s", timestamp, pid,
loglevel_string(pri), str);
if (ret < 0)
return -1;
diff --git a/tcmur_work.c b/tcmur_work.c
index ee567e9..801e305 100644
--- a/tcmur_work.c
+++ b/tcmur_work.c
@@ -41,16 +41,11 @@ free_work:
static void __tcmur_flush_work(struct tcmur_work *work)
{
- char pname[TCMU_THREAD_NAME_LEN];
-
- if (pthread_getname_np(pthread_self(), pname, TCMU_THREAD_NAME_LEN))
- return;
-
/*
* The event work thread may need to do a handler reopen
* call and try to flush itself. Just ignore.
*/
- if (!strcmp(pname, "ework-thread"))
+ if (__tcmu_is_ework_thread)
return;
/*
@@ -79,6 +74,7 @@ static void *tcmur_work_fn(void *data)
struct private *p = data;
tcmu_set_thread_name("ework-thread", NULL);
+ __tcmu_is_ework_thread = 1;
p->work_fn(p->data);
From: David Disseldorp <ddiss@suse.de>
Date: Fri Jan 3 09:10:02 PST 2020
Subject: tcmu-runner: fix i586 size_t error
Patch-mainline: submitted pull request on github 1/2020
This fix silences a compiler complaint on i586 (32-bit).
Signed-off-by: Lee Duncan <lduncan@suse.com>
---
tcmur_cmd_handler.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/tcmur_cmd_handler.c
+++ b/tcmur_cmd_handler.c
@@ -712,7 +712,7 @@ static int handle_writesame(struct tcmu_
uint32_t block_size = tcmu_dev_get_block_size(dev);
uint64_t start_lba = tcmu_cdb_get_lba(cdb);
uint64_t write_lbas;
- size_t max_xfer_length, length = 1024 * 1024;
+ uint64_t max_xfer_length, length = 1024 * 1024;
struct write_same *write_same;
int i, ret;
Summary: Fixes 32-bit architecture compilation
Upstream: in progress
diff --git a/main.c b/main.c
index 475279a..f3295de 100644
--- a/main.c
+++ b/main.c
@@ -657,7 +657,7 @@ int tcmur_get_time(struct tcmu_device *dev, struct timespec *time)
ret = clock_gettime(CLOCK_MONOTONIC_COARSE, time);
if (!ret) {
- tcmu_dev_dbg(dev, "Current time %lu secs.\n", time->tv_sec);
+ tcmu_dev_dbg(dev, "Current time %jd secs.\n", (intmax_t)time->tv_sec);
return 0;
}
@@ -700,9 +700,9 @@ static bool get_next_cmd_timeout(struct tcmu_device *dev,
tmo->tv_sec = 0;
}
- tcmu_dev_dbg(dev, "Next cmd id %hu timeout in %lu secs. Current time %lu. Start time %lu\n",
- tcmur_cmd->lib_cmd->cmd_id, tmo->tv_sec,
- curr_time->tv_sec, tcmur_cmd->start_time.tv_sec);
+ tcmu_dev_dbg(dev, "Next cmd id %hu timeout in %jd secs. Current time %jd. Start time %jd\n",
+ tcmur_cmd->lib_cmd->cmd_id, (intmax_t)tmo->tv_sec,
+ (intmax_t)curr_time->tv_sec, (intmax_t)tcmur_cmd->start_time.tv_sec);
break;
}
pthread_spin_unlock(&rdev->lock);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment