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>


   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
   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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2012 by Delphix. All rights reserved.
  24  * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
  25  */
  26 
  27 #include <assert.h>
  28 #include <fcntl.h>
  29 #include <poll.h>
  30 #include <stdio.h>
  31 #include <stdlib.h>
  32 #include <string.h>
  33 #include <zlib.h>
  34 #include <sys/spa.h>
  35 #include <sys/stat.h>
  36 #include <sys/processor.h>
  37 #include <sys/zfs_context.h>
  38 #include <sys/rrwlock.h>
  39 #include <sys/zmod.h>
  40 #include <sys/utsname.h>
  41 #include <sys/systeminfo.h>
  42 
  43 /*


 755         }
 756         *size = st.st_size;
 757         return (0);
 758 }
 759 
 760 /*
 761  * =========================================================================
 762  * misc routines
 763  * =========================================================================
 764  */
 765 
 766 void
 767 delay(clock_t ticks)
 768 {
 769         poll(0, 0, ticks * (1000 / hz));
 770 }
 771 
 772 /*
 773  * Find highest one bit set.
 774  *      Returns bit number + 1 of highest bit that is set, otherwise returns 0.
 775  * High order bit is 31 (or 63 in _LP64 kernel).
 776  */
 777 int
 778 highbit(ulong_t i)
 779 {
 780         register int h = 1;
 781 
 782         if (i == 0)
 783                 return (0);
 784 #ifdef _LP64
 785         if (i & 0xffffffff00000000ul) {
 786                 h += 32; i >>= 32;
 787         }
 788 #endif
 789         if (i & 0xffff0000) {
 790                 h += 16; i >>= 16;
 791         }
 792         if (i & 0xff00) {
 793                 h += 8; i >>= 8;
 794         }
 795         if (i & 0xf0) {
 796                 h += 4; i >>= 4;
 797         }
 798         if (i & 0xc) {
 799                 h += 2; i >>= 2;
 800         }
 801         if (i & 0x2) {
 802                 h += 1;
 803         }
 804         return (h);
 805 }
 806 
 807 static int random_fd = -1, urandom_fd = -1;
 808 




   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
   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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  24  * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
  25  */
  26 
  27 #include <assert.h>
  28 #include <fcntl.h>
  29 #include <poll.h>
  30 #include <stdio.h>
  31 #include <stdlib.h>
  32 #include <string.h>
  33 #include <zlib.h>
  34 #include <sys/spa.h>
  35 #include <sys/stat.h>
  36 #include <sys/processor.h>
  37 #include <sys/zfs_context.h>
  38 #include <sys/rrwlock.h>
  39 #include <sys/zmod.h>
  40 #include <sys/utsname.h>
  41 #include <sys/systeminfo.h>
  42 
  43 /*


 755         }
 756         *size = st.st_size;
 757         return (0);
 758 }
 759 
 760 /*
 761  * =========================================================================
 762  * misc routines
 763  * =========================================================================
 764  */
 765 
 766 void
 767 delay(clock_t ticks)
 768 {
 769         poll(0, 0, ticks * (1000 / hz));
 770 }
 771 
 772 /*
 773  * Find highest one bit set.
 774  *      Returns bit number + 1 of highest bit that is set, otherwise returns 0.

 775  */
 776 int
 777 highbit64(uint64_t i)
 778 {
 779         int h = 1;
 780 
 781         if (i == 0)
 782                 return (0);
 783         if (i & 0xffffffff00000000ULL) {

 784                 h += 32; i >>= 32;
 785         }

 786         if (i & 0xffff0000) {
 787                 h += 16; i >>= 16;
 788         }
 789         if (i & 0xff00) {
 790                 h += 8; i >>= 8;
 791         }
 792         if (i & 0xf0) {
 793                 h += 4; i >>= 4;
 794         }
 795         if (i & 0xc) {
 796                 h += 2; i >>= 2;
 797         }
 798         if (i & 0x2) {
 799                 h += 1;
 800         }
 801         return (h);
 802 }
 803 
 804 static int random_fd = -1, urandom_fd = -1;
 805