Illumos #2619 and #2747
[zfs.git] / module / zfs / dnode_sync.c
index 7d304b2..58fa473 100644 (file)
  *
  * CDDL HEADER END
  */
+
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
  */
 
 #include <sys/zfs_context.h>
@@ -418,9 +420,13 @@ dnode_evict_dbufs(dnode_t *dn)
                if (evicting)
                        delay(1);
                pass++;
-               ASSERT(pass < 100); /* sanity check */
+               if ((pass % 100) == 0)
+                       dprintf("Exceeded %d passes evicting dbufs\n", pass);
        } while (progress);
 
+       if (pass >= 100)
+               dprintf("Required %d passes to evict dbufs\n", pass);
+
        rw_enter(&dn->dn_struct_rwlock, RW_WRITER);
        if (dn->dn_bonus && refcount_is_zero(&dn->dn_bonus->db_holds)) {
                mutex_enter(&dn->dn_bonus->db_mtx);
@@ -594,7 +600,7 @@ dnode_sync(dnode_t *dn, dmu_tx_t *tx)
        }
 
        if (dn->dn_next_bonustype[txgoff]) {
-               ASSERT(dn->dn_next_bonustype[txgoff] < DMU_OT_NUMTYPES);
+               ASSERT(DMU_OT_IS_VALID(dn->dn_next_bonustype[txgoff]));
                dnp->dn_bonustype = dn->dn_next_bonustype[txgoff];
                dn->dn_next_bonustype[txgoff] = 0;
        }
@@ -662,9 +668,10 @@ dnode_sync(dnode_t *dn, dmu_tx_t *tx)
                        int i;
                        ASSERT(dn->dn_next_nblkptr[txgoff] < dnp->dn_nblkptr);
                        /* the blkptrs we are losing better be unallocated */
-                       for (i = dn->dn_next_nblkptr[txgoff];
-                           i < dnp->dn_nblkptr; i++)
-                               ASSERT(BP_IS_HOLE(&dnp->dn_blkptr[i]));
+                       for (i = 0; i < dnp->dn_nblkptr; i++) {
+                               if (i >= dn->dn_next_nblkptr[txgoff])
+                                       ASSERT(BP_IS_HOLE(&dnp->dn_blkptr[i]));
+                       }
 #endif
                }
                mutex_enter(&dn->dn_mtx);