Print this page
2619 asynchronous destruction of ZFS file systems
2747 SPA versioning with zfs feature flags
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <gwilson@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>
Approved by: Dan McDonald <danmcd@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/dmu.c
          +++ new/usr/src/uts/common/fs/zfs/dmu.c
↓ 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 (c) 2012 by Delphix. All rights reserved.
  23   24   */
  24   25  
  25   26  #include <sys/dmu.h>
  26   27  #include <sys/dmu_impl.h>
  27   28  #include <sys/dmu_tx.h>
  28   29  #include <sys/dbuf.h>
  29   30  #include <sys/dnode.h>
  30   31  #include <sys/zfs_context.h>
  31   32  #include <sys/dmu_objset.h>
  32   33  #include <sys/dmu_traverse.h>
↓ open down ↓ 6 lines elided ↑ open up ↑
  39   40  #include <sys/zfs_ioctl.h>
  40   41  #include <sys/zap.h>
  41   42  #include <sys/zio_checksum.h>
  42   43  #include <sys/sa.h>
  43   44  #ifdef _KERNEL
  44   45  #include <sys/vmsystm.h>
  45   46  #include <sys/zfs_znode.h>
  46   47  #endif
  47   48  
  48   49  const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES] = {
  49      -        {       byteswap_uint8_array,   TRUE,   "unallocated"           },
  50      -        {       zap_byteswap,           TRUE,   "object directory"      },
  51      -        {       byteswap_uint64_array,  TRUE,   "object array"          },
  52      -        {       byteswap_uint8_array,   TRUE,   "packed nvlist"         },
  53      -        {       byteswap_uint64_array,  TRUE,   "packed nvlist size"    },
  54      -        {       byteswap_uint64_array,  TRUE,   "bpobj"                 },
  55      -        {       byteswap_uint64_array,  TRUE,   "bpobj header"          },
  56      -        {       byteswap_uint64_array,  TRUE,   "SPA space map header"  },
  57      -        {       byteswap_uint64_array,  TRUE,   "SPA space map"         },
  58      -        {       byteswap_uint64_array,  TRUE,   "ZIL intent log"        },
  59      -        {       dnode_buf_byteswap,     TRUE,   "DMU dnode"             },
  60      -        {       dmu_objset_byteswap,    TRUE,   "DMU objset"            },
  61      -        {       byteswap_uint64_array,  TRUE,   "DSL directory"         },
  62      -        {       zap_byteswap,           TRUE,   "DSL directory child map"},
  63      -        {       zap_byteswap,           TRUE,   "DSL dataset snap map"  },
  64      -        {       zap_byteswap,           TRUE,   "DSL props"             },
  65      -        {       byteswap_uint64_array,  TRUE,   "DSL dataset"           },
  66      -        {       zfs_znode_byteswap,     TRUE,   "ZFS znode"             },
  67      -        {       zfs_oldacl_byteswap,    TRUE,   "ZFS V0 ACL"            },
  68      -        {       byteswap_uint8_array,   FALSE,  "ZFS plain file"        },
  69      -        {       zap_byteswap,           TRUE,   "ZFS directory"         },
  70      -        {       zap_byteswap,           TRUE,   "ZFS master node"       },
  71      -        {       zap_byteswap,           TRUE,   "ZFS delete queue"      },
  72      -        {       byteswap_uint8_array,   FALSE,  "zvol object"           },
  73      -        {       zap_byteswap,           TRUE,   "zvol prop"             },
  74      -        {       byteswap_uint8_array,   FALSE,  "other uint8[]"         },
  75      -        {       byteswap_uint64_array,  FALSE,  "other uint64[]"        },
  76      -        {       zap_byteswap,           TRUE,   "other ZAP"             },
  77      -        {       zap_byteswap,           TRUE,   "persistent error log"  },
  78      -        {       byteswap_uint8_array,   TRUE,   "SPA history"           },
  79      -        {       byteswap_uint64_array,  TRUE,   "SPA history offsets"   },
  80      -        {       zap_byteswap,           TRUE,   "Pool properties"       },
  81      -        {       zap_byteswap,           TRUE,   "DSL permissions"       },
  82      -        {       zfs_acl_byteswap,       TRUE,   "ZFS ACL"               },
  83      -        {       byteswap_uint8_array,   TRUE,   "ZFS SYSACL"            },
  84      -        {       byteswap_uint8_array,   TRUE,   "FUID table"            },
  85      -        {       byteswap_uint64_array,  TRUE,   "FUID table size"       },
  86      -        {       zap_byteswap,           TRUE,   "DSL dataset next clones"},
  87      -        {       zap_byteswap,           TRUE,   "scan work queue"       },
  88      -        {       zap_byteswap,           TRUE,   "ZFS user/group used"   },
  89      -        {       zap_byteswap,           TRUE,   "ZFS user/group quota"  },
  90      -        {       zap_byteswap,           TRUE,   "snapshot refcount tags"},
  91      -        {       zap_byteswap,           TRUE,   "DDT ZAP algorithm"     },
  92      -        {       zap_byteswap,           TRUE,   "DDT statistics"        },
  93      -        {       byteswap_uint8_array,   TRUE,   "System attributes"     },
  94      -        {       zap_byteswap,           TRUE,   "SA master node"        },
  95      -        {       zap_byteswap,           TRUE,   "SA attr registration"  },
  96      -        {       zap_byteswap,           TRUE,   "SA attr layouts"       },
  97      -        {       zap_byteswap,           TRUE,   "scan translations"     },
  98      -        {       byteswap_uint8_array,   FALSE,  "deduplicated block"    },
  99      -        {       zap_byteswap,           TRUE,   "DSL deadlist map"      },
 100      -        {       byteswap_uint64_array,  TRUE,   "DSL deadlist map hdr"  },
 101      -        {       zap_byteswap,           TRUE,   "DSL dir clones"        },
 102      -        {       byteswap_uint64_array,  TRUE,   "bpobj subobj"          },
       50 +        {       DMU_BSWAP_UINT8,        TRUE,   "unallocated"           },
       51 +        {       DMU_BSWAP_ZAP,          TRUE,   "object directory"      },
       52 +        {       DMU_BSWAP_UINT64,       TRUE,   "object array"          },
       53 +        {       DMU_BSWAP_UINT8,        TRUE,   "packed nvlist"         },
       54 +        {       DMU_BSWAP_UINT64,       TRUE,   "packed nvlist size"    },
       55 +        {       DMU_BSWAP_UINT64,       TRUE,   "bpobj"                 },
       56 +        {       DMU_BSWAP_UINT64,       TRUE,   "bpobj header"          },
       57 +        {       DMU_BSWAP_UINT64,       TRUE,   "SPA space map header"  },
       58 +        {       DMU_BSWAP_UINT64,       TRUE,   "SPA space map"         },
       59 +        {       DMU_BSWAP_UINT64,       TRUE,   "ZIL intent log"        },
       60 +        {       DMU_BSWAP_DNODE,        TRUE,   "DMU dnode"             },
       61 +        {       DMU_BSWAP_OBJSET,       TRUE,   "DMU objset"            },
       62 +        {       DMU_BSWAP_UINT64,       TRUE,   "DSL directory"         },
       63 +        {       DMU_BSWAP_ZAP,          TRUE,   "DSL directory child map"},
       64 +        {       DMU_BSWAP_ZAP,          TRUE,   "DSL dataset snap map"  },
       65 +        {       DMU_BSWAP_ZAP,          TRUE,   "DSL props"             },
       66 +        {       DMU_BSWAP_UINT64,       TRUE,   "DSL dataset"           },
       67 +        {       DMU_BSWAP_ZNODE,        TRUE,   "ZFS znode"             },
       68 +        {       DMU_BSWAP_OLDACL,       TRUE,   "ZFS V0 ACL"            },
       69 +        {       DMU_BSWAP_UINT8,        FALSE,  "ZFS plain file"        },
       70 +        {       DMU_BSWAP_ZAP,          TRUE,   "ZFS directory"         },
       71 +        {       DMU_BSWAP_ZAP,          TRUE,   "ZFS master node"       },
       72 +        {       DMU_BSWAP_ZAP,          TRUE,   "ZFS delete queue"      },
       73 +        {       DMU_BSWAP_UINT8,        FALSE,  "zvol object"           },
       74 +        {       DMU_BSWAP_ZAP,          TRUE,   "zvol prop"             },
       75 +        {       DMU_BSWAP_UINT8,        FALSE,  "other uint8[]"         },
       76 +        {       DMU_BSWAP_UINT64,       FALSE,  "other uint64[]"        },
       77 +        {       DMU_BSWAP_ZAP,          TRUE,   "other ZAP"             },
       78 +        {       DMU_BSWAP_ZAP,          TRUE,   "persistent error log"  },
       79 +        {       DMU_BSWAP_UINT8,        TRUE,   "SPA history"           },
       80 +        {       DMU_BSWAP_UINT64,       TRUE,   "SPA history offsets"   },
       81 +        {       DMU_BSWAP_ZAP,          TRUE,   "Pool properties"       },
       82 +        {       DMU_BSWAP_ZAP,          TRUE,   "DSL permissions"       },
       83 +        {       DMU_BSWAP_ACL,          TRUE,   "ZFS ACL"               },
       84 +        {       DMU_BSWAP_UINT8,        TRUE,   "ZFS SYSACL"            },
       85 +        {       DMU_BSWAP_UINT8,        TRUE,   "FUID table"            },
       86 +        {       DMU_BSWAP_UINT64,       TRUE,   "FUID table size"       },
       87 +        {       DMU_BSWAP_ZAP,          TRUE,   "DSL dataset next clones"},
       88 +        {       DMU_BSWAP_ZAP,          TRUE,   "scan work queue"       },
       89 +        {       DMU_BSWAP_ZAP,          TRUE,   "ZFS user/group used"   },
       90 +        {       DMU_BSWAP_ZAP,          TRUE,   "ZFS user/group quota"  },
       91 +        {       DMU_BSWAP_ZAP,          TRUE,   "snapshot refcount tags"},
       92 +        {       DMU_BSWAP_ZAP,          TRUE,   "DDT ZAP algorithm"     },
       93 +        {       DMU_BSWAP_ZAP,          TRUE,   "DDT statistics"        },
       94 +        {       DMU_BSWAP_UINT8,        TRUE,   "System attributes"     },
       95 +        {       DMU_BSWAP_ZAP,          TRUE,   "SA master node"        },
       96 +        {       DMU_BSWAP_ZAP,          TRUE,   "SA attr registration"  },
       97 +        {       DMU_BSWAP_ZAP,          TRUE,   "SA attr layouts"       },
       98 +        {       DMU_BSWAP_ZAP,          TRUE,   "scan translations"     },
       99 +        {       DMU_BSWAP_UINT8,        FALSE,  "deduplicated block"    },
      100 +        {       DMU_BSWAP_ZAP,          TRUE,   "DSL deadlist map"      },
      101 +        {       DMU_BSWAP_UINT64,       TRUE,   "DSL deadlist map hdr"  },
      102 +        {       DMU_BSWAP_ZAP,          TRUE,   "DSL dir clones"        },
      103 +        {       DMU_BSWAP_UINT64,       TRUE,   "bpobj subobj"          }
 103  104  };
 104  105  
      106 +const dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS] = {
      107 +        {       byteswap_uint8_array,   "uint8"         },
      108 +        {       byteswap_uint16_array,  "uint16"        },
      109 +        {       byteswap_uint32_array,  "uint32"        },
      110 +        {       byteswap_uint64_array,  "uint64"        },
      111 +        {       zap_byteswap,           "zap"           },
      112 +        {       dnode_buf_byteswap,     "dnode"         },
      113 +        {       dmu_objset_byteswap,    "objset"        },
      114 +        {       zfs_znode_byteswap,     "znode"         },
      115 +        {       zfs_oldacl_byteswap,    "oldacl"        },
      116 +        {       zfs_acl_byteswap,       "acl"           }
      117 +};
      118 +
 105  119  int
 106  120  dmu_buf_hold(objset_t *os, uint64_t object, uint64_t offset,
 107  121      void *tag, dmu_buf_t **dbp, int flags)
 108  122  {
 109  123          dnode_t *dn;
 110  124          uint64_t blkid;
 111  125          dmu_buf_impl_t *db;
 112  126          int err;
 113  127          int db_flags = DB_RF_CANFAIL;
 114  128  
↓ open down ↓ 54 lines elided ↑ open up ↑
 169  183  int
 170  184  dmu_set_bonustype(dmu_buf_t *db_fake, dmu_object_type_t type, dmu_tx_t *tx)
 171  185  {
 172  186          dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
 173  187          dnode_t *dn;
 174  188          int error;
 175  189  
 176  190          DB_DNODE_ENTER(db);
 177  191          dn = DB_DNODE(db);
 178  192  
 179      -        if (type > DMU_OT_NUMTYPES) {
      193 +        if (!DMU_OT_IS_VALID(type)) {
 180  194                  error = EINVAL;
 181  195          } else if (dn->dn_bonus != db) {
 182  196                  error = EINVAL;
 183  197          } else {
 184  198                  dnode_setbonus_type(dn, type, tx);
 185  199                  error = 0;
 186  200          }
 187  201  
 188  202          DB_DNODE_EXIT(db);
 189  203          return (error);
↓ open down ↓ 1306 lines elided ↑ open up ↑
1496 1510          dnode_setdirty(dn, tx);
1497 1511          dnode_rele(dn, FTAG);
1498 1512  }
1499 1513  
1500 1514  int zfs_mdcomp_disable = 0;
1501 1515  
1502 1516  void
1503 1517  dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, zio_prop_t *zp)
1504 1518  {
1505 1519          dmu_object_type_t type = dn ? dn->dn_type : DMU_OT_OBJSET;
1506      -        boolean_t ismd = (level > 0 || dmu_ot[type].ot_metadata ||
     1520 +        boolean_t ismd = (level > 0 || DMU_OT_IS_METADATA(type) ||
1507 1521              (wp & WP_SPILL));
1508 1522          enum zio_checksum checksum = os->os_checksum;
1509 1523          enum zio_compress compress = os->os_compress;
1510 1524          enum zio_checksum dedup_checksum = os->os_dedup_checksum;
1511 1525          boolean_t dedup;
1512 1526          boolean_t dedup_verify = os->os_dedup_verify;
1513 1527          int copies = os->os_copies;
1514 1528  
1515 1529          /*
1516 1530           * Determine checksum setting.
↓ open down ↓ 248 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX