Print this page
3525 Persistent L2ARC


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2012 by Delphix. All rights reserved.
  24  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.

  25  */
  26 
  27 #ifndef _SYS_SPA_H
  28 #define _SYS_SPA_H
  29 
  30 #include <sys/avl.h>
  31 #include <sys/zfs_context.h>
  32 #include <sys/nvpair.h>
  33 #include <sys/sysmacros.h>
  34 #include <sys/types.h>
  35 #include <sys/fs/zfs.h>
  36 
  37 #ifdef  __cplusplus
  38 extern "C" {
  39 #endif
  40 
  41 /*
  42  * Forward references that lots of things need.
  43  */
  44 typedef struct spa spa_t;


 275         (DVA_GET_GANG(&(bp)->blk_dva[0]) + \
 276         DVA_GET_GANG(&(bp)->blk_dva[1]) + \
 277         DVA_GET_GANG(&(bp)->blk_dva[2]))
 278 
 279 #define DVA_EQUAL(dva1, dva2)   \
 280         ((dva1)->dva_word[1] == (dva2)->dva_word[1] && \
 281         (dva1)->dva_word[0] == (dva2)->dva_word[0])
 282 
 283 #define BP_EQUAL(bp1, bp2)      \
 284         (BP_PHYSICAL_BIRTH(bp1) == BP_PHYSICAL_BIRTH(bp2) &&    \
 285         DVA_EQUAL(&(bp1)->blk_dva[0], &(bp2)->blk_dva[0]) &&      \
 286         DVA_EQUAL(&(bp1)->blk_dva[1], &(bp2)->blk_dva[1]) &&      \
 287         DVA_EQUAL(&(bp1)->blk_dva[2], &(bp2)->blk_dva[2]))
 288 
 289 #define ZIO_CHECKSUM_EQUAL(zc1, zc2) \
 290         (0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \
 291         ((zc1).zc_word[1] - (zc2).zc_word[1]) | \
 292         ((zc1).zc_word[2] - (zc2).zc_word[2]) | \
 293         ((zc1).zc_word[3] - (zc2).zc_word[3])))
 294 











 295 #define DVA_IS_VALID(dva)       (DVA_GET_ASIZE(dva) != 0)
 296 
 297 #define ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3)   \
 298 {                                               \
 299         (zcp)->zc_word[0] = w0;                      \
 300         (zcp)->zc_word[1] = w1;                      \
 301         (zcp)->zc_word[2] = w2;                      \
 302         (zcp)->zc_word[3] = w3;                      \
 303 }
 304 
 305 #define BP_IDENTITY(bp)         (&(bp)->blk_dva[0])
 306 #define BP_IS_GANG(bp)          DVA_GET_GANG(BP_IDENTITY(bp))
 307 #define BP_IS_HOLE(bp)          ((bp)->blk_birth == 0)
 308 
 309 /* BP_IS_RAIDZ(bp) assumes no block compression */
 310 #define BP_IS_RAIDZ(bp)         (DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \
 311                                 BP_GET_PSIZE(bp))
 312 
 313 #define BP_ZERO(bp)                             \
 314 {                                               \


 428 extern int spa_export(char *pool, nvlist_t **oldconfig, boolean_t force,
 429     boolean_t hardforce);
 430 extern int spa_reset(char *pool);
 431 extern void spa_async_request(spa_t *spa, int flag);
 432 extern void spa_async_unrequest(spa_t *spa, int flag);
 433 extern void spa_async_suspend(spa_t *spa);
 434 extern void spa_async_resume(spa_t *spa);
 435 extern spa_t *spa_inject_addref(char *pool);
 436 extern void spa_inject_delref(spa_t *spa);
 437 extern void spa_scan_stat_init(spa_t *spa);
 438 extern int spa_scan_get_stats(spa_t *spa, pool_scan_stat_t *ps);
 439 
 440 #define SPA_ASYNC_CONFIG_UPDATE 0x01
 441 #define SPA_ASYNC_REMOVE        0x02
 442 #define SPA_ASYNC_PROBE         0x04
 443 #define SPA_ASYNC_RESILVER_DONE 0x08
 444 #define SPA_ASYNC_RESILVER      0x10
 445 #define SPA_ASYNC_AUTOEXPAND    0x20
 446 #define SPA_ASYNC_REMOVE_DONE   0x40
 447 #define SPA_ASYNC_REMOVE_STOP   0x80

 448 
 449 /*
 450  * Controls the behavior of spa_vdev_remove().
 451  */
 452 #define SPA_REMOVE_UNSPARE      0x01
 453 #define SPA_REMOVE_DONE         0x02
 454 
 455 /* device manipulation */
 456 extern int spa_vdev_add(spa_t *spa, nvlist_t *nvroot);
 457 extern int spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot,
 458     int replacing);
 459 extern int spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid,
 460     int replace_done);
 461 extern int spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare);
 462 extern boolean_t spa_vdev_remove_active(spa_t *spa);
 463 extern int spa_vdev_setpath(spa_t *spa, uint64_t guid, const char *newpath);
 464 extern int spa_vdev_setfru(spa_t *spa, uint64_t guid, const char *newfru);
 465 extern int spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
 466     nvlist_t *props, boolean_t exp);
 467 




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2012 by Delphix. All rights reserved.
  24  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  25  * Copyright 2013 Saso Kiselkov. All rights reserved.
  26  */
  27 
  28 #ifndef _SYS_SPA_H
  29 #define _SYS_SPA_H
  30 
  31 #include <sys/avl.h>
  32 #include <sys/zfs_context.h>
  33 #include <sys/nvpair.h>
  34 #include <sys/sysmacros.h>
  35 #include <sys/types.h>
  36 #include <sys/fs/zfs.h>
  37 
  38 #ifdef  __cplusplus
  39 extern "C" {
  40 #endif
  41 
  42 /*
  43  * Forward references that lots of things need.
  44  */
  45 typedef struct spa spa_t;


 276         (DVA_GET_GANG(&(bp)->blk_dva[0]) + \
 277         DVA_GET_GANG(&(bp)->blk_dva[1]) + \
 278         DVA_GET_GANG(&(bp)->blk_dva[2]))
 279 
 280 #define DVA_EQUAL(dva1, dva2)   \
 281         ((dva1)->dva_word[1] == (dva2)->dva_word[1] && \
 282         (dva1)->dva_word[0] == (dva2)->dva_word[0])
 283 
 284 #define BP_EQUAL(bp1, bp2)      \
 285         (BP_PHYSICAL_BIRTH(bp1) == BP_PHYSICAL_BIRTH(bp2) &&    \
 286         DVA_EQUAL(&(bp1)->blk_dva[0], &(bp2)->blk_dva[0]) &&      \
 287         DVA_EQUAL(&(bp1)->blk_dva[1], &(bp2)->blk_dva[1]) &&      \
 288         DVA_EQUAL(&(bp1)->blk_dva[2], &(bp2)->blk_dva[2]))
 289 
 290 #define ZIO_CHECKSUM_EQUAL(zc1, zc2) \
 291         (0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \
 292         ((zc1).zc_word[1] - (zc2).zc_word[1]) | \
 293         ((zc1).zc_word[2] - (zc2).zc_word[2]) | \
 294         ((zc1).zc_word[3] - (zc2).zc_word[3])))
 295 
 296 #define ZIO_CHECKSUM_BSWAP(_zc) \
 297         do { \
 298                 zio_cksum_t *zc = (_zc); \
 299                 zc->zc_word[0] = BSWAP_64(zc->zc_word[0]); \
 300                 zc->zc_word[1] = BSWAP_64(zc->zc_word[1]); \
 301                 zc->zc_word[2] = BSWAP_64(zc->zc_word[2]); \
 302                 zc->zc_word[3] = BSWAP_64(zc->zc_word[3]); \
 303                 _NOTE(NOTREACHED) \
 304                 _NOTE(CONSTCOND) \
 305         } while (0)
 306 
 307 #define DVA_IS_VALID(dva)       (DVA_GET_ASIZE(dva) != 0)
 308 
 309 #define ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3)   \
 310 {                                               \
 311         (zcp)->zc_word[0] = w0;                      \
 312         (zcp)->zc_word[1] = w1;                      \
 313         (zcp)->zc_word[2] = w2;                      \
 314         (zcp)->zc_word[3] = w3;                      \
 315 }
 316 
 317 #define BP_IDENTITY(bp)         (&(bp)->blk_dva[0])
 318 #define BP_IS_GANG(bp)          DVA_GET_GANG(BP_IDENTITY(bp))
 319 #define BP_IS_HOLE(bp)          ((bp)->blk_birth == 0)
 320 
 321 /* BP_IS_RAIDZ(bp) assumes no block compression */
 322 #define BP_IS_RAIDZ(bp)         (DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \
 323                                 BP_GET_PSIZE(bp))
 324 
 325 #define BP_ZERO(bp)                             \
 326 {                                               \


 440 extern int spa_export(char *pool, nvlist_t **oldconfig, boolean_t force,
 441     boolean_t hardforce);
 442 extern int spa_reset(char *pool);
 443 extern void spa_async_request(spa_t *spa, int flag);
 444 extern void spa_async_unrequest(spa_t *spa, int flag);
 445 extern void spa_async_suspend(spa_t *spa);
 446 extern void spa_async_resume(spa_t *spa);
 447 extern spa_t *spa_inject_addref(char *pool);
 448 extern void spa_inject_delref(spa_t *spa);
 449 extern void spa_scan_stat_init(spa_t *spa);
 450 extern int spa_scan_get_stats(spa_t *spa, pool_scan_stat_t *ps);
 451 
 452 #define SPA_ASYNC_CONFIG_UPDATE         0x01
 453 #define SPA_ASYNC_REMOVE                0x02
 454 #define SPA_ASYNC_PROBE                 0x04
 455 #define SPA_ASYNC_RESILVER_DONE         0x08
 456 #define SPA_ASYNC_RESILVER              0x10
 457 #define SPA_ASYNC_AUTOEXPAND            0x20
 458 #define SPA_ASYNC_REMOVE_DONE           0x40
 459 #define SPA_ASYNC_REMOVE_STOP           0x80
 460 #define SPA_ASYNC_L2CACHE_REBUILD       0x100
 461 
 462 /*
 463  * Controls the behavior of spa_vdev_remove().
 464  */
 465 #define SPA_REMOVE_UNSPARE      0x01
 466 #define SPA_REMOVE_DONE         0x02
 467 
 468 /* device manipulation */
 469 extern int spa_vdev_add(spa_t *spa, nvlist_t *nvroot);
 470 extern int spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot,
 471     int replacing);
 472 extern int spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid,
 473     int replace_done);
 474 extern int spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare);
 475 extern boolean_t spa_vdev_remove_active(spa_t *spa);
 476 extern int spa_vdev_setpath(spa_t *spa, uint64_t guid, const char *newpath);
 477 extern int spa_vdev_setfru(spa_t *spa, uint64_t guid, const char *newfru);
 478 extern int spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
 479     nvlist_t *props, boolean_t exp);
 480