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 2013 Nexenta Systems, Inc.  All rights reserved.
  14  */
  15 
  16 #ifndef _SYS_COS_H
  17 #define _SYS_COS_H
  18 
  19 #include <sys/avl.h>
  20 #include <sys/zfs_context.h>
  21 #include <sys/nvpair.h>
  22 #include <sys/sysmacros.h>
  23 #include <sys/types.h>
  24 #include <sys/fs/zfs.h>
  25 
  26 #ifdef  __cplusplus
  27 extern "C" {
  28 #endif
  29 
  30 /*
  31  * This is the interface to SPA Class Of Storage related functionality.
  32  * For more details, see comments in cos_impl.h
  33  */
  34 
  35 /*
  36  * Macros for conversion between zio priorities and vdev properties.
  37  * These rely on the specific corresponding order of the zio_priority_t
  38  * and cos_prop_t enum definitions to simplify the conversion.
  39  */
  40 #define COS_PROP_TO_ZIO_PRIO_MIN(prp)   ((prp) - COS_PROP_READ_MINACTIVE)
  41 #define COS_ZIO_PRIO_TO_PROP_MIN(pri)   ((pri) + COS_PROP_READ_MINACTIVE)
  42 #define COS_PROP_MIN_VALID(prp)                 \
  43         (((prp) >= COS_PROP_READ_MINACTIVE) &&       \
  44         ((prp) <= COS_PROP_SCRUB_MINACTIVE))
  45 #define COS_PROP_TO_ZIO_PRIO_MAX(prp)   ((prp) - COS_PROP_READ_MAXACTIVE)
  46 #define COS_ZIO_PRIO_TO_PROP_MAX(pri)   ((pri) + COS_PROP_READ_MAXACTIVE)
  47 #define COS_PROP_MAX_VALID(prp)                 \
  48         (((prp) >= COS_PROP_READ_MAXACTIVE) &&       \
  49         ((prp) <= COS_PROP_SCRUB_MAXACTIVE))
  50 
  51 /*
  52  * Forward declaration
  53  */
  54 typedef struct cos cos_t;
  55 
  56 void spa_cos_enter(spa_t *);
  57 void spa_cos_exit(spa_t *);
  58 void spa_cos_init(spa_t *);
  59 void spa_cos_fini(spa_t *);
  60 
  61 int spa_alloc_cos(spa_t *, const char *, uint64_t);
  62 int spa_free_cos(spa_t *, const char *, boolean_t);
  63 int spa_list_cos(spa_t *, nvlist_t *);
  64 int spa_cos_prop_set(spa_t *, const char *, nvlist_t *);
  65 int spa_cos_prop_get(spa_t *, const char *, nvlist_t **);
  66 
  67 cos_t *spa_lookup_cos_by_guid(spa_t *, uint64_t);
  68 cos_t *spa_lookup_cos_by_name(spa_t *, const char *);
  69 
  70 int spa_load_cos_props(spa_t *);
  71 
  72 void cos_hold(cos_t *cos);
  73 void cos_rele(cos_t *cos);
  74 
  75 uint64_t cos_get_prop_uint64(cos_t *cos, cos_prop_t p);
  76 
  77 #ifdef  __cplusplus
  78 }
  79 #endif
  80 
  81 #endif  /* _SYS_COS_H */