Print this page
3580 Want zvols to return volblocksize when queried for physical block size
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/zvol.c
          +++ new/usr/src/uts/common/fs/zfs/zvol.c
↓ open down ↓ 1619 lines elided ↑ open up ↑
1620 1620  
1621 1621  /*
1622 1622   * Dirtbag ioctls to support mkfs(1M) for UFS filesystems.  See dkio(7I).
1623 1623   * Also a dirtbag dkio ioctl for unmap/free-block functionality.
1624 1624   */
1625 1625  /*ARGSUSED*/
1626 1626  int
1627 1627  zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
1628 1628  {
1629 1629          zvol_state_t *zv;
1630      -        struct dk_cinfo dki;
1631      -        struct dk_minfo dkm;
1632 1630          struct dk_callback *dkc;
1633 1631          int error = 0;
1634 1632          rl_t *rl;
1635 1633  
1636 1634          mutex_enter(&zfsdev_state_lock);
1637 1635  
1638 1636          zv = zfsdev_get_soft_state(getminor(dev), ZSST_ZVOL);
1639 1637  
1640 1638          if (zv == NULL) {
1641 1639                  mutex_exit(&zfsdev_state_lock);
1642 1640                  return (SET_ERROR(ENXIO));
1643 1641          }
1644 1642          ASSERT(zv->zv_total_opens > 0);
1645 1643  
1646 1644          switch (cmd) {
1647 1645  
1648 1646          case DKIOCINFO:
     1647 +        {
     1648 +                struct dk_cinfo dki;
     1649 +
1649 1650                  bzero(&dki, sizeof (dki));
1650 1651                  (void) strcpy(dki.dki_cname, "zvol");
1651 1652                  (void) strcpy(dki.dki_dname, "zvol");
1652 1653                  dki.dki_ctype = DKC_UNKNOWN;
1653 1654                  dki.dki_unit = getminor(dev);
1654 1655                  dki.dki_maxtransfer = 1 << (SPA_MAXBLOCKSHIFT - zv->zv_min_bs);
1655 1656                  mutex_exit(&zfsdev_state_lock);
1656 1657                  if (ddi_copyout(&dki, (void *)arg, sizeof (dki), flag))
1657 1658                          error = SET_ERROR(EFAULT);
1658 1659                  return (error);
     1660 +        }
1659 1661  
1660 1662          case DKIOCGMEDIAINFO:
     1663 +        {
     1664 +                struct dk_minfo dkm;
     1665 +
1661 1666                  bzero(&dkm, sizeof (dkm));
1662 1667                  dkm.dki_lbsize = 1U << zv->zv_min_bs;
1663 1668                  dkm.dki_capacity = zv->zv_volsize >> zv->zv_min_bs;
1664 1669                  dkm.dki_media_type = DK_UNKNOWN;
1665 1670                  mutex_exit(&zfsdev_state_lock);
1666 1671                  if (ddi_copyout(&dkm, (void *)arg, sizeof (dkm), flag))
1667 1672                          error = SET_ERROR(EFAULT);
1668 1673                  return (error);
     1674 +        }
1669 1675  
     1676 +        case DKIOCGMEDIAINFOEXT:
     1677 +        {
     1678 +                struct dk_minfo_ext dkmext;
     1679 +
     1680 +                bzero(&dkmext, sizeof (dkmext));
     1681 +                dkmext.dki_lbsize = 1U << zv->zv_min_bs;
     1682 +                dkmext.dki_pbsize = zv->zv_volblocksize;
     1683 +                dkmext.dki_capacity = zv->zv_volsize >> zv->zv_min_bs;
     1684 +                dkmext.dki_media_type = DK_UNKNOWN;
     1685 +                mutex_exit(&zfsdev_state_lock);
     1686 +                if (ddi_copyout(&dkmext, (void *)arg, sizeof (dkmext), flag))
     1687 +                        error = SET_ERROR(EFAULT);
     1688 +                return (error);
     1689 +        }
     1690 +
1670 1691          case DKIOCGETEFI:
1671      -                {
1672      -                        uint64_t vs = zv->zv_volsize;
1673      -                        uint8_t bs = zv->zv_min_bs;
     1692 +        {
     1693 +                uint64_t vs = zv->zv_volsize;
     1694 +                uint8_t bs = zv->zv_min_bs;
1674 1695  
1675      -                        mutex_exit(&zfsdev_state_lock);
1676      -                        error = zvol_getefi((void *)arg, flag, vs, bs);
1677      -                        return (error);
1678      -                }
     1696 +                mutex_exit(&zfsdev_state_lock);
     1697 +                error = zvol_getefi((void *)arg, flag, vs, bs);
     1698 +                return (error);
     1699 +        }
1679 1700  
1680 1701          case DKIOCFLUSHWRITECACHE:
1681 1702                  dkc = (struct dk_callback *)arg;
1682 1703                  mutex_exit(&zfsdev_state_lock);
1683 1704                  zil_commit(zv->zv_zilog, ZVOL_OBJ);
1684 1705                  if ((flag & FKIOCTL) && dkc != NULL && dkc->dkc_callback) {
1685 1706                          (*dkc->dkc_callback)(dkc->dkc_cookie, error);
1686 1707                          error = 0;
1687 1708                  }
1688 1709                  return (error);
1689 1710  
1690 1711          case DKIOCGETWCE:
1691      -                {
1692      -                        int wce = (zv->zv_flags & ZVOL_WCE) ? 1 : 0;
1693      -                        if (ddi_copyout(&wce, (void *)arg, sizeof (int),
1694      -                            flag))
1695      -                                error = SET_ERROR(EFAULT);
     1712 +        {
     1713 +                int wce = (zv->zv_flags & ZVOL_WCE) ? 1 : 0;
     1714 +                if (ddi_copyout(&wce, (void *)arg, sizeof (int),
     1715 +                    flag))
     1716 +                        error = SET_ERROR(EFAULT);
     1717 +                break;
     1718 +        }
     1719 +        case DKIOCSETWCE:
     1720 +        {
     1721 +                int wce;
     1722 +                if (ddi_copyin((void *)arg, &wce, sizeof (int),
     1723 +                    flag)) {
     1724 +                        error = SET_ERROR(EFAULT);
1696 1725                          break;
1697 1726                  }
1698      -        case DKIOCSETWCE:
1699      -                {
1700      -                        int wce;
1701      -                        if (ddi_copyin((void *)arg, &wce, sizeof (int),
1702      -                            flag)) {
1703      -                                error = SET_ERROR(EFAULT);
1704      -                                break;
1705      -                        }
1706      -                        if (wce) {
1707      -                                zv->zv_flags |= ZVOL_WCE;
1708      -                                mutex_exit(&zfsdev_state_lock);
1709      -                        } else {
1710      -                                zv->zv_flags &= ~ZVOL_WCE;
1711      -                                mutex_exit(&zfsdev_state_lock);
1712      -                                zil_commit(zv->zv_zilog, ZVOL_OBJ);
1713      -                        }
1714      -                        return (0);
     1727 +                if (wce) {
     1728 +                        zv->zv_flags |= ZVOL_WCE;
     1729 +                        mutex_exit(&zfsdev_state_lock);
     1730 +                } else {
     1731 +                        zv->zv_flags &= ~ZVOL_WCE;
     1732 +                        mutex_exit(&zfsdev_state_lock);
     1733 +                        zil_commit(zv->zv_zilog, ZVOL_OBJ);
1715 1734                  }
     1735 +                return (0);
     1736 +        }
1716 1737  
1717 1738          case DKIOCGGEOM:
1718 1739          case DKIOCGVTOC:
1719 1740                  /*
1720 1741                   * commands using these (like prtvtoc) expect ENOTSUP
1721 1742                   * since we're emulating an EFI label
1722 1743                   */
1723 1744                  error = SET_ERROR(ENOTSUP);
1724 1745                  break;
1725 1746  
↓ open down ↓ 388 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX