zfs_context.h revision 339158
1192067Snwhitehorn/* 2192067Snwhitehorn * CDDL HEADER START 3192067Snwhitehorn * 4192067Snwhitehorn * The contents of this file are subject to the terms of the 5192067Snwhitehorn * Common Development and Distribution License (the "License"). 6192067Snwhitehorn * You may not use this file except in compliance with the License. 7192067Snwhitehorn * 8192067Snwhitehorn * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9192067Snwhitehorn * or http://www.opensolaris.org/os/licensing. 10192067Snwhitehorn * See the License for the specific language governing permissions 11192067Snwhitehorn * and limitations under the License. 12192067Snwhitehorn * 13192067Snwhitehorn * When distributing Covered Code, include this CDDL HEADER in each 14192067Snwhitehorn * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15192067Snwhitehorn * If applicable, add the following below this CDDL HEADER, with the 16192067Snwhitehorn * fields enclosed by brackets "[]" replaced with your own identifying 17192067Snwhitehorn * information: Portions Copyright [yyyy] [name of copyright owner] 18192067Snwhitehorn * 19192067Snwhitehorn * CDDL HEADER END 20192067Snwhitehorn */ 21192067Snwhitehorn/* 22192067Snwhitehorn * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23192067Snwhitehorn * Use is subject to license terms. 24192067Snwhitehorn */ 25192067Snwhitehorn/* 26192067Snwhitehorn * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 27192067Snwhitehorn * Copyright (c) 2013 by Delphix. All rights reserved. 28192067Snwhitehorn */ 29192067Snwhitehorn 30192067Snwhitehorn#ifndef _SYS_ZFS_CONTEXT_H 31192067Snwhitehorn#define _SYS_ZFS_CONTEXT_H 32192067Snwhitehorn 33192067Snwhitehorn#ifdef __cplusplus 34192067Snwhitehornextern "C" { 35192067Snwhitehorn#endif 36192067Snwhitehorn 37192067Snwhitehorn#include <sys/param.h> 38198212Snwhitehorn#include <sys/stdint.h> 39198212Snwhitehorn#include <sys/note.h> 40192067Snwhitehorn#include <sys/kernel.h> 41262675Sjhibbits#include <sys/debug.h> 42192067Snwhitehorn#include <sys/systm.h> 43192067Snwhitehorn#include <sys/proc.h> 44262675Sjhibbits#include <sys/sysmacros.h> 45192067Snwhitehorn#include <sys/bitmap.h> 46192067Snwhitehorn#include <sys/cmn_err.h> 47198212Snwhitehorn#include <sys/kmem.h> 48262675Sjhibbits#include <sys/taskq.h> 49192067Snwhitehorn#include <sys/taskqueue.h> 50192067Snwhitehorn#include <sys/systm.h> 51192067Snwhitehorn#include <sys/conf.h> 52192067Snwhitehorn#include <sys/mutex.h> 53192067Snwhitehorn#include <sys/rwlock.h> 54192067Snwhitehorn#include <sys/kcondvar.h> 55192067Snwhitehorn#include <sys/random.h> 56192067Snwhitehorn#include <sys/byteorder.h> 57192067Snwhitehorn#include <sys/systm.h> 58192067Snwhitehorn#include <sys/list.h> 59212054Snwhitehorn#include <sys/zfs_debug.h> 60255910Snwhitehorn#include <sys/sysevent.h> 61266020Sian#include <sys/uio.h> 62266020Sian#include <sys/dirent.h> 63212054Snwhitehorn#include <sys/time.h> 64212054Snwhitehorn#include <sys/uio.h> 65212054Snwhitehorn#include <sys/fcntl.h> 66212054Snwhitehorn#include <sys/limits.h> 67212054Snwhitehorn#include <sys/string.h> 68212054Snwhitehorn#include <sys/bio.h> 69262675Sjhibbits#include <sys/buf.h> 70192067Snwhitehorn#include <sys/cred.h> 71212054Snwhitehorn#include <sys/sdt.h> 72212054Snwhitehorn#include <sys/file.h> 73255910Snwhitehorn#include <sys/vfs.h> 74212054Snwhitehorn#include <sys/sysctl.h> 75212054Snwhitehorn#include <sys/sbuf.h> 76192067Snwhitehorn#include <sys/priv.h> 77212054Snwhitehorn#include <sys/kdb.h> 78212054Snwhitehorn#include <sys/ktr.h> 79212054Snwhitehorn#include <sys/stack.h> 80212054Snwhitehorn#include <sys/lockf.h> 81192067Snwhitehorn#include <sys/pathname.h> 82212054Snwhitehorn#include <sys/policy.h> 83262675Sjhibbits#include <sys/refstr.h> 84212054Snwhitehorn#include <sys/zone.h> 85246732Srpaulo#include <sys/eventhandler.h> 86192067Snwhitehorn#include <sys/extattr.h> 87192067Snwhitehorn#include <sys/misc.h> 88212054Snwhitehorn#include <sys/sig.h> 89212054Snwhitehorn#include <sys/osd.h> 90212054Snwhitehorn#include <sys/sysevent/dev.h> 91192067Snwhitehorn#include <sys/sysevent/eventdefs.h> 92192067Snwhitehorn#include <sys/u8_textprep.h> 93192067Snwhitehorn#include <sys/fm/util.h> 94212054Snwhitehorn#include <sys/sunddi.h> 95192067Snwhitehorn#ifdef illumos 96192067Snwhitehorn#include <sys/cyclic.h> 97212054Snwhitehorn#endif 98192067Snwhitehorn#include <sys/callo.h> 99255420Snwhitehorn#include <sys/disp.h> 100255420Snwhitehorn#include <machine/stdarg.h> 101255420Snwhitehorn 102255420Snwhitehorn#include <vm/vm.h> 103192067Snwhitehorn#include <vm/vm_page.h> 104255420Snwhitehorn#include <vm/vm_object.h> 105255420Snwhitehorn#include <vm/vm_kern.h> 106255420Snwhitehorn#include <vm/vm_map.h> 107255420Snwhitehorn#include <vm/vm_extern.h> 108255420Snwhitehorn#include <vm/vnode_pager.h> 109255420Snwhitehorn 110255420Snwhitehorn#define boot_ncpus (mp_ncpus) 111255420Snwhitehorn 112255420Snwhitehorn#define CPU_SEQID (curcpu) 113255420Snwhitehorn 114255420Snwhitehorn#define tsd_create(keyp, destructor) do { \ 115255420Snwhitehorn *(keyp) = osd_thread_register((destructor)); \ 116192067Snwhitehorn KASSERT(*(keyp) > 0, ("cannot register OSD")); \ 117192067Snwhitehorn} while (0) 118192067Snwhitehorn#define tsd_destroy(keyp) osd_thread_deregister(*(keyp)) 119192067Snwhitehorn#define tsd_get(key) osd_thread_get(curthread, (key)) 120266020Sian#define tsd_set(key, value) osd_thread_set(curthread, (key), (value)) 121266020Sian 122192067Snwhitehorn#ifdef __cplusplus 123266020Sian} 124266020Sian#endif 125266020Sian 126266020Sianextern int zfs_debug_level; 127266020Sianextern struct mtx zfs_debug_mtx; 128266020Sian#define ZFS_LOG(lvl, ...) do { \ 129266020Sian if (((lvl) & 0xff) <= zfs_debug_level) { \ 130266020Sian mtx_lock(&zfs_debug_mtx); \ 131266020Sian printf("%s:%u[%d]: ", __func__, __LINE__, (lvl)); \ 132266020Sian printf(__VA_ARGS__); \ 133266020Sian printf("\n"); \ 134266020Sian if ((lvl) & 0x100) \ 135266020Sian kdb_backtrace(); \ 136266020Sian mtx_unlock(&zfs_debug_mtx); \ 137266020Sian } \ 138266020Sian} while (0) 139266020Sian 140266020Sian#define sys_shutdown rebooting 141266020Sian 142266020Sian#define noinline __attribute__((noinline)) 143266020Sian#define likely(x) __builtin_expect((x), 1) 144266020Sian 145266020Sian#endif /* _SYS_ZFS_CONTEXT_H */ 146266020Sian