Print this page
3748 zfs headers should be C++ compatible
Submitted by:   Justin Gibbs <justing@spectralogic.com>
Submitted by:   Will Andrews <willa@spectralogic.com>
Reviewed by:    Matthew Ahrens <mahrens@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/zio.c
          +++ new/usr/src/uts/common/fs/zfs/zio.c
↓ open down ↓ 501 lines elided ↑ open up ↑
 502  502                  zio->io_error = zio->io_child_error[c];
 503  503  }
 504  504  
 505  505  /*
 506  506   * ==========================================================================
 507  507   * Create the various types of I/O (read, write, free, etc)
 508  508   * ==========================================================================
 509  509   */
 510  510  static zio_t *
 511  511  zio_create(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp,
 512      -    void *data, uint64_t size, zio_done_func_t *done, void *private,
      512 +    void *data, uint64_t size, zio_done_func_t *done, void *io_private,
 513  513      zio_type_t type, int priority, enum zio_flag flags,
 514  514      vdev_t *vd, uint64_t offset, const zbookmark_t *zb,
 515  515      enum zio_stage stage, enum zio_stage pipeline)
 516  516  {
 517  517          zio_t *zio;
 518  518  
 519  519          ASSERT3U(size, <=, SPA_MAXBLOCKSIZE);
 520  520          ASSERT(P2PHASE(size, SPA_MINBLOCKSIZE) == 0);
 521  521          ASSERT(P2PHASE(offset, SPA_MINBLOCKSIZE) == 0);
 522  522  
↓ open down ↓ 30 lines elided ↑ open up ↑
 553  553                          zio->io_bp = &zio->io_bp_copy;  /* so caller can free */
 554  554                  if (zio->io_child_type == ZIO_CHILD_LOGICAL)
 555  555                          zio->io_logical = zio;
 556  556                  if (zio->io_child_type > ZIO_CHILD_GANG && BP_IS_GANG(bp))
 557  557                          pipeline |= ZIO_GANG_STAGES;
 558  558          }
 559  559  
 560  560          zio->io_spa = spa;
 561  561          zio->io_txg = txg;
 562  562          zio->io_done = done;
 563      -        zio->io_private = private;
      563 +        zio->io_private = io_private;
 564  564          zio->io_type = type;
 565  565          zio->io_priority = priority;
 566  566          zio->io_vd = vd;
 567  567          zio->io_offset = offset;
 568  568          zio->io_orig_data = zio->io_data = data;
 569  569          zio->io_orig_size = zio->io_size = size;
 570  570          zio->io_orig_flags = zio->io_flags = flags;
 571  571          zio->io_orig_stage = zio->io_stage = stage;
 572  572          zio->io_orig_pipeline = zio->io_pipeline = pipeline;
 573  573  
↓ open down ↓ 19 lines elided ↑ open up ↑
 593  593  {
 594  594          list_destroy(&zio->io_parent_list);
 595  595          list_destroy(&zio->io_child_list);
 596  596          mutex_destroy(&zio->io_lock);
 597  597          cv_destroy(&zio->io_cv);
 598  598          kmem_cache_free(zio_cache, zio);
 599  599  }
 600  600  
 601  601  zio_t *
 602  602  zio_null(zio_t *pio, spa_t *spa, vdev_t *vd, zio_done_func_t *done,
 603      -    void *private, enum zio_flag flags)
      603 +    void *io_private, enum zio_flag flags)
 604  604  {
 605  605          zio_t *zio;
 606  606  
 607      -        zio = zio_create(pio, spa, 0, NULL, NULL, 0, done, private,
      607 +        zio = zio_create(pio, spa, 0, NULL, NULL, 0, done, io_private,
 608  608              ZIO_TYPE_NULL, ZIO_PRIORITY_NOW, flags, vd, 0, NULL,
 609  609              ZIO_STAGE_OPEN, ZIO_INTERLOCK_PIPELINE);
 610  610  
 611  611          return (zio);
 612  612  }
 613  613  
 614  614  zio_t *
 615      -zio_root(spa_t *spa, zio_done_func_t *done, void *private, enum zio_flag flags)
      615 +zio_root(spa_t *spa, zio_done_func_t *done, void *io_private,
      616 +    enum zio_flag flags)
 616  617  {
 617      -        return (zio_null(NULL, spa, NULL, done, private, flags));
      618 +        return (zio_null(NULL, spa, NULL, done, io_private, flags));
 618  619  }
 619  620  
 620  621  zio_t *
 621  622  zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
 622      -    void *data, uint64_t size, zio_done_func_t *done, void *private,
      623 +    void *data, uint64_t size, zio_done_func_t *done, void *io_private,
 623  624      int priority, enum zio_flag flags, const zbookmark_t *zb)
 624  625  {
 625  626          zio_t *zio;
 626  627  
 627  628          zio = zio_create(pio, spa, BP_PHYSICAL_BIRTH(bp), bp,
 628      -            data, size, done, private,
      629 +            data, size, done, io_private,
 629  630              ZIO_TYPE_READ, priority, flags, NULL, 0, zb,
 630  631              ZIO_STAGE_OPEN, (flags & ZIO_FLAG_DDT_CHILD) ?
 631  632              ZIO_DDT_CHILD_READ_PIPELINE : ZIO_READ_PIPELINE);
 632  633  
 633  634          return (zio);
 634  635  }
 635  636  
 636  637  zio_t *
 637  638  zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
 638  639      void *data, uint64_t size, const zio_prop_t *zp,
 639      -    zio_done_func_t *ready, zio_done_func_t *done, void *private,
      640 +    zio_done_func_t *ready, zio_done_func_t *done, void *io_private,
 640  641      int priority, enum zio_flag flags, const zbookmark_t *zb)
 641  642  {
 642  643          zio_t *zio;
 643  644  
 644  645          ASSERT(zp->zp_checksum >= ZIO_CHECKSUM_OFF &&
 645  646              zp->zp_checksum < ZIO_CHECKSUM_FUNCTIONS &&
 646  647              zp->zp_compress >= ZIO_COMPRESS_OFF &&
 647  648              zp->zp_compress < ZIO_COMPRESS_FUNCTIONS &&
 648  649              DMU_OT_IS_VALID(zp->zp_type) &&
 649  650              zp->zp_level < 32 &&
 650  651              zp->zp_copies > 0 &&
 651  652              zp->zp_copies <= spa_max_replication(spa));
 652  653  
 653      -        zio = zio_create(pio, spa, txg, bp, data, size, done, private,
      654 +        zio = zio_create(pio, spa, txg, bp, data, size, done, io_private,
 654  655              ZIO_TYPE_WRITE, priority, flags, NULL, 0, zb,
 655  656              ZIO_STAGE_OPEN, (flags & ZIO_FLAG_DDT_CHILD) ?
 656  657              ZIO_DDT_CHILD_WRITE_PIPELINE : ZIO_WRITE_PIPELINE);
 657  658  
 658  659          zio->io_ready = ready;
 659  660          zio->io_prop = *zp;
 660  661  
 661  662          return (zio);
 662  663  }
 663  664  
 664  665  zio_t *
 665  666  zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, void *data,
 666      -    uint64_t size, zio_done_func_t *done, void *private, int priority,
      667 +    uint64_t size, zio_done_func_t *done, void *io_private, int priority,
 667  668      enum zio_flag flags, zbookmark_t *zb)
 668  669  {
 669  670          zio_t *zio;
 670  671  
 671      -        zio = zio_create(pio, spa, txg, bp, data, size, done, private,
      672 +        zio = zio_create(pio, spa, txg, bp, data, size, done, io_private,
 672  673              ZIO_TYPE_WRITE, priority, flags, NULL, 0, zb,
 673  674              ZIO_STAGE_OPEN, ZIO_REWRITE_PIPELINE);
 674  675  
 675  676          return (zio);
 676  677  }
 677  678  
 678  679  void
 679  680  zio_write_override(zio_t *zio, blkptr_t *bp, int copies, boolean_t nopwrite)
 680  681  {
 681  682          ASSERT(zio->io_type == ZIO_TYPE_WRITE);
↓ open down ↓ 36 lines elided ↑ open up ↑
 718  719  
 719  720          zio = zio_create(pio, spa, txg, bp, NULL, BP_GET_PSIZE(bp),
 720  721              NULL, NULL, ZIO_TYPE_FREE, ZIO_PRIORITY_FREE, flags,
 721  722              NULL, 0, NULL, ZIO_STAGE_OPEN, ZIO_FREE_PIPELINE);
 722  723  
 723  724          return (zio);
 724  725  }
 725  726  
 726  727  zio_t *
 727  728  zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp,
 728      -    zio_done_func_t *done, void *private, enum zio_flag flags)
      729 +    zio_done_func_t *done, void *io_private, enum zio_flag flags)
 729  730  {
 730  731          zio_t *zio;
 731  732  
 732  733          /*
 733  734           * A claim is an allocation of a specific block.  Claims are needed
 734  735           * to support immediate writes in the intent log.  The issue is that
 735  736           * immediate writes contain committed data, but in a txg that was
 736  737           * *not* committed.  Upon opening the pool after an unclean shutdown,
 737  738           * the intent log claims all blocks that contain immediate write data
 738  739           * so that the SPA knows they're in use.
 739  740           *
 740  741           * All claims *must* be resolved in the first txg -- before the SPA
 741  742           * starts allocating blocks -- so that nothing is allocated twice.
 742  743           * If txg == 0 we just verify that the block is claimable.
 743  744           */
 744  745          ASSERT3U(spa->spa_uberblock.ub_rootbp.blk_birth, <, spa_first_txg(spa));
 745  746          ASSERT(txg == spa_first_txg(spa) || txg == 0);
 746  747          ASSERT(!BP_GET_DEDUP(bp) || !spa_writeable(spa));       /* zdb(1M) */
 747  748  
 748  749          zio = zio_create(pio, spa, txg, bp, NULL, BP_GET_PSIZE(bp),
 749      -            done, private, ZIO_TYPE_CLAIM, ZIO_PRIORITY_NOW, flags,
      750 +            done, io_private, ZIO_TYPE_CLAIM, ZIO_PRIORITY_NOW, flags,
 750  751              NULL, 0, NULL, ZIO_STAGE_OPEN, ZIO_CLAIM_PIPELINE);
 751  752  
 752  753          return (zio);
 753  754  }
 754  755  
 755  756  zio_t *
 756  757  zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd,
 757      -    zio_done_func_t *done, void *private, int priority, enum zio_flag flags)
      758 +    zio_done_func_t *done, void *io_private, int priority, enum zio_flag flags)
 758  759  {
 759  760          zio_t *zio;
 760  761          int c;
 761  762  
 762  763          if (vd->vdev_children == 0) {
 763      -                zio = zio_create(pio, spa, 0, NULL, NULL, 0, done, private,
      764 +                zio = zio_create(pio, spa, 0, NULL, NULL, 0, done, io_private,
 764  765                      ZIO_TYPE_IOCTL, priority, flags, vd, 0, NULL,
 765  766                      ZIO_STAGE_OPEN, ZIO_IOCTL_PIPELINE);
 766  767  
 767  768                  zio->io_cmd = cmd;
 768  769          } else {
 769  770                  zio = zio_null(pio, spa, NULL, NULL, NULL, flags);
 770  771  
 771  772                  for (c = 0; c < vd->vdev_children; c++)
 772  773                          zio_nowait(zio_ioctl(zio, spa, vd->vdev_child[c], cmd,
 773      -                            done, private, priority, flags));
      774 +                            done, io_private, priority, flags));
 774  775          }
 775  776  
 776  777          return (zio);
 777  778  }
 778  779  
 779  780  zio_t *
 780  781  zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset, uint64_t size,
 781      -    void *data, int checksum, zio_done_func_t *done, void *private,
      782 +    void *data, int checksum, zio_done_func_t *done, void *io_private,
 782  783      int priority, enum zio_flag flags, boolean_t labels)
 783  784  {
 784  785          zio_t *zio;
 785  786  
 786  787          ASSERT(vd->vdev_children == 0);
 787  788          ASSERT(!labels || offset + size <= VDEV_LABEL_START_SIZE ||
 788  789              offset >= vd->vdev_psize - VDEV_LABEL_END_SIZE);
 789  790          ASSERT3U(offset + size, <=, vd->vdev_psize);
 790  791  
 791      -        zio = zio_create(pio, vd->vdev_spa, 0, NULL, data, size, done, private,
 792      -            ZIO_TYPE_READ, priority, flags, vd, offset, NULL,
      792 +        zio = zio_create(pio, vd->vdev_spa, 0, NULL, data, size, done,
      793 +            io_private, ZIO_TYPE_READ, priority, flags, vd, offset, NULL,
 793  794              ZIO_STAGE_OPEN, ZIO_READ_PHYS_PIPELINE);
 794  795  
 795  796          zio->io_prop.zp_checksum = checksum;
 796  797  
 797  798          return (zio);
 798  799  }
 799  800  
 800  801  zio_t *
 801  802  zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset, uint64_t size,
 802      -    void *data, int checksum, zio_done_func_t *done, void *private,
      803 +    void *data, int checksum, zio_done_func_t *done, void *io_private,
 803  804      int priority, enum zio_flag flags, boolean_t labels)
 804  805  {
 805  806          zio_t *zio;
 806  807  
 807  808          ASSERT(vd->vdev_children == 0);
 808  809          ASSERT(!labels || offset + size <= VDEV_LABEL_START_SIZE ||
 809  810              offset >= vd->vdev_psize - VDEV_LABEL_END_SIZE);
 810  811          ASSERT3U(offset + size, <=, vd->vdev_psize);
 811  812  
 812      -        zio = zio_create(pio, vd->vdev_spa, 0, NULL, data, size, done, private,
 813      -            ZIO_TYPE_WRITE, priority, flags, vd, offset, NULL,
      813 +        zio = zio_create(pio, vd->vdev_spa, 0, NULL, data, size, done,
      814 +            io_private, ZIO_TYPE_WRITE, priority, flags, vd, offset, NULL,
 814  815              ZIO_STAGE_OPEN, ZIO_WRITE_PHYS_PIPELINE);
 815  816  
 816  817          zio->io_prop.zp_checksum = checksum;
 817  818  
 818  819          if (zio_checksum_table[checksum].ci_eck) {
 819  820                  /*
 820  821                   * zec checksums are necessarily destructive -- they modify
 821  822                   * the end of the write buffer to hold the verifier/checksum.
 822  823                   * Therefore, we must make a local copy in case the data is
 823  824                   * being written to multiple places in parallel.
↓ open down ↓ 5 lines elided ↑ open up ↑
 829  830  
 830  831          return (zio);
 831  832  }
 832  833  
 833  834  /*
 834  835   * Create a child I/O to do some work for us.
 835  836   */
 836  837  zio_t *
 837  838  zio_vdev_child_io(zio_t *pio, blkptr_t *bp, vdev_t *vd, uint64_t offset,
 838  839          void *data, uint64_t size, int type, int priority, enum zio_flag flags,
 839      -        zio_done_func_t *done, void *private)
      840 +        zio_done_func_t *done, void *io_private)
 840  841  {
 841  842          enum zio_stage pipeline = ZIO_VDEV_CHILD_PIPELINE;
 842  843          zio_t *zio;
 843  844  
 844  845          ASSERT(vd->vdev_parent ==
 845  846              (pio->io_vd ? pio->io_vd : pio->io_spa->spa_root_vdev));
 846  847  
 847  848          if (type == ZIO_TYPE_READ && bp != NULL) {
 848  849                  /*
 849  850                   * If we have the bp, then the child should perform the
↓ open down ↓ 11 lines elided ↑ open up ↑
 861  862          flags |= ZIO_VDEV_CHILD_FLAGS(pio) | ZIO_FLAG_DONT_PROPAGATE;
 862  863  
 863  864          /*
 864  865           * If we've decided to do a repair, the write is not speculative --
 865  866           * even if the original read was.
 866  867           */
 867  868          if (flags & ZIO_FLAG_IO_REPAIR)
 868  869                  flags &= ~ZIO_FLAG_SPECULATIVE;
 869  870  
 870  871          zio = zio_create(pio, pio->io_spa, pio->io_txg, bp, data, size,
 871      -            done, private, type, priority, flags, vd, offset, &pio->io_bookmark,
 872      -            ZIO_STAGE_VDEV_IO_START >> 1, pipeline);
      872 +            done, io_private, type, priority, flags, vd, offset,
      873 +            &pio->io_bookmark, ZIO_STAGE_VDEV_IO_START >> 1, pipeline);
 873  874  
 874  875          return (zio);
 875  876  }
 876  877  
 877  878  zio_t *
 878  879  zio_vdev_delegated_io(vdev_t *vd, uint64_t offset, void *data, uint64_t size,
 879  880          int type, int priority, enum zio_flag flags,
 880      -        zio_done_func_t *done, void *private)
      881 +        zio_done_func_t *done, void *io_private)
 881  882  {
 882  883          zio_t *zio;
 883  884  
 884  885          ASSERT(vd->vdev_ops->vdev_op_leaf);
 885  886  
 886  887          zio = zio_create(NULL, vd->vdev_spa, 0, NULL,
 887      -            data, size, done, private, type, priority,
      888 +            data, size, done, io_private, type, priority,
 888  889              flags | ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_RETRY,
 889  890              vd, offset, NULL,
 890  891              ZIO_STAGE_VDEV_IO_START >> 1, ZIO_VDEV_CHILD_PIPELINE);
 891  892  
 892  893          return (zio);
 893  894  }
 894  895  
 895  896  void
 896  897  zio_flush(zio_t *zio, vdev_t *vd)
 897  898  {
↓ open down ↓ 2256 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX