1 // SPDX-License-Identifier: BSD-2-Clause 2 /* 3 * Copyright (c) 2020 iXsystems, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * $FreeBSD$ 28 */ 29 30 #ifndef ZFS_CONTEXT_OS_H_ 31 #define ZFS_CONTEXT_OS_H_ 32 33 #include <sys/condvar.h> 34 #include <sys/rwlock.h> 35 #include <sys/sig.h> 36 #include_next <sys/sdt.h> 37 #include <sys/misc.h> 38 #include <sys/kdb.h> 39 #include <sys/pathname.h> 40 #include <sys/conf.h> 41 #include <sys/types.h> 42 #include <sys/ccompat.h> 43 #include <linux/types.h> 44 45 #if KSTACK_PAGES * PAGE_SIZE >= 16384 46 #define HAVE_LARGE_STACKS 1 47 #endif 48 49 #define taskq_create_sysdc(a, b, d, e, p, dc, f) \ 50 ((void) sizeof (dc), taskq_create(a, b, maxclsyspri, d, e, f)) 51 52 #define tsd_create(keyp, destructor) do { \ 53 *(keyp) = osd_thread_register((destructor)); \ 54 KASSERT(*(keyp) > 0, ("cannot register OSD")); \ 55 } while (0) 56 57 #define tsd_destroy(keyp) osd_thread_deregister(*(keyp)) 58 #define tsd_get(key) osd_thread_get(curthread, (key)) 59 #define tsd_set(key, value) osd_thread_set(curthread, (key), (value)) 60 #define fm_panic panic 61 62 extern int zfs_debug_level; 63 extern struct mtx zfs_debug_mtx; 64 #define ZFS_LOG(lvl, ...) do { \ 65 if (((lvl) & 0xff) <= zfs_debug_level) { \ 66 mtx_lock(&zfs_debug_mtx); \ 67 printf("%s:%u[%d]: ", \ 68 __func__, __LINE__, (lvl)); \ 69 printf(__VA_ARGS__); \ 70 printf("\n"); \ 71 if ((lvl) & 0x100) \ 72 kdb_backtrace(); \ 73 mtx_unlock(&zfs_debug_mtx); \ 74 } \ 75 } while (0) 76 77 #define MSEC_TO_TICK(msec) (howmany((hrtime_t)(msec) * hz, MILLISEC)) 78 extern int hz; 79 extern int tick; 80 typedef int fstrans_cookie_t; 81 #define spl_fstrans_mark() (0) 82 #define spl_fstrans_unmark(x) ((void)x) 83 #define signal_pending(x) SIGPENDING(x) 84 #define current curthread 85 #define thread_join(x) 86 typedef struct opensolaris_utsname utsname_t; 87 extern utsname_t *utsname(void); 88 extern int spa_import_rootpool(const char *name, bool checkpointrewind); 89 #endif 90