metaslab.c (262093) | metaslab.c (265740) |
---|---|
1/* 2 * CDDL HEADER START 3 * 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 --- 6 unchanged lines hidden (view full) --- 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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. | 1/* 2 * CDDL HEADER START 3 * 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 --- 6 unchanged lines hidden (view full) --- 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 (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 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. 25 */ 26 27#include <sys/zfs_context.h> 28#include <sys/dmu.h> 29#include <sys/dmu_tx.h> 30#include <sys/space_map.h> 31#include <sys/metaslab_impl.h> --- 752 unchanged lines hidden (view full) --- 784 /* 785 * Find the largest power of 2 block size that evenly divides the 786 * requested size. This is used to try to allocate blocks with similar 787 * alignment from the same area of the metaslab (i.e. same cursor 788 * bucket) but it does not guarantee that other allocations sizes 789 * may exist in the same region. 790 */ 791 uint64_t align = size & -size; | 24 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. 25 */ 26 27#include <sys/zfs_context.h> 28#include <sys/dmu.h> 29#include <sys/dmu_tx.h> 30#include <sys/space_map.h> 31#include <sys/metaslab_impl.h> --- 752 unchanged lines hidden (view full) --- 784 /* 785 * Find the largest power of 2 block size that evenly divides the 786 * requested size. This is used to try to allocate blocks with similar 787 * alignment from the same area of the metaslab (i.e. same cursor 788 * bucket) but it does not guarantee that other allocations sizes 789 * may exist in the same region. 790 */ 791 uint64_t align = size & -size; |
792 uint64_t *cursor = &msp->ms_lbas[highbit(align) - 1]; | 792 uint64_t *cursor = &msp->ms_lbas[highbit64(align) - 1]; |
793 avl_tree_t *t = &msp->ms_tree->rt_root; 794 795 return (metaslab_block_picker(t, cursor, size, align)); 796} 797 798/* ARGSUSED */ 799static boolean_t 800metaslab_ff_fragmented(metaslab_t *msp) --- 20 unchanged lines hidden (view full) --- 821 /* 822 * Find the largest power of 2 block size that evenly divides the 823 * requested size. This is used to try to allocate blocks with similar 824 * alignment from the same area of the metaslab (i.e. same cursor 825 * bucket) but it does not guarantee that other allocations sizes 826 * may exist in the same region. 827 */ 828 uint64_t align = size & -size; | 793 avl_tree_t *t = &msp->ms_tree->rt_root; 794 795 return (metaslab_block_picker(t, cursor, size, align)); 796} 797 798/* ARGSUSED */ 799static boolean_t 800metaslab_ff_fragmented(metaslab_t *msp) --- 20 unchanged lines hidden (view full) --- 821 /* 822 * Find the largest power of 2 block size that evenly divides the 823 * requested size. This is used to try to allocate blocks with similar 824 * alignment from the same area of the metaslab (i.e. same cursor 825 * bucket) but it does not guarantee that other allocations sizes 826 * may exist in the same region. 827 */ 828 uint64_t align = size & -size; |
829 uint64_t *cursor = &msp->ms_lbas[highbit(align) - 1]; | 829 uint64_t *cursor = &msp->ms_lbas[highbit64(align) - 1]; |
830 range_tree_t *rt = msp->ms_tree; 831 avl_tree_t *t = &rt->rt_root; 832 uint64_t max_size = metaslab_block_maxsize(msp); 833 int free_pct = range_tree_space(rt) * 100 / msp->ms_size; 834 835 ASSERT(MUTEX_HELD(&msp->ms_lock)); 836 ASSERT3U(avl_numnodes(t), ==, avl_numnodes(&msp->ms_size_tree)); 837 --- 99 unchanged lines hidden (view full) --- 937uint64_t metaslab_ndf_clump_shift = 4; 938 939static uint64_t 940metaslab_ndf_alloc(metaslab_t *msp, uint64_t size) 941{ 942 avl_tree_t *t = &msp->ms_tree->rt_root; 943 avl_index_t where; 944 range_seg_t *rs, rsearch; | 830 range_tree_t *rt = msp->ms_tree; 831 avl_tree_t *t = &rt->rt_root; 832 uint64_t max_size = metaslab_block_maxsize(msp); 833 int free_pct = range_tree_space(rt) * 100 / msp->ms_size; 834 835 ASSERT(MUTEX_HELD(&msp->ms_lock)); 836 ASSERT3U(avl_numnodes(t), ==, avl_numnodes(&msp->ms_size_tree)); 837 --- 99 unchanged lines hidden (view full) --- 937uint64_t metaslab_ndf_clump_shift = 4; 938 939static uint64_t 940metaslab_ndf_alloc(metaslab_t *msp, uint64_t size) 941{ 942 avl_tree_t *t = &msp->ms_tree->rt_root; 943 avl_index_t where; 944 range_seg_t *rs, rsearch; |
945 uint64_t hbit = highbit(size); | 945 uint64_t hbit = highbit64(size); |
946 uint64_t *cursor = &msp->ms_lbas[hbit - 1]; 947 uint64_t max_size = metaslab_block_maxsize(msp); 948 949 ASSERT(MUTEX_HELD(&msp->ms_lock)); 950 ASSERT3U(avl_numnodes(t), ==, avl_numnodes(&msp->ms_size_tree)); 951 952 if (max_size < size) 953 return (-1ULL); --- 226 unchanged lines hidden (view full) --- 1180 /* 1181 * A null space map means that the entire metaslab is free, 1182 * calculate a weight factor that spans the entire size of the 1183 * metaslab. 1184 */ 1185 if (msp->ms_sm == NULL) { 1186 vdev_t *vd = msp->ms_group->mg_vd; 1187 | 946 uint64_t *cursor = &msp->ms_lbas[hbit - 1]; 947 uint64_t max_size = metaslab_block_maxsize(msp); 948 949 ASSERT(MUTEX_HELD(&msp->ms_lock)); 950 ASSERT3U(avl_numnodes(t), ==, avl_numnodes(&msp->ms_size_tree)); 951 952 if (max_size < size) 953 return (-1ULL); --- 226 unchanged lines hidden (view full) --- 1180 /* 1181 * A null space map means that the entire metaslab is free, 1182 * calculate a weight factor that spans the entire size of the 1183 * metaslab. 1184 */ 1185 if (msp->ms_sm == NULL) { 1186 vdev_t *vd = msp->ms_group->mg_vd; 1187 |
1188 i = highbit(msp->ms_size) - 1; | 1188 i = highbit64(msp->ms_size) - 1; |
1189 sectors = msp->ms_size >> vd->vdev_ashift; 1190 return (sectors * i * vd->vdev_ashift); 1191 } 1192 1193 if (msp->ms_sm->sm_dbuf->db_size != sizeof (space_map_phys_t)) 1194 return (0); 1195 1196 for (i = 0; i < SPACE_MAP_HISTOGRAM_SIZE(msp->ms_sm); i++) { --- 1116 unchanged lines hidden --- | 1189 sectors = msp->ms_size >> vd->vdev_ashift; 1190 return (sectors * i * vd->vdev_ashift); 1191 } 1192 1193 if (msp->ms_sm->sm_dbuf->db_size != sizeof (space_map_phys_t)) 1194 return (0); 1195 1196 for (i = 0; i < SPACE_MAP_HISTOGRAM_SIZE(msp->ms_sm); i++) { --- 1116 unchanged lines hidden --- |