Print this page
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/zfs_vnops.c
          +++ new/usr/src/uts/common/fs/zfs/zfs_vnops.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) 2012 by Delphix. All rights reserved.
  23   24   */
  24   25  
       26 +
       27 +
       28 +
  25   29  /* Portions Copyright 2007 Jeremy Teo */
  26   30  /* Portions Copyright 2010 Robert Milkowski */
  27   31  
  28   32  #include <sys/types.h>
  29   33  #include <sys/param.h>
  30   34  #include <sys/time.h>
  31   35  #include <sys/systm.h>
  32   36  #include <sys/sysmacros.h>
  33   37  #include <sys/resource.h>
  34   38  #include <sys/vfs.h>
↓ open down ↓ 1599 lines elided ↑ open up ↑
1634 1638                  /* if the file is too big, only hold_free a token amount */
1635 1639                  dmu_tx_hold_free(tx, zp->z_id, 0,
1636 1640                      (toobig ? DMU_MAX_ACCESS : DMU_OBJECT_END));
1637 1641          }
1638 1642  
1639 1643          /* are there any extended attributes? */
1640 1644          error = sa_lookup(zp->z_sa_hdl, SA_ZPL_XATTR(zfsvfs),
1641 1645              &xattr_obj, sizeof (xattr_obj));
1642 1646          if (error == 0 && xattr_obj) {
1643 1647                  error = zfs_zget(zfsvfs, xattr_obj, &xzp);
1644      -                ASSERT3U(error, ==, 0);
     1648 +                ASSERT0(error);
1645 1649                  dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_TRUE);
1646 1650                  dmu_tx_hold_sa(tx, xzp->z_sa_hdl, B_FALSE);
1647 1651          }
1648 1652  
1649 1653          mutex_enter(&zp->z_lock);
1650 1654          if ((acl_obj = zfs_external_acl(zp)) != 0 && may_delete_now)
1651 1655                  dmu_tx_hold_free(tx, acl_obj, 0, DMU_OBJECT_END);
1652 1656          mutex_exit(&zp->z_lock);
1653 1657  
1654 1658          /* charge as an update -- would be nice not to charge at all */
↓ open down ↓ 57 lines elided ↑ open up ↑
1712 1716                          mutex_exit(&xzp->z_lock);
1713 1717                          zfs_unlinked_add(xzp, tx);
1714 1718  
1715 1719                          if (zp->z_is_sa)
1716 1720                                  error = sa_remove(zp->z_sa_hdl,
1717 1721                                      SA_ZPL_XATTR(zfsvfs), tx);
1718 1722                          else
1719 1723                                  error = sa_update(zp->z_sa_hdl,
1720 1724                                      SA_ZPL_XATTR(zfsvfs), &null_xattr,
1721 1725                                      sizeof (uint64_t), tx);
1722      -                        ASSERT3U(error, ==, 0);
     1726 +                        ASSERT0(error);
1723 1727                  }
1724 1728                  mutex_enter(&vp->v_lock);
1725 1729                  vp->v_count--;
1726      -                ASSERT3U(vp->v_count, ==, 0);
     1730 +                ASSERT0(vp->v_count);
1727 1731                  mutex_exit(&vp->v_lock);
1728 1732                  mutex_exit(&zp->z_lock);
1729 1733                  zfs_znode_delete(zp, tx);
1730 1734          } else if (unlinked) {
1731 1735                  mutex_exit(&zp->z_lock);
1732 1736                  zfs_unlinked_add(zp, tx);
1733 1737          }
1734 1738  
1735 1739          txtype = TX_REMOVE;
1736 1740          if (flags & FIGNORECASE)
↓ open down ↓ 1352 lines elided ↑ open up ↑
3089 3093                          ASSERT(err == 0);
3090 3094                  }
3091 3095          }
3092 3096  
3093 3097          if (mask & AT_MODE) {
3094 3098                  SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MODE(zfsvfs), NULL,
3095 3099                      &new_mode, sizeof (new_mode));
3096 3100                  zp->z_mode = new_mode;
3097 3101                  ASSERT3U((uintptr_t)aclp, !=, NULL);
3098 3102                  err = zfs_aclset_common(zp, aclp, cr, tx);
3099      -                ASSERT3U(err, ==, 0);
     3103 +                ASSERT0(err);
3100 3104                  if (zp->z_acl_cached)
3101 3105                          zfs_acl_free(zp->z_acl_cached);
3102 3106                  zp->z_acl_cached = aclp;
3103 3107                  aclp = NULL;
3104 3108          }
3105 3109  
3106 3110  
3107 3111          if (mask & AT_ATIME) {
3108 3112                  ZFS_TIME_ENCODE(&vap->va_atime, zp->z_atime);
3109 3113                  SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_ATIME(zfsvfs), NULL,
↓ open down ↓ 502 lines elided ↑ open up ↑
3612 3616          if (tzp)        /* Attempt to remove the existing target */
3613 3617                  error = zfs_link_destroy(tdl, tzp, tx, zflg, NULL);
3614 3618  
3615 3619          if (error == 0) {
3616 3620                  error = zfs_link_create(tdl, szp, tx, ZRENAMING);
3617 3621                  if (error == 0) {
3618 3622                          szp->z_pflags |= ZFS_AV_MODIFIED;
3619 3623  
3620 3624                          error = sa_update(szp->z_sa_hdl, SA_ZPL_FLAGS(zfsvfs),
3621 3625                              (void *)&szp->z_pflags, sizeof (uint64_t), tx);
3622      -                        ASSERT3U(error, ==, 0);
     3626 +                        ASSERT0(error);
3623 3627  
3624 3628                          error = zfs_link_destroy(sdl, szp, tx, ZRENAMING, NULL);
3625 3629                          if (error == 0) {
3626 3630                                  zfs_log_rename(zilog, tx, TX_RENAME |
3627 3631                                      (flags & FIGNORECASE ? TX_CI : 0), sdzp,
3628 3632                                      sdl->dl_name, tdzp, tdl->dl_name, szp);
3629 3633  
3630 3634                                  /*
3631 3635                                   * Update path information for the target vnode
3632 3636                                   */
↓ open down ↓ 1620 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX