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 Use utility funct...



details:   https://anonhg.NetBSD.org/src/rev/1cf90fcdd7bc
branches:  trunk
changeset: 745354:1cf90fcdd7bc
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Feb 29 17:15:43 2020 +0000

description:
Use utility functions to handle disk geometry.

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c |  62 ++++-------------
 1 files changed, 17 insertions(+), 45 deletions(-)

diffs (106 lines):

diff -r 01ec64924847 -r 1cf90fcdd7bc external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c    Sat Feb 29 17:14:40 2020 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c    Sat Feb 29 17:15:43 2020 +0000
@@ -35,7 +35,6 @@
 #include <sys/sunldi.h>
 #include <sys/fm/fs/zfs.h>
 #include <sys/disk.h>
-#include <sys/disklabel.h>
 #include <sys/dkio.h>
 #include <sys/workqueue.h>
 
@@ -147,10 +146,11 @@
        spa_t *spa = vd->vdev_spa;
        vdev_disk_t *dvd;
        vnode_t *vp;
-       struct dkwedge_info dkw;
+       int error, cmd;
+       uint64_t numsecs;
+       unsigned secsize;
        struct disk *pdk;
-       int error, cmd;
-       struct partinfo pinfo;
+       struct dkwedge_info dkw;
 
        /*
         * We must have a pathname, and it must be absolute.
@@ -219,33 +219,15 @@
                return (SET_ERROR(EINVAL));
        }
 
+       pdk = NULL;
+       if (getdiskinfo(vp, &dkw) == 0)
+               pdk = disk_find(dkw.dkw_parent);
+
        /* XXXNETBSD Once tls-maxphys gets merged this block becomes:
-               if (VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD, NOCRED) == 0)
-                       pdk = disk_find(dkw.dkw_parent);
-               else
-                       pdk = disk_find_blk(vp->v_rdev);
                dvd->vd_maxphys = (pdk ? disk_maxphys(pdk) : MACHINE_MAXPHYS);
        */
        {
                struct buf buf = { .b_bcount = MAXPHYS };
-
-               if (VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD, NOCRED) == 0) {
-                       pdk = disk_find(dkw.dkw_parent);
-               } else {
-                       const char *dev_name;
-
-                       dev_name = devsw_blk2name(major(vp->v_rdev));
-                       if (dev_name) {
-                               char disk_name[16];
-
-                               snprintf(disk_name, sizeof(disk_name), "%s%d",
-                                   dev_name, DISKUNIT(vp->v_rdev));
-                               pdk = disk_find(disk_name);
-                       } else {
-                               pdk = NULL;
-                       }
-                       buf.b_dev = vp->v_rdev;
-               }
                if (pdk && pdk->dk_driver && pdk->dk_driver->d_minphys)
                        (*pdk->dk_driver->d_minphys)(&buf);
                dvd->vd_maxphys = buf.b_bcount;
@@ -268,32 +250,22 @@
        dvd->vd_vp = vp;
 
 skip_open:
-       /*
-        * Determine the actual size of the device.
-        * Try wedge info first as it supports larger disks.
-        */
-       error = VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD, NOCRED);
-       if (error == 0) {
-               pdk = disk_find(dkw.dkw_parent);
-               if (pdk) {
-                       pinfo.pi_secsize = (1 << pdk->dk_byteshift);
-                       pinfo.pi_size = dkw.dkw_size;
-                       pinfo.pi_offset = dkw.dkw_offset;
-               } else  
-                       error = ENODEV;
-       }
-       if (error)
-               error = VOP_IOCTL(vp, DIOCGPARTINFO, &pinfo, FREAD, kcred);
+       error = getdisksize(vp, &numsecs, &secsize);
        if (error != 0) {
                vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
                return (SET_ERROR(error));
        }
-       *psize = pinfo.pi_size * pinfo.pi_secsize;
+
+       *psize = numsecs * secsize;
        *max_psize = *psize;
 
-       *ashift = highbit(MAX(pinfo.pi_secsize, SPA_MINBLOCKSIZE)) - 1;
+       *ashift = highbit(MAX(secsize, SPA_MINBLOCKSIZE)) - 1;
        *pashift = *ashift;
-       vd->vdev_wholedisk = (pinfo.pi_offset == 0); /* XXXNETBSD */
+
+       vd->vdev_wholedisk = 0;
+       if (getdiskinfo(vp, &dkw) != 0 &&
+           dkw.dkw_offset == 0 && dkw.dkw_size == numsecs)
+               vd->vdev_wholedisk = 1,
 
        /*
         * Clear the nowritecache bit, so that on a vdev_reopen() we will



Home | Main Index | Thread Index | Old Index