Print this page
7938 Port ZOL #3712 disable LBA weighting on files and SSDs

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/vdev_disk.c
          +++ new/usr/src/uts/common/fs/zfs/vdev_disk.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
  24   24   * Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
  25   25   * Copyright (c) 2013 Joyent, Inc.  All rights reserved.
       26 + * Copyright (c) 2017 James S Blachly, MD <james.blachly@gmail.com>
  26   27   */
  27   28  
  28   29  #include <sys/zfs_context.h>
  29   30  #include <sys/spa_impl.h>
  30   31  #include <sys/refcount.h>
  31   32  #include <sys/vdev_disk.h>
  32   33  #include <sys/vdev_impl.h>
  33   34  #include <sys/fs/zfs.h>
  34   35  #include <sys/zio.h>
  35   36  #include <sys/sunldi.h>
↓ open down ↓ 228 lines elided ↑ open up ↑
 264  265                  struct dk_minfo ud;
 265  266          } dks;
 266  267          struct dk_minfo_ext *dkmext = &dks.ude;
 267  268          struct dk_minfo *dkm = &dks.ud;
 268  269          int error;
 269  270          dev_t dev;
 270  271          int otyp;
 271  272          boolean_t validate_devid = B_FALSE;
 272  273          ddi_devid_t devid;
 273  274          uint64_t capacity = 0, blksz = 0, pbsize;
      275 +        int device_solid_state;
      276 +        char *vendorp;  /* will point to inquiry-vendor-id */
 274  277  
 275  278          /*
 276  279           * We must have a pathname, and it must be absolute.
 277  280           */
 278  281          if (vd->vdev_path == NULL || vd->vdev_path[0] != '/') {
 279  282                  vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
 280  283                  return (SET_ERROR(EINVAL));
 281  284          }
 282  285  
 283  286          /*
↓ open down ↓ 252 lines elided ↑ open up ↑
 536  539  
 537  540                  /*
 538  541                   * Since we own the whole disk, try to enable disk write
 539  542                   * caching.  We ignore errors because it's OK if we can't do it.
 540  543                   */
 541  544                  (void) ldi_ioctl(dvd->vd_lh, DKIOCSETWCE, (intptr_t)&wce,
 542  545                      FKIOCTL, kcred, NULL);
 543  546          }
 544  547  
 545  548          /*
      549 +         * Inform the ZIO pipeline if we are non-rotational:
      550 +         * 1. Check if device is SSD
      551 +         * 2. If not SSD, check if device is Virtio
      552 +         */
      553 +        device_solid_state = ldi_prop_get_int(dvd->vd_lh, LDI_DEV_T_ANY,
      554 +            "device-solid-state", 0);
      555 +        vd->vdev_nonrot = (device_solid_state ? B_TRUE : B_FALSE);
      556 +
      557 +        if (device_solid_state == 0 &&
      558 +            ldi_prop_exists(dvd->vd_lh, LDI_DEV_T_ANY, "inquiry-vendor-id")) {
      559 +                ldi_prop_lookup_string(dvd->vd_lh, LDI_DEV_T_ANY,
      560 +                    "inquiry-vendor-id", &vendorp);
      561 +                if (strncmp(vendorp, "Virtio", 6) == 0)
      562 +                    vd->vdev_nonrot = B_TRUE;
      563 +                ddi_prop_free(vendorp);
      564 +        }
      565 +
      566 +        cmn_err(CE_NOTE, "[vdev_disk_open] %s :: device-solid-state "
      567 +            "== %d :: vd->vdev_nonrot == %d\n", vd->vdev_path,
      568 +            device_solid_state, (int) vd->vdev_nonrot);
      569 +
      570 +        /*
 546  571           * Clear the nowritecache bit, so that on a vdev_reopen() we will
 547  572           * try again.
 548  573           */
 549  574          vd->vdev_nowritecache = B_FALSE;
 550  575  
 551  576          return (0);
 552  577  }
 553  578  
 554  579  static void
 555  580  vdev_disk_close(vdev_t *vd)
↓ open down ↓ 348 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX