Skip to content

Commit

Permalink
3580 Want zvols to return volblocksize when queried for physical bloc…
Browse files Browse the repository at this point in the history
…k 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>
Reviewed by: Boris Protopopov <boris.protopopov@nexenta.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Gordon Ross <gwr@nexenta.com>
  • Loading branch information
grwilson authored and Christopher Siden committed Nov 29, 2013
1 parent e722410 commit a0b6056
Showing 1 changed file with 52 additions and 31 deletions.
83 changes: 52 additions & 31 deletions usr/src/uts/common/fs/zfs/zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1627,8 +1627,6 @@ int
zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
{
zvol_state_t *zv;
struct dk_cinfo dki;
struct dk_minfo dkm;
struct dk_callback *dkc;
int error = 0;
rl_t *rl;
Expand All @@ -1646,6 +1644,9 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
switch (cmd) {

case DKIOCINFO:
{
struct dk_cinfo dki;

bzero(&dki, sizeof (dki));
(void) strcpy(dki.dki_cname, "zvol");
(void) strcpy(dki.dki_dname, "zvol");
Expand All @@ -1656,8 +1657,12 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
if (ddi_copyout(&dki, (void *)arg, sizeof (dki), flag))
error = SET_ERROR(EFAULT);
return (error);
}

case DKIOCGMEDIAINFO:
{
struct dk_minfo dkm;

bzero(&dkm, sizeof (dkm));
dkm.dki_lbsize = 1U << zv->zv_min_bs;
dkm.dki_capacity = zv->zv_volsize >> zv->zv_min_bs;
Expand All @@ -1666,16 +1671,32 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
if (ddi_copyout(&dkm, (void *)arg, sizeof (dkm), flag))
error = SET_ERROR(EFAULT);
return (error);
}

case DKIOCGMEDIAINFOEXT:
{
struct dk_minfo_ext dkmext;

bzero(&dkmext, sizeof (dkmext));
dkmext.dki_lbsize = 1U << zv->zv_min_bs;
dkmext.dki_pbsize = zv->zv_volblocksize;
dkmext.dki_capacity = zv->zv_volsize >> zv->zv_min_bs;
dkmext.dki_media_type = DK_UNKNOWN;
mutex_exit(&zfsdev_state_lock);
if (ddi_copyout(&dkmext, (void *)arg, sizeof (dkmext), flag))
error = SET_ERROR(EFAULT);
return (error);
}

case DKIOCGETEFI:
{
uint64_t vs = zv->zv_volsize;
uint8_t bs = zv->zv_min_bs;
{
uint64_t vs = zv->zv_volsize;
uint8_t bs = zv->zv_min_bs;

mutex_exit(&zfsdev_state_lock);
error = zvol_getefi((void *)arg, flag, vs, bs);
return (error);
}
mutex_exit(&zfsdev_state_lock);
error = zvol_getefi((void *)arg, flag, vs, bs);
return (error);
}

case DKIOCFLUSHWRITECACHE:
dkc = (struct dk_callback *)arg;
Expand All @@ -1688,31 +1709,31 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
return (error);

case DKIOCGETWCE:
{
int wce = (zv->zv_flags & ZVOL_WCE) ? 1 : 0;
if (ddi_copyout(&wce, (void *)arg, sizeof (int),
flag))
error = SET_ERROR(EFAULT);
{
int wce = (zv->zv_flags & ZVOL_WCE) ? 1 : 0;
if (ddi_copyout(&wce, (void *)arg, sizeof (int),
flag))
error = SET_ERROR(EFAULT);
break;
}
case DKIOCSETWCE:
{
int wce;
if (ddi_copyin((void *)arg, &wce, sizeof (int),
flag)) {
error = SET_ERROR(EFAULT);
break;
}
case DKIOCSETWCE:
{
int wce;
if (ddi_copyin((void *)arg, &wce, sizeof (int),
flag)) {
error = SET_ERROR(EFAULT);
break;
}
if (wce) {
zv->zv_flags |= ZVOL_WCE;
mutex_exit(&zfsdev_state_lock);
} else {
zv->zv_flags &= ~ZVOL_WCE;
mutex_exit(&zfsdev_state_lock);
zil_commit(zv->zv_zilog, ZVOL_OBJ);
}
return (0);
if (wce) {
zv->zv_flags |= ZVOL_WCE;
mutex_exit(&zfsdev_state_lock);
} else {
zv->zv_flags &= ~ZVOL_WCE;
mutex_exit(&zfsdev_state_lock);
zil_commit(zv->zv_zilog, ZVOL_OBJ);
}
return (0);
}

case DKIOCGGEOM:
case DKIOCGVTOC:
Expand Down

0 comments on commit a0b6056

Please sign in to comment.