summaryrefslogtreecommitdiffstats
path: root/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2014-05-08 13:10:39 +0000
committermav <mav@FreeBSD.org>2014-05-08 13:10:39 +0000
commitda286974ab2c76c57f866ef9a57c31eb57f904c3 (patch)
tree98069a0839adeaf4d2549dae14f428bdce8ee895 /sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
parentdf9f601cbcdbfe062c43e38da3dd1a4351c46fdf (diff)
downloadFreeBSD-src-da286974ab2c76c57f866ef9a57c31eb57f904c3.zip
FreeBSD-src-da286974ab2c76c57f866ef9a57c31eb57f904c3.tar.gz
MFC r264086:
3580 Want zvols to return volblocksize when queried for physical block size illumos/illumos-gate@a0b60564dfc644f4bfaef1ce26d343b44cf68bc5 It is irrelevant for FreeBSD, just reducing diff.
Diffstat (limited to 'sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c83
1 files changed, 52 insertions, 31 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
index 30b13e7..5d14597 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
@@ -1723,8 +1723,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;
@@ -1742,6 +1740,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");
@@ -1752,8 +1753,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;
@@ -1762,16 +1767,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(&spa_namespace_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(&spa_namespace_lock);
- error = zvol_getefi((void *)arg, flag, vs, bs);
- return (error);
- }
+ mutex_exit(&spa_namespace_lock);
+ error = zvol_getefi((void *)arg, flag, vs, bs);
+ return (error);
+ }
case DKIOCFLUSHWRITECACHE:
dkc = (struct dk_callback *)arg;
@@ -1784,31 +1805,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(&spa_namespace_lock);
- } else {
- zv->zv_flags &= ~ZVOL_WCE;
- mutex_exit(&spa_namespace_lock);
- zil_commit(zv->zv_zilog, ZVOL_OBJ);
- }
- return (0);
+ if (wce) {
+ zv->zv_flags |= ZVOL_WCE;
+ mutex_exit(&spa_namespace_lock);
+ } else {
+ zv->zv_flags &= ~ZVOL_WCE;
+ mutex_exit(&spa_namespace_lock);
+ zil_commit(zv->zv_zilog, ZVOL_OBJ);
}
+ return (0);
+ }
case DKIOCGGEOM:
case DKIOCGVTOC:
OpenPOWER on IntegriCloud