1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
  14  */
  15 
  16 /*
  17  * See special.c for details on the theory of operation
  18  */
  19 
  20 #ifndef _SYS_SPECIAL_H
  21 #define _SYS_SPECIAL_H
  22 
  23 #include <sys/sysmacros.h>
  24 #include <sys/types.h>
  25 #include <sys/fs/zfs.h>
  26 #include <sys/spa.h>
  27 #include <sys/zio.h>
  28 
  29 #ifdef  __cplusplus
  30 extern "C" {
  31 #endif
  32 
  33 #define META_PLACEMENT_OFF      0
  34 #define META_PLACEMENT_ON       1
  35 #define META_PLACEMENT_DUAL     2
  36 
  37 #define SYNC_TO_SPECIAL_DISABLED        0
  38 #define SYNC_TO_SPECIAL_STANDARD        1
  39 #define SYNC_TO_SPECIAL_BALANCED        2
  40 #define SYNC_TO_SPECIAL_ALWAYS          3
  41 
  42 void spa_special_init(spa_t *spa);
  43 void spa_special_fini(spa_t *spa);
  44 void spa_check_special(spa_t *);
  45 boolean_t spa_write_data_to_special(spa_t *, objset_t *);
  46 boolean_t spa_can_special_be_used(spa_t *spa);
  47 void spa_special_check_errors(spa_t *spa);
  48 int spa_special_vdev_remove(spa_t *spa, vdev_t *vd, uint64_t *txg);
  49 
  50 /* currently there are 2 flags */
  51 enum specialflagbit {
  52         /* 2 bits - data type */
  53         SPECIAL_FLAGBIT_DATAUSER,
  54         SPECIAL_FLAGBIT_DATAMETA,
  55 
  56         SPECIAL_NUM_FLAGBITS
  57 };
  58 
  59 #define SPECIAL_FLAG_DATAUSER   (1ULL << SPECIAL_FLAGBIT_DATAUSER)
  60 #define SPECIAL_FLAG_DATAMETA   (1ULL << SPECIAL_FLAGBIT_DATAMETA)
  61 
  62 #define SPECIAL_FLAGSMASK       ((1ULL << SPECIAL_NUM_FLAGBITS) - 1)
  63 
  64 /* only meta data on special */
  65 #define SPECIAL_META_FLAGS      (SPECIAL_FLAG_DATAMETA)
  66 #define SPECIAL_META_MASK       (0)
  67 
  68 /* both meta and user data on special */
  69 #define SPECIAL_WRCACHE_FLAGS   (SPECIAL_FLAG_DATAUSER | SPECIAL_FLAG_DATAMETA)
  70 #define SPECIAL_WRCACHE_MASK    (SPECIAL_FLAG_DATAUSER | SPECIAL_FLAG_DATAMETA)
  71 
  72 metaslab_class_t *spa_select_class(spa_t *spa, zio_t *zio);
  73 
  74 #ifdef  __cplusplus
  75 }
  76 #endif
  77 
  78 #endif  /* _SYS_SPECIAL_H */