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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/metaslab.c
          +++ new/usr/src/uts/common/fs/zfs/metaslab.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) 2013 by Delphix. All rights reserved.
       23 + * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
  24   24   * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  25   25   */
  26   26  
  27   27  #include <sys/zfs_context.h>
  28   28  #include <sys/dmu.h>
  29   29  #include <sys/dmu_tx.h>
  30   30  #include <sys/space_map.h>
  31   31  #include <sys/metaslab_impl.h>
  32   32  #include <sys/vdev_impl.h>
  33   33  #include <sys/zio.h>
↓ open down ↓ 652 lines elided ↑ open up ↑
 686  686  metaslab_ff_alloc(metaslab_t *msp, uint64_t size)
 687  687  {
 688  688          /*
 689  689           * Find the largest power of 2 block size that evenly divides the
 690  690           * requested size. This is used to try to allocate blocks with similar
 691  691           * alignment from the same area of the metaslab (i.e. same cursor
 692  692           * bucket) but it does not guarantee that other allocations sizes
 693  693           * may exist in the same region.
 694  694           */
 695  695          uint64_t align = size & -size;
 696      -        uint64_t *cursor = &msp->ms_lbas[highbit(align) - 1];
      696 +        uint64_t *cursor = &msp->ms_lbas[highbit64(align) - 1];
 697  697          avl_tree_t *t = &msp->ms_tree->rt_root;
 698  698  
 699  699          return (metaslab_block_picker(t, cursor, size, align));
 700  700  }
 701  701  
 702  702  /* ARGSUSED */
 703  703  static boolean_t
 704  704  metaslab_ff_fragmented(metaslab_t *msp)
 705  705  {
 706  706          return (B_TRUE);
↓ open down ↓ 16 lines elided ↑ open up ↑
 723  723  metaslab_df_alloc(metaslab_t *msp, uint64_t size)
 724  724  {
 725  725          /*
 726  726           * Find the largest power of 2 block size that evenly divides the
 727  727           * requested size. This is used to try to allocate blocks with similar
 728  728           * alignment from the same area of the metaslab (i.e. same cursor
 729  729           * bucket) but it does not guarantee that other allocations sizes
 730  730           * may exist in the same region.
 731  731           */
 732  732          uint64_t align = size & -size;
 733      -        uint64_t *cursor = &msp->ms_lbas[highbit(align) - 1];
      733 +        uint64_t *cursor = &msp->ms_lbas[highbit64(align) - 1];
 734  734          range_tree_t *rt = msp->ms_tree;
 735  735          avl_tree_t *t = &rt->rt_root;
 736  736          uint64_t max_size = metaslab_block_maxsize(msp);
 737  737          int free_pct = range_tree_space(rt) * 100 / msp->ms_size;
 738  738  
 739  739          ASSERT(MUTEX_HELD(&msp->ms_lock));
 740  740          ASSERT3U(avl_numnodes(t), ==, avl_numnodes(&msp->ms_size_tree));
 741  741  
 742  742          if (max_size < size)
 743  743                  return (-1ULL);
↓ open down ↓ 95 lines elided ↑ open up ↑
 839  839   * to request from the allocator.
 840  840   */
 841  841  uint64_t metaslab_ndf_clump_shift = 4;
 842  842  
 843  843  static uint64_t
 844  844  metaslab_ndf_alloc(metaslab_t *msp, uint64_t size)
 845  845  {
 846  846          avl_tree_t *t = &msp->ms_tree->rt_root;
 847  847          avl_index_t where;
 848  848          range_seg_t *rs, rsearch;
 849      -        uint64_t hbit = highbit(size);
      849 +        uint64_t hbit = highbit64(size);
 850  850          uint64_t *cursor = &msp->ms_lbas[hbit - 1];
 851  851          uint64_t max_size = metaslab_block_maxsize(msp);
 852  852  
 853  853          ASSERT(MUTEX_HELD(&msp->ms_lock));
 854  854          ASSERT3U(avl_numnodes(t), ==, avl_numnodes(&msp->ms_size_tree));
 855  855  
 856  856          if (max_size < size)
 857  857                  return (-1ULL);
 858  858  
 859  859          rsearch.rs_start = *cursor;
↓ open down ↓ 222 lines elided ↑ open up ↑
1082 1082          int i;
1083 1083  
1084 1084          /*
1085 1085           * A null space map means that the entire metaslab is free,
1086 1086           * calculate a weight factor that spans the entire size of the
1087 1087           * metaslab.
1088 1088           */
1089 1089          if (msp->ms_sm == NULL) {
1090 1090                  vdev_t *vd = msp->ms_group->mg_vd;
1091 1091  
1092      -                i = highbit(msp->ms_size) - 1;
     1092 +                i = highbit64(msp->ms_size) - 1;
1093 1093                  sectors = msp->ms_size >> vd->vdev_ashift;
1094 1094                  return (sectors * i * vd->vdev_ashift);
1095 1095          }
1096 1096  
1097 1097          if (msp->ms_sm->sm_dbuf->db_size != sizeof (space_map_phys_t))
1098 1098                  return (0);
1099 1099  
1100 1100          for (i = 0; i < SPACE_MAP_HISTOGRAM_SIZE(msp->ms_sm); i++) {
1101 1101                  if (msp->ms_sm->sm_phys->smp_histogram[i] == 0)
1102 1102                          continue;
↓ open down ↓ 1114 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX