Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/cddl/osnet/dist/uts/common/fs/zfs Add missing zvol_...



details:   https://anonhg.NetBSD.org/src/rev/1184eb5307ed
branches:  trunk
changeset: 456662:1184eb5307ed
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed May 22 08:46:27 2019 +0000

description:
Add missing zvol_close() to zfsdev_close().

Change zvol_size_changed() to initialize "zv->zv_volsize"
and initialize only "dg_secsize" and "dg_secperunit".
Calling disk_set_info() will initialize the remaining
parts of the geometry.

Set "doread" in zvol_strategy() to make reading from
device possible.

Reorganize/add disk_busy()/disk_unbusy() instrumentation.

Redo zvol_ioctl() to implement DIOCGWEDGEINFO and let
disk_ioctl() process the remaining ioctls.

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c |   3 +-
 external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c      |  94 ++++++++---------
 2 files changed, 48 insertions(+), 49 deletions(-)

diffs (178 lines):

diff -r 0d57652beedb -r 1184eb5307ed external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c    Wed May 22 08:45:32 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ioctl.c    Wed May 22 08:46:27 2019 +0000
@@ -6285,6 +6285,7 @@
 #ifdef __FreeBSD__
                return;
 #else
+               return zvol_close(dev, flag, otyp, cr);
                return 0;
 #endif
        }
@@ -6303,7 +6304,7 @@
 #endif
 #ifdef __NetBSD__
 static int
-zfsdev_ioctl(dev_t dev, int zcmd, intptr_t iarg, int flag, cred_t *cr, int *rvalp)
+zfsdev_ioctl(dev_t dev, u_long zcmd, intptr_t iarg, int flag, cred_t *cr, int *rvalp)
 #endif
 {
        zfs_cmd_t *zc;
diff -r 0d57652beedb -r 1184eb5307ed external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c Wed May 22 08:45:32 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zvol.c Wed May 22 08:46:27 2019 +0000
@@ -315,29 +315,14 @@
        }
 #endif /* __FreeBSD__ */
 #ifdef __NetBSD__
-       prop_dictionary_t disk_info, odisk_info, geom;
-       struct disk *disk;
-
-       disk = &zv->zv_dk;
-
-       disk_info = prop_dictionary_create();
-       geom = prop_dictionary_create();
-
-       prop_dictionary_set_cstring_nocopy(disk_info, "type", "ESDI");
-       prop_dictionary_set_uint64(geom, "sectors-per-unit", zv->zv_volsize);
-       prop_dictionary_set_uint32(geom, "sector-size",
-           DEV_BSIZE /* XXX 512? */);
-       prop_dictionary_set_uint32(geom, "sectors-per-track", 32);
-       prop_dictionary_set_uint32(geom, "tracks-per-cylinder", 64);
-       prop_dictionary_set_uint32(geom, "cylinders-per-unit", zv->zv_volsize / 2048);
-       prop_dictionary_set(disk_info, "geometry", geom);
-       prop_object_release(geom);
-
-       odisk_info = disk->dk_info;
-       disk->dk_info = disk_info;
-
-       if (odisk_info != NULL)
-               prop_object_release(odisk_info);
+       struct disk_geom *dg = &zv->zv_dk.dk_geom;
+
+       zv->zv_volsize = volsize;
+
+       memset(dg, 0, sizeof(*dg));
+       dg->dg_secsize = DEV_BSIZE; /* XXX 512? */
+       dg->dg_secperunit = zv->zv_volsize / dg->dg_secsize;;
+       disk_set_info(NULL, &zv->zv_dk, "ZVOL");
 #endif
 }
 
@@ -1793,7 +1778,7 @@
        objset_t *os;
        rl_t *rl;
        int error = 0;
-#ifdef illumos
+#if defined(illumos) || defined(__NetBSD__)
        boolean_t doread = bp->b_flags & B_READ;
 #else
        boolean_t doread = 0;
@@ -2136,6 +2121,12 @@
        }
 #endif
 
+#ifdef __NetBSD__
+       uint64_t resid = uio->uio_resid;
+       mutex_enter(&zv->zv_dklock);
+       disk_busy(&zv->zv_dk);
+       mutex_exit(&zv->zv_dklock);
+#endif
        rl = zfs_range_lock(&zv->zv_znode, uio->uio_loffset, uio->uio_resid,
            RL_READER);
        while (uio->uio_resid > 0 && uio->uio_loffset < volsize) {
@@ -2154,6 +2145,11 @@
                }
        }
        zfs_range_unlock(rl);
+#ifdef __NetBSD__
+       mutex_enter(&zv->zv_dklock);
+       disk_unbusy(&zv->zv_dk, resid - uio->uio_resid, 1);
+       mutex_exit(&zv->zv_dklock);
+#endif
        return (error);
 }
 
@@ -2205,6 +2201,12 @@
 #endif
            (zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS);
 
+#ifdef __NetBSD__
+       uint64_t resid = uio->uio_resid;
+       mutex_enter(&zv->zv_dklock);
+       disk_busy(&zv->zv_dk);
+       mutex_exit(&zv->zv_dklock);
+#endif
        rl = zfs_range_lock(&zv->zv_znode, uio->uio_loffset, uio->uio_resid,
            RL_WRITER);
        while (uio->uio_resid > 0 && uio->uio_loffset < volsize) {
@@ -2232,6 +2234,11 @@
        zfs_range_unlock(rl);
        if (sync)
                zil_commit(zv->zv_zilog, ZVOL_OBJ);
+#ifdef __NetBSD__
+       mutex_enter(&zv->zv_dklock);
+       disk_unbusy(&zv->zv_dk, resid - uio->uio_resid, 0);
+       mutex_exit(&zv->zv_dklock);
+#endif
        return (error);
 }
 
@@ -3568,42 +3575,33 @@
                return (ENXIO);
        }
 
+       error = disk_ioctl(&zv->zv_dk, NODEV, cmd, (void *)arg, flag, curlwp);
+       if (error != EPASSTHROUGH) {
+               mutex_exit(&zfsdev_state_lock);
+               return error;
+       }
+
+       error = 0;
+
        switch(cmd) {
        case DIOCGWEDGEINFO:
        {
                struct dkwedge_info *dkw = (void *) arg;
-
-               strlcpy(dkw->dkw_devname, zv->zv_name, 16);
-               strlcpy(dkw->dkw_wname, zv->zv_name, MAXPATHLEN);
-               strlcpy(dkw->dkw_parent, zv->zv_name, 16);
+               
+               memset(dkw, 0, sizeof(*dkw));
+               strlcpy(dkw->dkw_devname, zv->zv_name,
+                   sizeof(dkw->dkw_devname));
+               strlcpy(dkw->dkw_parent, "ZFS", sizeof(dkw->dkw_parent));
                
                dkw->dkw_offset = 0;
-               /* XXX NetBSD supports only DEV_BSIZE device block
-                  size zv_volblocksize >> DEV_BSIZE*/
-               dkw->dkw_size = (zv->zv_volsize / DEV_BSIZE);
-               dprintf("dkw %"PRIu64" volsize %"PRIu64" volblock %"PRIu64" \n",
-                   dkw->dkw_size, zv->zv_volsize, zv->zv_volblocksize);
+               dkw->dkw_size = zv->zv_volsize / DEV_BSIZE;
                strcpy(dkw->dkw_ptype, DKW_PTYPE_FFS);
 
                break;
        }
 
-       case DIOCGDISKINFO:
-       {
-               struct plistref *pref = (struct plistref *) arg;
-
-               if (zv->zv_dk.dk_info == NULL) {
-                       mutex_exit(&zfsdev_state_lock);
-                       return ENOTSUP;
-               } else
-                       prop_dictionary_copyout_ioctl(pref, cmd,
-                           zv->zv_dk.dk_info);
-               
-               break;
-       }
-       
        default:
-               aprint_debug("unknown disk_ioctl called\n");
+               dprintf("unknown disk_ioctl called\n");
                error = ENOTTY;
                break; 
        }



Home | Main Index | Thread Index | Old Index