]> git.proxmox.com Git - mirror_zfs-debian.git/blobdiff - module/zfs/zap_leaf.c
Imported Upstream version 0.6.4.2
[mirror_zfs-debian.git] / module / zfs / zap_leaf.c
index 13bc879d7e82645cd1a1a05423e941a94fa79b22..9578048250e2f675c30525dc50d492fe58ac8212 100644 (file)
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2013, 2014 by Delphix. All rights reserved.
  */
 
 /*
@@ -79,8 +79,9 @@ stv(int len, void *addr, uint64_t value)
        case 8:
                *(uint64_t *)addr = value;
                return;
+       default:
+               cmn_err(CE_PANIC, "bad int len %d", len);
        }
-       ASSERT(!"bad int len");
 }
 
 static uint64_t
@@ -95,8 +96,9 @@ ldv(int len, const void *addr)
                return (*(uint32_t *)addr);
        case 8:
                return (*(uint64_t *)addr);
+       default:
+               cmn_err(CE_PANIC, "bad int len %d", len);
        }
-       ASSERT(!"bad int len");
        return (0xFEEDFACEDEADBEEFULL);
 }
 
@@ -105,16 +107,16 @@ zap_leaf_byteswap(zap_leaf_phys_t *buf, int size)
 {
        int i;
        zap_leaf_t l;
-       l.l_bs = highbit(size)-1;
+       l.l_bs = highbit64(size) - 1;
        l.l_phys = buf;
 
-       buf->l_hdr.lh_block_type =      BSWAP_64(buf->l_hdr.lh_block_type);
-       buf->l_hdr.lh_prefix =          BSWAP_64(buf->l_hdr.lh_prefix);
-       buf->l_hdr.lh_magic =           BSWAP_32(buf->l_hdr.lh_magic);
-       buf->l_hdr.lh_nfree =           BSWAP_16(buf->l_hdr.lh_nfree);
-       buf->l_hdr.lh_nentries =        BSWAP_16(buf->l_hdr.lh_nentries);
-       buf->l_hdr.lh_prefix_len =      BSWAP_16(buf->l_hdr.lh_prefix_len);
-       buf->l_hdr.lh_freelist =        BSWAP_16(buf->l_hdr.lh_freelist);
+       buf->l_hdr.lh_block_type =      BSWAP_64(buf->l_hdr.lh_block_type);
+       buf->l_hdr.lh_prefix =          BSWAP_64(buf->l_hdr.lh_prefix);
+       buf->l_hdr.lh_magic =           BSWAP_32(buf->l_hdr.lh_magic);
+       buf->l_hdr.lh_nfree =           BSWAP_16(buf->l_hdr.lh_nfree);
+       buf->l_hdr.lh_nentries =        BSWAP_16(buf->l_hdr.lh_nentries);
+       buf->l_hdr.lh_prefix_len =      BSWAP_16(buf->l_hdr.lh_prefix_len);
+       buf->l_hdr.lh_freelist =        BSWAP_16(buf->l_hdr.lh_freelist);
 
        for (i = 0; i < ZAP_LEAF_HASH_NUMENTRIES(&l); i++)
                buf->l_hash[i] = BSWAP_16(buf->l_hash[i]);
@@ -147,7 +149,8 @@ zap_leaf_byteswap(zap_leaf_phys_t *buf, int size)
                        /* la_array doesn't need swapping */
                        break;
                default:
-                       ASSERT(!"bad leaf type");
+                       cmn_err(CE_PANIC, "bad leaf type %d",
+                           lc->l_free.lf_type);
                }
        }
 }
@@ -157,7 +160,7 @@ zap_leaf_init(zap_leaf_t *l, boolean_t sort)
 {
        int i;
 
-       l->l_bs = highbit(l->l_dbuf->db_size)-1;
+       l->l_bs = highbit64(l->l_dbuf->db_size) - 1;
        zap_memset(&l->l_phys->l_hdr, 0, sizeof (struct zap_leaf_header));
        zap_memset(l->l_phys->l_hash, CHAIN_END, 2*ZAP_LEAF_HASH_NUMENTRIES(l));
        for (i = 0; i < ZAP_LEAF_NUMCHUNKS(l); i++) {
@@ -342,7 +345,7 @@ zap_leaf_array_match(zap_leaf_t *l, zap_name_t *zn,
 
                ASSERT(zn->zn_key_intlen == sizeof (*thiskey));
                thiskey = kmem_alloc(array_numints * sizeof (*thiskey),
-                   KM_PUSHPAGE);
+                   KM_SLEEP);
 
                zap_leaf_array_read(l, chunk, sizeof (*thiskey), array_numints,
                    sizeof (*thiskey), array_numints, thiskey);
@@ -354,7 +357,7 @@ zap_leaf_array_match(zap_leaf_t *l, zap_name_t *zn,
 
        ASSERT(zn->zn_key_intlen == 1);
        if (zn->zn_matchtype == MT_FIRST) {
-               char *thisname = kmem_alloc(array_numints, KM_PUSHPAGE);
+               char *thisname = kmem_alloc(array_numints, KM_SLEEP);
                boolean_t match;
 
                zap_leaf_array_read(l, chunk, sizeof (char), array_numints,