static int max_free_slots;
static int free_slots;
-static void
+static _Noreturn void
sweep_thread(void *arg)
{
int err = 0;
#include <time.h>
#include <unistd.h>
-static __attribute__((noreturn)) void
+static _Noreturn void
usage(void)
{
(void) fprintf(stderr,
static char *g_pool;
static boolean_t g_readonly;
-static __attribute__((noreturn)) void
+static _Noreturn void
usage(void)
{
(void) fprintf(stderr,
}
-static __attribute__((noreturn)) __attribute__((format(printf, 3, 4))) void
+static __attribute__((format(printf, 3, 4))) _Noreturn void
fatal(spa_t *spa, void *tag, const char *fmt, ...)
{
va_list ap;
ZTEST_OBJECTS
};
-static void usage(boolean_t) __NORETURN;
+static _Noreturn void usage(boolean_t);
static int ztest_scrub_impl(spa_t *spa);
/*
char *fatal_msg;
-static __attribute__((noreturn)) __attribute__((format(printf, 2, 3))) void
+static __attribute__((format(printf, 2, 3))) _Noreturn void
fatal(int do_perror, char *message, ...)
{
va_list args;
(void) zio_resume(spa);
}
-static void
+static _Noreturn void
ztest_resume_thread(void *arg)
{
spa_t *spa = arg;
thread_exit();
}
-static void
+static _Noreturn void
ztest_deadman_thread(void *arg)
{
ztest_shared_t *zs = arg;
(double)functime / NANOSEC, zi->zi_funcname);
}
-static void
+static _Noreturn void
ztest_thread(void *arg)
{
int rand;
AC_SUBST([NO_CLOBBERED])
])
-dnl #
-dnl # Check if cc supports -Wno-cast-function-type option.
-dnl #
-dnl # We actually invoke it with the --cast-function-type option
-dnl # and infer the 'no-' version does or doesn't exist based upon
-dnl # the results. This is required because when checking any of
-dnl # no- prefixed options gcc always returns success.
-dnl #
-AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_CAST_FUNCTION_TYPE], [
- AC_MSG_CHECKING([whether $CC supports -Wno-cast-function-type])
-
- saved_flags="$CFLAGS"
- CFLAGS="$CFLAGS -Werror -Wcast-function-type"
-
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
- NO_CAST_FUNCTION_TYPE=-Wno-cast-function-type
- AC_MSG_RESULT([yes])
- ], [
- NO_CAST_FUNCTION_TYPE=
- AC_MSG_RESULT([no])
- ])
-
- CFLAGS="$saved_flags"
- AC_SUBST([NO_CAST_FUNCTION_TYPE])
-])
-
dnl #
dnl # Check if cc supports -Wimplicit-fallthrough option.
dnl #
AC_SUBST(CPU_COUNT)
ZFS_AC_CONFIG_ALWAYS_CC_NO_CLOBBERED
- ZFS_AC_CONFIG_ALWAYS_CC_NO_CAST_FUNCTION_TYPE
ZFS_AC_CONFIG_ALWAYS_CC_IMPLICIT_FALLTHROUGH
ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN
ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION
__attribute__((format(printf, 1, 2)));
extern void uu_vwarn(const char *, va_list)
__attribute__((format(printf, 1, 0)));
-extern void uu_die(const char *, ...)
- __attribute__((format(printf, 1, 2))) __NORETURN;
-extern void uu_vdie(const char *, va_list)
- __attribute__((format(printf, 1, 0))) __NORETURN;
-extern void uu_xdie(int, const char *, ...)
- __attribute__((format(printf, 2, 3))) __NORETURN;
-extern void uu_vxdie(int, const char *, va_list)
- __attribute__((format(printf, 2, 0))) __NORETURN;
+extern _Noreturn void uu_die(const char *, ...)
+ __attribute__((format(printf, 1, 2)));
+extern _Noreturn void uu_vdie(const char *, va_list)
+ __attribute__((format(printf, 1, 0)));
+extern _Noreturn void uu_xdie(int, const char *, ...)
+ __attribute__((format(printf, 2, 3)));
+extern _Noreturn void uu_vxdie(int, const char *, va_list)
+ __attribute__((format(printf, 2, 0)));
/*
* Exit status functions (not to be used directly)
extern kthread_t *__thread_create(caddr_t stk, size_t stksize,
thread_func_t func, const char *name, void *args, size_t len, proc_t *pp,
int state, pri_t pri);
-extern void __thread_exit(void);
+extern __attribute__((noreturn)) void __thread_exit(void);
extern struct task_struct *spl_kthread_create(int (*func)(void *),
void *data, const char namefmt[], ...);
extern void cmn_err(int, const char *, ...);
extern void vcmn_err(int, const char *, va_list);
-extern void panic(const char *, ...) __NORETURN;
-extern void vpanic(const char *, va_list) __NORETURN;
+extern _Noreturn void panic(const char *, ...);
+extern _Noreturn void vpanic(const char *, va_list);
#define fm_panic panic
#define _SYS_FEATURE_TESTS_H
#define ____cacheline_aligned
-#define __NORETURN __attribute__((__noreturn__))
#if !defined(zfs_fallthrough) && !defined(_LIBCPP_VERSION)
#if defined(HAVE_IMPLICIT_FALLTHROUGH)
static const char *pname;
-static void
-uu_die_internal(int status, const char *format, va_list alist) __NORETURN;
+static _Noreturn void
+uu_die_internal(int status, const char *format, va_list alist);
int uu_exit_ok_value = EXIT_SUCCESS;
int uu_exit_fatal_value = EXIT_FAILURE;
va_end(alist);
}
-static __attribute__((format(printf, 2, 0))) __NORETURN void
+static __attribute__((format(printf, 2, 0))) _Noreturn void
uu_die_internal(int status, const char *format, va_list alist)
{
uu_warn_internal(errno, format, alist);
AM_CFLAGS += -DLIB_ZPOOL_BUILD
-# For the void (*)(void *) -> void *(*)(void *) cast in zk_thread_create()
-# See https://github.com/openzfs/zfs/pull/13110#discussion_r808450136
-kernel.$(OBJEXT): CFLAGS += $(NO_CAST_FUNCTION_TYPE)
-kernel.l$(OBJEXT): CFLAGS += $(NO_CAST_FUNCTION_TYPE)
-
lib_LTLIBRARIES = libzpool.la
USER_C = \
#define TS_STACK_MIN MAX(PTHREAD_STACK_MIN, 32768)
#define TS_STACK_MAX (256 * 1024)
+struct zk_thread_wrapper {
+ void (*func)(void *);
+ void *arg;
+};
+
+static void *
+zk_thread_wrapper(void *arg)
+{
+ struct zk_thread_wrapper ztw;
+ memcpy(&ztw, arg, sizeof (ztw));
+ free(arg);
+ ztw.func(ztw.arg);
+ return (NULL);
+}
+
kthread_t *
zk_thread_create(void (*func)(void *), void *arg, size_t stksize, int state)
{
pthread_attr_t attr;
pthread_t tid;
char *stkstr;
+ struct zk_thread_wrapper *ztw;
int detachstate = PTHREAD_CREATE_DETACHED;
VERIFY0(pthread_attr_init(&attr));
VERIFY0(pthread_attr_setstacksize(&attr, stksize));
VERIFY0(pthread_attr_setguardsize(&attr, PAGESIZE));
- VERIFY0(pthread_create(&tid, &attr, (void *(*)(void *))func, arg));
+ VERIFY(ztw = malloc(sizeof (*ztw)));
+ ztw->func = func;
+ ztw->arg = arg;
+ VERIFY0(pthread_create(&tid, &attr, zk_thread_wrapper, ztw));
VERIFY0(pthread_attr_destroy(&attr));
return ((void *)(uintptr_t)tid);
taskq_wait(tq);
}
-static void
+static _Noreturn void
taskq_thread(void *arg)
{
taskq_t *tq = arg;
typedef struct _label_t { long long unsigned val[JMP_BUF_CNT]; } label_t;
int setjmp(label_t *) __attribute__ ((__nothrow__));
-extern void longjmp(label_t *) __attribute__((__noreturn__));
+extern _Noreturn void longjmp(label_t *);
#define LUAI_THROW(L,c) longjmp(&(c)->b)
#define LUAI_TRY(L,c,a) if (setjmp(&(c)->b) == 0) { a }
/* L2ARC persistence rebuild control routines. */
void l2arc_rebuild_vdev(vdev_t *vd, boolean_t reopen);
-static void l2arc_dev_rebuild_thread(void *arg);
+static _Noreturn void l2arc_dev_rebuild_thread(void *arg);
static int l2arc_rebuild(l2arc_dev_t *dev);
/* L2ARC persistence read I/O routines. */
* This thread feeds the L2ARC at regular intervals. This is the beating
* heart of the L2ARC.
*/
-static void
+static _Noreturn void
l2arc_feed_thread(void *unused)
{
(void) unused;
/*
* Main entry point for L2ARC rebuilding.
*/
-static void
+static _Noreturn void
l2arc_dev_rebuild_thread(void *arg)
{
l2arc_dev_t *dev = arg;
* of the dbuf cache is at or below the maximum size. Once the dbuf is aged
* out of the cache it is destroyed and becomes eligible for arc eviction.
*/
-static void
+static _Noreturn void
dbuf_evict_thread(void *unused)
{
(void) unused;
* dmu_recv_stream's worker thread; pull records off the queue, and then call
* receive_process_record When we're done, signal the main thread and exit.
*/
-static void
+static _Noreturn void
receive_writer_thread(void *arg)
{
struct receive_writer_arg *rwa = arg;
return (0);
}
-static void
+static _Noreturn void
redact_traverse_thread(void *arg)
{
struct redact_thread_arg *rt_arg = arg;
int error_code;
};
-static void
+static _Noreturn void
redact_merge_thread(void *arg)
{
struct redact_merge_thread_arg *rmta = arg;
* error code of the thread in case something goes wrong, and pushes the End of
* Stream record when the traverse_dataset call has finished.
*/
-static void
+static _Noreturn void
send_traverse_thread(void *arg)
{
struct send_thread_arg *st_arg = arg;
return (next);
}
-static void
+static _Noreturn void
redact_list_thread(void *arg)
{
struct redact_list_thread_arg *rlt_arg = arg;
* data from the redact_list_thread and use that to determine which blocks
* should be redacted.
*/
-static void
+static _Noreturn void
send_merge_thread(void *arg)
{
struct send_merge_thread_arg *smt_arg = arg;
* some indirect blocks can be discarded because they're not holes. Second,
* it issues prefetches for the data we need to send.
*/
-static void
+static _Noreturn void
send_reader_thread(void *arg)
{
struct send_reader_thread_arg *srta = arg;
uint_t zfs_multihost_fail_intervals = MMP_DEFAULT_FAIL_INTERVALS;
static void *const mmp_tag = "mmp_write_uberblock";
-static void mmp_thread(void *arg);
+static _Noreturn void mmp_thread(void *arg);
void
mmp_init(spa_t *spa)
mutex_enter(&mmp->mmp_thread_lock);
}
-static void
+static _Noreturn void
mmp_thread_exit(mmp_thread_t *mmp, kthread_t **mpp, callb_cpr_t *cpr)
{
ASSERT(*mpp != NULL);
zio_nowait(zio);
}
-static void
+static _Noreturn void
mmp_thread(void *arg)
{
spa_t *spa = (spa_t *)arg;
spa_event_notify(vd->vdev_spa, vd, NULL, ESC_ZFS_VDEV_AUTOEXPAND);
}
-static void
+static _Noreturn void
spa_async_thread(void *arg)
{
spa_t *spa = (spa_t *)arg;
* now transition to the syncing state.
*/
-static void txg_sync_thread(void *arg);
-static void txg_quiesce_thread(void *arg);
+static _Noreturn void txg_sync_thread(void *arg);
+static _Noreturn void txg_quiesce_thread(void *arg);
int zfs_txg_timeout = 5; /* max seconds worth of delta per txg */
return (tx->tx_quiesced_txg != 0);
}
-static void
+static _Noreturn void
txg_sync_thread(void *arg)
{
dsl_pool_t *dp = arg;
}
}
-static void
+static _Noreturn void
txg_quiesce_thread(void *arg)
{
dsl_pool_t *dp = arg;
vdev_xlate_walk(vd, &logical_rs, vdev_initialize_xlate_range_add, arg);
}
-static void
+static _Noreturn void
vdev_initialize_thread(void *arg)
{
vdev_t *vd = arg;
/*
* For vdev_rebuild_initiate_sync() and vdev_rebuild_reset_sync().
*/
-static void vdev_rebuild_thread(void *arg);
+static _Noreturn void vdev_rebuild_thread(void *arg);
/*
* Clear the per-vdev rebuild bytes value for a vdev tree.
* Each scan thread is responsible for rebuilding a top-level vdev. The
* rebuild progress in tracked on-disk in VDEV_TOP_ZAP_VDEV_REBUILD_PHYS.
*/
-static void
+static _Noreturn void
vdev_rebuild_thread(void *arg)
{
vdev_t *vd = arg;
#define VDEV_REMOVAL_ZAP_OBJS "lzap"
-static void spa_vdev_remove_thread(void *arg);
+static _Noreturn void spa_vdev_remove_thread(void *arg);
static int spa_vdev_remove_cancel_impl(spa_t *spa);
static void
* TXG have completed (see spa_txg_zio) and writes the new mappings to disk
* (see vdev_mapping_sync()).
*/
-static void
+static _Noreturn void
spa_vdev_remove_thread(void *arg)
{
spa_t *spa = arg;
* by its ms_allocatable. While a metaslab is undergoing trimming it is
* not eligible for new allocations.
*/
-static void
+static _Noreturn void
vdev_trim_thread(void *arg)
{
vdev_t *vd = arg;
* N.B. This behavior is different from a manual TRIM where a thread
* is created for each leaf vdev, instead of each top-level vdev.
*/
-static void
+static _Noreturn void
vdev_autotrim_thread(void *arg)
{
vdev_t *vd = arg;
vdev_autotrim(spa);
}
-static void
+static _Noreturn void
vdev_trim_l2arc_thread(void *arg)
{
vdev_t *vd = arg;
const char *zthr_name;
};
-static void
+static _Noreturn void
zthr_procedure(void *arg)
{
zthr_t *t = arg;
#include <string.h>
-static __attribute__((noreturn)) void
+static _Noreturn void
usage(char *progname)
{
(void) fprintf(stderr, "Usage: %s <dirname|filename>\n", progname);
exit(1);
}
-static __attribute__((noreturn)) void
+static _Noreturn void
fail(char *err)
{
perror(err);
#define FILE_MODE (S_ISVTX + S_IRUSR + S_IWUSR)
-static void usage(void) __attribute__((noreturn));
+static _Noreturn void usage(void);
int
main(int argc, char **argv)