Whamcloud - gitweb
LU-17836 build: allow builds without libpthread 62/55062/2
authorShaun Tancheff <shaun.tancheff@hpe.com>
Thu, 9 May 2024 10:10:54 +0000 (17:10 +0700)
committerOleg Drokin <green@whamcloud.com>
Fri, 31 May 2024 14:56:27 +0000 (14:56 +0000)
Configure currently allows for --disable-libpthread it is not
frequently used but may be needed for some users.

Test-Parameters: trivial
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I32049bab8e0f278b4c80fe37839c8c90c45d4c74
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55062
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/rw_seq_cst_vs_drop_caches.c
lustre/utils/lctl_thread.c
lustre/utils/lctl_thread.h
lustre/utils/obd.c

index e428fb0..c0f7ded 100644 (file)
@@ -8,7 +8,9 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
+#ifdef HAVE_LIBPTHREAD
 #include <pthread.h>
+#endif
 
 /*
  * Usage: rw_seq_cst_vs_drop_caches [-m] /mnt/lustre/file0 /mnt/lustre2/file0
@@ -36,9 +38,11 @@ static int fd[2] = { -1, -1 };
  * contending with constant reads
  */
 static uint64_t u, u_max = UINT64_MAX / 2;
-static uint64_t v[2];
 char *ptr;
 
+#ifdef HAVE_LIBPTHREAD
+static uint64_t v[2];
+
 static void *access_thread_start(void *unused)
 {
        char *ptr2 = NULL;
@@ -72,13 +76,14 @@ static void *access_thread_start(void *unused)
                munmap(ptr2, sizeof(v[i]));
        abort();
 }
+#endif
 
 static char stderr_buf[4096];
 
 int main(int argc, char *argv[])
 {
        int drop_caches_fd = -1;
-       pthread_t access_thread;
+       pthread_t access_thread __attribute__ ((unused));
        struct stat st[2];
        ssize_t rc;
        int i, ch;
@@ -140,9 +145,11 @@ int main(int argc, char *argv[])
                        handle_error("pwrite");
        }
 
+#ifdef HAVE_LIBPTHREAD
        rc = pthread_create(&access_thread, NULL, &access_thread_start, NULL);
        if (rc != 0)
                handle_error("pthread_create");
+#endif
 
        for (u = 1; u <= u_max; u++) {
                if (mmap_mode) {
@@ -158,6 +165,7 @@ int main(int argc, char *argv[])
                        handle_error("drop caches");
        }
 
+#ifdef HAVE_LIBPTHREAD
        rc = pthread_cancel(access_thread);
        if (rc != 0)
                handle_error("pthread_cancel");
@@ -165,6 +173,7 @@ int main(int argc, char *argv[])
        rc = pthread_join(access_thread, NULL);
        if (rc != 0)
                handle_error("pthread_join");
+#endif
 
        if (mmap_mode)
                munmap(ptr, sizeof(u));
index f4bd5d7..29b4e45 100644 (file)
  *
  * Author: Rajeev Mishra <rajeevm@hpe.com>
  */
- #include <errno.h>
- #include <stdio.h>
- #include <stdarg.h>
- #include <ctype.h>
- #include "lctl_thread.h"
- #include <stdlib.h>
- #include <libcfs/util/string.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include "lctl_thread.h"
+#include <stdlib.h>
+#include <libcfs/util/string.h>
+
 #if HAVE_LIBPTHREAD
 /**
  * Initialize the given set_param work queue.
@@ -298,12 +300,5 @@ out_free:
        free(sp_threads);
        return rc;
 }
-#else
-#define popt_is_parallel(popt) 0
-#define spwq_init(wq, popt) 0
-#define spwq_expand(wq, num_items) 0
-#define spwq_add_item(wq, path, param_name, value) 0
-#define sp_run_threads(wq) 0
-#define spwq_destroy(wq) 0
-struct sp_workq { int unused; }
+
 #endif /* HAVE_LIBPTHREAD */
index c9f32af..ae64041 100644 (file)
@@ -49,9 +49,10 @@ struct param_opts {
        unsigned int po_header:1;
        unsigned int po_parallel_threads;
 };
-#define popt_is_parallel(popt) ((popt).po_parallel_threads > 0)
 
 #ifdef HAVE_LIBPTHREAD
+#define popt_is_parallel(popt) ((popt).po_parallel_threads > 0)
+
 int write_param(const char *path, const char *param_name,
                struct param_opts *popt, const char *value);
 
@@ -96,4 +97,21 @@ int spwq_expand(struct sp_workq *wq, size_t num_items);
 int spwq_add_item(struct sp_workq *wq, char *path, char *param_name,
                  char *value);
 int sp_run_threads(struct sp_workq *wq);
+#else
+#define popt_is_parallel(popt) 0
+
+struct sp_workq { int unused; };
+
+static inline int spwq_init(struct sp_workq *wq, struct param_opts *popt)
+{ return 0; }
+static inline int spwq_destroy(struct sp_workq *wq)
+{ return 0; }
+static inline int spwq_expand(struct sp_workq *wq, size_t num_items)
+{ return 0; }
+static inline int spwq_add_item(struct sp_workq *wq, char *path,
+                               char *param_name, char *value)
+{ return 0; }
+static inline int sp_run_threads(struct sp_workq *wq)
+{ return 0; }
+
 #endif
index 81e7cd1..d731156 100644 (file)
@@ -2004,16 +2004,18 @@ int jt_obd_test_brw(int argc, char **argv)
        struct obd_ioctl_data data;
        struct timeval start, next_time;
        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
-       __u64 count, next_count, len, stride, thr_offset = 0, objid = 3;
+       __u64 count, next_count, len, thr_offset = 0, objid = 3;
        int write = 0, verbose = 1, cmd, i, rc = 0, pages = 1;
        int offset_pages = 0;
        long n;
        int repeat_offset = 0;
        unsigned long long ull;
-       int  nthr_per_obj = 0;
        int  verify = 1;
-       int  obj_idx = 0;
        char *end;
+       __u64 stride __attribute__ ((unused));
+       int  nthr_per_obj __attribute__ ((unused)) = 0;
+       int  obj_idx __attribute__ ((unused)) = 0;
+
 
        if (argc < 2 || argc > 7) {
                fprintf(stderr, "error: %s: bad number of arguments: %d\n",