Print this page
    
NEX-13937 Improve kstat performance
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-10069 ZFS_READONLY is a little too strict (fix test lint)
NEX-9553 Move ss_fill gap logic from scan algorithm into range_tree.c
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-6088 ZFS scrub/resilver take excessively long due to issuing lots of random IO
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
6209 libc mutexes break kernel writers hearts
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Dan McDonald <danmcd@omniti.com>
NEX-4582 update wrc test cases for allow to use write back cache per tree of datasets
Reviewed by: Steve Peng <steve.peng@nexenta.com>
Reviewed by: Alex Aizman <alex.aizman@nexenta.com>
5960 zfs recv should prefetch indirect blocks
5925 zfs receive -o origin=
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
NEX-4229 Panic destroying the pool using file backing store on FS with nbmand=on
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-3541 Implement persistent L2ARC - fix build breakage in libzpool.
NEX-3508 CLONE - Port NEX-2946 Add UNMAP/TRIM functionality to ZFS and illumos
Reviewed by: Josef Sipek <josef.sipek@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Conflicts:
    usr/src/uts/common/io/scsi/targets/sd.c
    usr/src/uts/common/sys/scsi/targets/sddef.h
NEX-3079 port illumos ARC improvements
re #12393 rb3935 Kerberos and smbd disagree about who is our AD server (fix elf runtime attributes check)
re #11612 rb3907 Failing vdev of a mirrored pool should not take zfs operations out of action for extended periods of time.
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/lib/libzpool/common/sys/zfs_context.h
          +++ new/usr/src/lib/libzpool/common/sys/zfs_context.h
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  
    | 
      ↓ open down ↓ | 
    12 lines elided | 
    
      ↑ open up ↑ | 
  
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24   23   * Copyright (c) 2012, 2016 by Delphix. All rights reserved.
  25   24   * Copyright (c) 2012, Joyent, Inc. All rights reserved.
       25 + * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  26   26   * Copyright 2017 RackTop Systems.
  27   27   */
  28   28  
  29   29  #ifndef _SYS_ZFS_CONTEXT_H
  30   30  #define _SYS_ZFS_CONTEXT_H
  31   31  
  32   32  #ifdef  __cplusplus
  33   33  extern "C" {
  34   34  #endif
  35   35  
  36   36  #define _SYNCH_H
  37   37  
  38   38  #define _SYS_VNODE_H
  39   39  #define _SYS_VFS_H
  40   40  #define _SYS_CALLB_H
  41   41  
  42   42  #include <stdio.h>
  43   43  #include <stdlib.h>
  44   44  #include <stddef.h>
  45   45  #include <stdarg.h>
  46   46  #include <fcntl.h>
  47   47  #include <unistd.h>
  48   48  #include <errno.h>
  49   49  #include <string.h>
  50   50  #include <strings.h>
  51   51  #include <thread.h>
  52   52  #include <assert.h>
  53   53  #include <alloca.h>
  54   54  #include <umem.h>
  55   55  #include <limits.h>
  56   56  #include <atomic.h>
  57   57  #include <dirent.h>
  58   58  #include <time.h>
  59   59  #include <procfs.h>
  60   60  #include <pthread.h>
  61   61  #include <setjmp.h>
  62   62  #include <sys/debug.h>
  63   63  #include <libsysevent.h>
  64   64  #include <sys/note.h>
  65   65  #include <sys/types.h>
  66   66  #include <sys/cred.h>
  67   67  #include <sys/sysmacros.h>
  68   68  #include <sys/bitmap.h>
  69   69  #include <sys/resource.h>
  70   70  #include <sys/byteorder.h>
  71   71  #include <sys/list.h>
  72   72  #include <sys/uio.h>
  73   73  #include <sys/zfs_debug.h>
  74   74  #include <sys/sdt.h>
  75   75  #include <sys/kstat.h>
  76   76  #include <sys/u8_textprep.h>
  77   77  #include <sys/sysevent/eventdefs.h>
  78   78  #include <sys/sysevent/dev.h>
  79   79  #include <sys/debug.h>
  80   80  #include <sys/taskq.h>
  81   81  #include <sys/taskq_impl.h>
  82   82  #include <sys/mutex.h>
  83   83  #include <sys/proc.h>
  84   84  #include <sys/condvar.h>
  85   85  #include <sys/cmn_err.h>
  86   86  #include <sys/kmem.h>
  87   87  #include <sys/systm.h>
  88   88  #include <sys/random.h>
  89   89  #include <sys/buf.h>
  90   90  #include <sys/sid.h>
  91   91  #include <sys/acl.h>
  92   92  #include <sys/bitmap.h>
  93   93  #include <sys/systeminfo.h>
  94   94  #include <sys/cpuvar.h>
  95   95  #include <sys/pset.h>
  96   96  #include <sys/kobj.h>
  97   97  #include <sys/fm/util.h>
  98   98  #include "zfs.h"
  99   99  
 100  100  /*
 101  101   * ZFS debugging
 102  102   */
 103  103  
 104  104  #ifdef ZFS_DEBUG
 105  105  extern void dprintf_setup(int *argc, char **argv);
 106  106  #endif /* ZFS_DEBUG */
 107  107  
 108  108  /*
 109  109   * DTrace SDT probes have different signatures in userland than they do in
 110  110   * the kernel.  If they're being used in kernel code, re-define them out of
 111  111   * existence for their counterparts in libzpool.
 112  112   *
 113  113   * Here's an example of how to use the set-error probes in userland:
 114  114   * zfs$target:::set-error /arg0 == EBUSY/ {stack();}
 115  115   *
 116  116   * Here's an example of how to use DTRACE_PROBE probes in userland:
 117  117   * If there is a probe declared as follows:
 118  118   * DTRACE_PROBE2(zfs__probe_name, uint64_t, blkid, dnode_t *, dn);
 119  119   * Then you can use it as follows:
 120  120   * zfs$target:::probe2 /copyinstr(arg0) == "zfs__probe_name"/
 121  121   *     {printf("%u %p\n", arg1, arg2);}
 122  122   */
 123  123  
 124  124  #ifdef DTRACE_PROBE
 125  125  #undef  DTRACE_PROBE
 126  126  #endif  /* DTRACE_PROBE */
 127  127  #define DTRACE_PROBE(a) \
 128  128          ZFS_PROBE0(#a)
 129  129  
 130  130  #ifdef DTRACE_PROBE1
 131  131  #undef  DTRACE_PROBE1
 132  132  #endif  /* DTRACE_PROBE1 */
 133  133  #define DTRACE_PROBE1(a, b, c) \
 134  134          ZFS_PROBE1(#a, (unsigned long)c)
 135  135  
 136  136  #ifdef DTRACE_PROBE2
 137  137  #undef  DTRACE_PROBE2
 138  138  #endif  /* DTRACE_PROBE2 */
 139  139  #define DTRACE_PROBE2(a, b, c, d, e) \
 140  140          ZFS_PROBE2(#a, (unsigned long)c, (unsigned long)e)
 141  141  
 142  142  #ifdef DTRACE_PROBE3
 143  143  #undef  DTRACE_PROBE3
 144  144  #endif  /* DTRACE_PROBE3 */
 145  145  #define DTRACE_PROBE3(a, b, c, d, e, f, g) \
 146  146          ZFS_PROBE3(#a, (unsigned long)c, (unsigned long)e, (unsigned long)g)
 147  147  
 148  148  #ifdef DTRACE_PROBE4
 149  149  #undef  DTRACE_PROBE4
 150  150  #endif  /* DTRACE_PROBE4 */
 151  151  #define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) \
 152  152          ZFS_PROBE4(#a, (unsigned long)c, (unsigned long)e, (unsigned long)g, \
 153  153          (unsigned long)i)
 154  154  
 155  155  /*
 156  156   * We use the comma operator so that this macro can be used without much
 157  157   * additional code.  For example, "return (EINVAL);" becomes
 158  158   * "return (SET_ERROR(EINVAL));".  Note that the argument will be evaluated
 159  159   * twice, so it should not have side effects (e.g. something like:
 160  160   * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice).
 161  161   */
 162  162  #define SET_ERROR(err) (ZFS_SET_ERROR(err), err)
 163  163  
 164  164  /*
 165  165   * Threads
 166  166   */
 167  167  #define kpreempt(x)     yield()
 168  168  #define newproc(f, a, cid, pri, ctp, pid)       (ENOSYS)
 169  169  
 170  170  /*
 171  171   * vnodes
 172  172   */
 173  173  #define XVA_MAPSIZE     3
 174  174  #define XVA_MAGIC       0x78766174
 175  175  
 176  176  typedef struct vnode {
 177  177          uint64_t        v_size;
 178  178          int             v_fd;
 179  179          char            *v_path;
 180  180          int             v_dump_fd;
 181  181  } vnode_t;
 182  182  
 183  183  extern char *vn_dumpdir;
 184  184  #define AV_SCANSTAMP_SZ 32              /* length of anti-virus scanstamp */
 185  185  
 186  186  typedef struct xoptattr {
 187  187          timestruc_t     xoa_createtime; /* Create time of file */
 188  188          uint8_t         xoa_archive;
 189  189          uint8_t         xoa_system;
 190  190          uint8_t         xoa_readonly;
 191  191          uint8_t         xoa_hidden;
 192  192          uint8_t         xoa_nounlink;
 193  193          uint8_t         xoa_immutable;
 194  194          uint8_t         xoa_appendonly;
 195  195          uint8_t         xoa_nodump;
 196  196          uint8_t         xoa_settable;
 197  197          uint8_t         xoa_opaque;
 198  198          uint8_t         xoa_av_quarantined;
 199  199          uint8_t         xoa_av_modified;
 200  200          uint8_t         xoa_av_scanstamp[AV_SCANSTAMP_SZ];
 201  201          uint8_t         xoa_reparse;
 202  202          uint8_t         xoa_offline;
 203  203          uint8_t         xoa_sparse;
 204  204  } xoptattr_t;
 205  205  
 206  206  typedef struct vattr {
 207  207          uint_t          va_mask;        /* bit-mask of attributes */
 208  208          u_offset_t      va_size;        /* file size in bytes */
 209  209  } vattr_t;
 210  210  
 211  211  
 212  212  typedef struct xvattr {
 213  213          vattr_t         xva_vattr;      /* Embedded vattr structure */
 214  214          uint32_t        xva_magic;      /* Magic Number */
 215  215          uint32_t        xva_mapsize;    /* Size of attr bitmap (32-bit words) */
 216  216          uint32_t        *xva_rtnattrmapp;       /* Ptr to xva_rtnattrmap[] */
 217  217          uint32_t        xva_reqattrmap[XVA_MAPSIZE];    /* Requested attrs */
 218  218          uint32_t        xva_rtnattrmap[XVA_MAPSIZE];    /* Returned attrs */
 219  219          xoptattr_t      xva_xoptattrs;  /* Optional attributes */
 220  220  } xvattr_t;
 221  221  
 222  222  typedef struct vsecattr {
 223  223          uint_t          vsa_mask;       /* See below */
 224  224          int             vsa_aclcnt;     /* ACL entry count */
 225  225          void            *vsa_aclentp;   /* pointer to ACL entries */
 226  226          int             vsa_dfaclcnt;   /* default ACL entry count */
 227  227          void            *vsa_dfaclentp; /* pointer to default ACL entries */
 228  228          size_t          vsa_aclentsz;   /* ACE size in bytes of vsa_aclentp */
 229  229  } vsecattr_t;
 230  230  
 231  231  #define AT_TYPE         0x00001
 232  232  #define AT_MODE         0x00002
 233  233  #define AT_UID          0x00004
 234  234  #define AT_GID          0x00008
 235  235  #define AT_FSID         0x00010
 236  236  #define AT_NODEID       0x00020
 237  237  #define AT_NLINK        0x00040
  
    | 
      ↓ open down ↓ | 
    202 lines elided | 
    
      ↑ open up ↑ | 
  
 238  238  #define AT_SIZE         0x00080
 239  239  #define AT_ATIME        0x00100
 240  240  #define AT_MTIME        0x00200
 241  241  #define AT_CTIME        0x00400
 242  242  #define AT_RDEV         0x00800
 243  243  #define AT_BLKSIZE      0x01000
 244  244  #define AT_NBLOCKS      0x02000
 245  245  #define AT_SEQ          0x08000
 246  246  #define AT_XVATTR       0x10000
 247  247  
      248 +typedef struct caller_context {
      249 +        pid_t           cc_pid;         /* Process ID of the caller */
      250 +        int             cc_sysid;       /* System ID, used for remote calls */
      251 +        u_longlong_t    cc_caller_id;   /* Identifier for (set of) caller(s) */
      252 +        ulong_t         cc_flags;
      253 +} caller_context_t;
      254 +
 248  255  #define CRCREAT         0
 249  256  
 250  257  extern int fop_getattr(vnode_t *vp, vattr_t *vap);
 251  258  
 252  259  #define VOP_CLOSE(vp, f, c, o, cr, ct)  0
 253  260  #define VOP_PUTPAGE(vp, of, sz, fl, cr, ct)     0
 254  261  #define VOP_GETATTR(vp, vap, fl, cr, ct)  fop_getattr((vp), (vap));
 255  262  
 256  263  #define VOP_FSYNC(vp, f, cr, ct)        fsync((vp)->v_fd)
      264 +#define VOP_SPACE(vp, cmd, flck, fl, off, cr, ct) \
      265 +        fcntl((vp)->v_fd, cmd, (flck), sizeof (*(flck)))
 257  266  
 258  267  #define VN_RELE(vp)     vn_close(vp)
 259  268  
 260  269  extern int vn_open(char *path, int x1, int oflags, int mode, vnode_t **vpp,
 261  270      int x2, int x3);
 262  271  extern int vn_openat(char *path, int x1, int oflags, int mode, vnode_t **vpp,
 263  272      int x2, int x3, vnode_t *vp, int fd);
 264  273  extern int vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len,
 265  274      offset_t offset, int x1, int x2, rlim64_t x3, void *x4, ssize_t *residp);
 266  275  extern void vn_close(vnode_t *vp);
 267  276  
 268  277  #define vn_remove(path, x1, x2)         remove(path)
 269  278  #define vn_rename(from, to, seg)        rename((from), (to))
 270  279  #define vn_is_readonly(vp)              B_FALSE
 271  280  
 272  281  extern vnode_t *rootdir;
 273  282  
 274  283  #include <sys/file.h>           /* for FREAD, FWRITE, etc */
 275  284  #include <sys/sunddi.h>         /* for ddi_strtoul, ddi_strtoull, etc */
 276  285  #include <sys/cyclic.h>         /* for cyclic_add, cyclic remove, etc */
 277  286  #include <vm/seg_kmem.h>        /* for zio_arena */
 278  287  
 279  288  /*
 280  289   * Random stuff
 281  290   */
 282  291  #define max_ncpus       64
 283  292  #define boot_ncpus      (sysconf(_SC_NPROCESSORS_ONLN))
 284  293  
 285  294  #define minclsyspri     60
 286  295  #define maxclsyspri     99
 287  296  
 288  297  #define CPU_SEQID       (thr_self() & (max_ncpus - 1))
 289  298  
 290  299  extern void kernel_init(int);
 291  300  extern void kernel_fini(void);
 292  301  
 293  302  struct spa;
 294  303  extern void show_pool_stats(struct spa *);
 295  304  extern int set_global_var(char *arg);
 296  305  
 297  306  typedef struct callb_cpr {
 298  307          kmutex_t        *cc_lockp;
 299  308  } callb_cpr_t;
 300  309  
 301  310  #define CALLB_CPR_INIT(cp, lockp, func, name)   {               \
 302  311          (cp)->cc_lockp = lockp;                                 \
 303  312  }
 304  313  
 305  314  #define CALLB_CPR_SAFE_BEGIN(cp) {                              \
 306  315          ASSERT(MUTEX_HELD((cp)->cc_lockp));                     \
 307  316  }
 308  317  
 309  318  #define CALLB_CPR_SAFE_END(cp, lockp) {                         \
  
    | 
      ↓ open down ↓ | 
    43 lines elided | 
    
      ↑ open up ↑ | 
  
 310  319          ASSERT(MUTEX_HELD((cp)->cc_lockp));                     \
 311  320  }
 312  321  
 313  322  #define CALLB_CPR_EXIT(cp) {                                    \
 314  323          ASSERT(MUTEX_HELD((cp)->cc_lockp));                     \
 315  324          mutex_exit((cp)->cc_lockp);                             \
 316  325  }
 317  326  
 318  327  #define zone_dataset_visible(x, y)      (1)
 319  328  #define INGLOBALZONE(z)                 (1)
 320      -extern uint32_t zone_get_hostid(void *zonep);
 321  329  
 322  330  extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr);
 323  331  extern int zfs_secpolicy_rename_perms(const char *from, const char *to,
 324  332      cred_t *cr);
 325  333  extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr);
 326  334  
 327  335  #define ddi_log_sysevent(_a, _b, _c, _d, _e, _f, _g) \
 328  336          sysevent_post_event(_c, _d, _b, "libzpool", _e, _f)
 329  337  
 330  338  #ifdef  __cplusplus
 331  339  }
 332  340  #endif
 333  341  
 334  342  #endif  /* _SYS_ZFS_CONTEXT_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX