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>


   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 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /*
  26  * Copyright (c) 2013 by Delphix. All rights reserved.
  27  */
  28 
  29 #include <sys/zfs_context.h>
  30 #include <sys/spa.h>
  31 #include <sys/dmu.h>
  32 #include <sys/dmu_tx.h>
  33 #include <sys/dnode.h>
  34 #include <sys/dsl_pool.h>
  35 #include <sys/zio.h>
  36 #include <sys/space_map.h>
  37 #include <sys/refcount.h>
  38 #include <sys/zfeature.h>
  39 
  40 /*
  41  * This value controls how the space map's block size is allowed to grow.
  42  * If the value is set to the same size as SPACE_MAP_INITIAL_BLOCKSIZE then
  43  * the space map block size will remain fixed. Setting this value to something
  44  * greater than SPACE_MAP_INITIAL_BLOCKSIZE will allow the space map to
  45  * increase its block size as needed. To maintain backwards compatibilty the
  46  * space map's block size must be a power of 2 and SPACE_MAP_INITIAL_BLOCKSIZE


 250         /*
 251          * The object contains more than one block so we can't adjust
 252          * its size.
 253          */
 254         if (sm->sm_phys->smp_objsize > sm->sm_blksz)
 255                 return;
 256 
 257         if (size > sm->sm_blksz) {
 258                 uint64_t newsz;
 259 
 260                 /*
 261                  * Older software versions treat space map blocks as fixed
 262                  * entities. The DMU is capable of handling different block
 263                  * sizes making it possible for us to increase the
 264                  * block size and maintain backwards compatibility. The
 265                  * caveat is that the new block sizes must be a
 266                  * power of 2 so that old software can append to the file,
 267                  * adding more blocks. The block size can grow until it
 268                  * reaches space_map_max_blksz.
 269                  */
 270                 newsz = ISP2(size) ? size : 1ULL << highbit(size);
 271                 if (newsz > space_map_max_blksz)
 272                         newsz = space_map_max_blksz;
 273 
 274                 VERIFY0(dmu_object_set_blocksize(sm->sm_os,
 275                     space_map_object(sm), newsz, 0, tx));
 276                 dmu_object_size_from_db(sm->sm_dbuf, &blksz, &blocks);
 277 
 278                 zfs_dbgmsg("txg %llu, spa %s, increasing blksz from %d to %d",
 279                     dmu_tx_get_txg(tx), spa_name(dmu_objset_spa(sm->sm_os)),
 280                     sm->sm_blksz, blksz);
 281 
 282                 VERIFY3U(newsz, ==, blksz);
 283                 VERIFY3U(sm->sm_blksz, <, blksz);
 284                 sm->sm_blksz = blksz;
 285         }
 286 }
 287 
 288 /*
 289  * Note: space_map_write() will drop sm_lock across dmu_write() calls.
 290  */




   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 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /*
  26  * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  27  */
  28 
  29 #include <sys/zfs_context.h>
  30 #include <sys/spa.h>
  31 #include <sys/dmu.h>
  32 #include <sys/dmu_tx.h>
  33 #include <sys/dnode.h>
  34 #include <sys/dsl_pool.h>
  35 #include <sys/zio.h>
  36 #include <sys/space_map.h>
  37 #include <sys/refcount.h>
  38 #include <sys/zfeature.h>
  39 
  40 /*
  41  * This value controls how the space map's block size is allowed to grow.
  42  * If the value is set to the same size as SPACE_MAP_INITIAL_BLOCKSIZE then
  43  * the space map block size will remain fixed. Setting this value to something
  44  * greater than SPACE_MAP_INITIAL_BLOCKSIZE will allow the space map to
  45  * increase its block size as needed. To maintain backwards compatibilty the
  46  * space map's block size must be a power of 2 and SPACE_MAP_INITIAL_BLOCKSIZE


 250         /*
 251          * The object contains more than one block so we can't adjust
 252          * its size.
 253          */
 254         if (sm->sm_phys->smp_objsize > sm->sm_blksz)
 255                 return;
 256 
 257         if (size > sm->sm_blksz) {
 258                 uint64_t newsz;
 259 
 260                 /*
 261                  * Older software versions treat space map blocks as fixed
 262                  * entities. The DMU is capable of handling different block
 263                  * sizes making it possible for us to increase the
 264                  * block size and maintain backwards compatibility. The
 265                  * caveat is that the new block sizes must be a
 266                  * power of 2 so that old software can append to the file,
 267                  * adding more blocks. The block size can grow until it
 268                  * reaches space_map_max_blksz.
 269                  */
 270                 newsz = ISP2(size) ? size : 1ULL << highbit64(size);
 271                 if (newsz > space_map_max_blksz)
 272                         newsz = space_map_max_blksz;
 273 
 274                 VERIFY0(dmu_object_set_blocksize(sm->sm_os,
 275                     space_map_object(sm), newsz, 0, tx));
 276                 dmu_object_size_from_db(sm->sm_dbuf, &blksz, &blocks);
 277 
 278                 zfs_dbgmsg("txg %llu, spa %s, increasing blksz from %d to %d",
 279                     dmu_tx_get_txg(tx), spa_name(dmu_objset_spa(sm->sm_os)),
 280                     sm->sm_blksz, blksz);
 281 
 282                 VERIFY3U(newsz, ==, blksz);
 283                 VERIFY3U(sm->sm_blksz, <, blksz);
 284                 sm->sm_blksz = blksz;
 285         }
 286 }
 287 
 288 /*
 289  * Note: space_map_write() will drop sm_lock across dmu_write() calls.
 290  */