Print this page
4374 dn_free_ranges should use range_tree_t
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Max Grossman <max.grossman@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Dan McDonald <danmcd@omniti.com>


   4  * The contents of this file are subject to the terms of the
   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 /*
  23  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2013 by Delphix. All rights reserved.
  25  */
  26 
  27 #include <sys/zfs_context.h>
  28 #include <sys/spa.h>
  29 #include <sys/spa_impl.h>
  30 #include <sys/zio.h>
  31 #include <sys/ddt.h>
  32 #include <sys/zap.h>
  33 #include <sys/dmu_tx.h>
  34 #include <sys/arc.h>
  35 #include <sys/dsl_pool.h>
  36 #include <sys/zio_checksum.h>
  37 #include <sys/zio_compress.h>
  38 #include <sys/dsl_scan.h>
  39 
  40 /*
  41  * Enable/disable prefetching of dedup-ed blocks which are going to be freed.
  42  */
  43 int zfs_dedup_prefetch = 1;
  44 


 385 {
 386         const uint64_t *s = (const uint64_t *)src;
 387         uint64_t *d = (uint64_t *)dst;
 388         uint64_t *d_end = (uint64_t *)(dst + 1);
 389 
 390         ASSERT(neg == 0 || neg == -1ULL);       /* add or subtract */
 391 
 392         while (d < d_end)
 393                 *d++ += (*s++ ^ neg) - neg;
 394 }
 395 
 396 static void
 397 ddt_stat_update(ddt_t *ddt, ddt_entry_t *dde, uint64_t neg)
 398 {
 399         ddt_stat_t dds;
 400         ddt_histogram_t *ddh;
 401         int bucket;
 402 
 403         ddt_stat_generate(ddt, dde, &dds);
 404 
 405         bucket = highbit(dds.dds_ref_blocks) - 1;
 406         ASSERT(bucket >= 0);
 407 
 408         ddh = &ddt->ddt_histogram[dde->dde_type][dde->dde_class];
 409 
 410         ddt_stat_add(&ddh->ddh_stat[bucket], &dds, neg);
 411 }
 412 
 413 void
 414 ddt_histogram_add(ddt_histogram_t *dst, const ddt_histogram_t *src)
 415 {
 416         for (int h = 0; h < 64; h++)
 417                 ddt_stat_add(&dst->ddh_stat[h], &src->ddh_stat[h], 0);
 418 }
 419 
 420 void
 421 ddt_histogram_stat(ddt_stat_t *dds, const ddt_histogram_t *ddh)
 422 {
 423         bzero(dds, sizeof (*dds));
 424 
 425         for (int h = 0; h < 64; h++)




   4  * The contents of this file are subject to the terms of the
   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 /*
  23  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  25  */
  26 
  27 #include <sys/zfs_context.h>
  28 #include <sys/spa.h>
  29 #include <sys/spa_impl.h>
  30 #include <sys/zio.h>
  31 #include <sys/ddt.h>
  32 #include <sys/zap.h>
  33 #include <sys/dmu_tx.h>
  34 #include <sys/arc.h>
  35 #include <sys/dsl_pool.h>
  36 #include <sys/zio_checksum.h>
  37 #include <sys/zio_compress.h>
  38 #include <sys/dsl_scan.h>
  39 
  40 /*
  41  * Enable/disable prefetching of dedup-ed blocks which are going to be freed.
  42  */
  43 int zfs_dedup_prefetch = 1;
  44 


 385 {
 386         const uint64_t *s = (const uint64_t *)src;
 387         uint64_t *d = (uint64_t *)dst;
 388         uint64_t *d_end = (uint64_t *)(dst + 1);
 389 
 390         ASSERT(neg == 0 || neg == -1ULL);       /* add or subtract */
 391 
 392         while (d < d_end)
 393                 *d++ += (*s++ ^ neg) - neg;
 394 }
 395 
 396 static void
 397 ddt_stat_update(ddt_t *ddt, ddt_entry_t *dde, uint64_t neg)
 398 {
 399         ddt_stat_t dds;
 400         ddt_histogram_t *ddh;
 401         int bucket;
 402 
 403         ddt_stat_generate(ddt, dde, &dds);
 404 
 405         bucket = highbit64(dds.dds_ref_blocks) - 1;
 406         ASSERT(bucket >= 0);
 407 
 408         ddh = &ddt->ddt_histogram[dde->dde_type][dde->dde_class];
 409 
 410         ddt_stat_add(&ddh->ddh_stat[bucket], &dds, neg);
 411 }
 412 
 413 void
 414 ddt_histogram_add(ddt_histogram_t *dst, const ddt_histogram_t *src)
 415 {
 416         for (int h = 0; h < 64; h++)
 417                 ddt_stat_add(&dst->ddh_stat[h], &src->ddh_stat[h], 0);
 418 }
 419 
 420 void
 421 ddt_histogram_stat(ddt_stat_t *dds, const ddt_histogram_t *ddh)
 422 {
 423         bzero(dds, sizeof (*dds));
 424 
 425         for (int h = 0; h < 64; h++)