Deleted Added
full compact
54a55,99
> /**
> * The limit for ZFS to automatically increase a top-level vdev's ashift
> * from logical ashift to physical ashift.
> *
> * Example: one or more 512B emulation child vdevs
> * child->vdev_ashift = 9 (512 bytes)
> * child->vdev_physical_ashift = 12 (4096 bytes)
> * zfs_max_auto_ashift = 11 (2048 bytes)
> *
> * On pool creation or the addition of a new top-leve vdev, ZFS will
> * bump the ashift of the top-level vdev to 2048.
> *
> * Example: one or more 512B emulation child vdevs
> * child->vdev_ashift = 9 (512 bytes)
> * child->vdev_physical_ashift = 12 (4096 bytes)
> * zfs_max_auto_ashift = 13 (8192 bytes)
> *
> * On pool creation or the addition of a new top-leve vdev, ZFS will
> * bump the ashift of the top-level vdev to 4096.
> */
> static uint64_t zfs_max_auto_ashift = SPA_MAXASHIFT;
>
> static int
> sysctl_vfs_zfs_max_auto_ashift(SYSCTL_HANDLER_ARGS)
> {
> uint64_t val;
> int err;
>
> val = zfs_max_auto_ashift;
> err = sysctl_handle_64(oidp, &val, 0, req);
> if (err != 0 || req->newptr == NULL)
> return (err);
>
> if (val > SPA_MAXASHIFT)
> val = SPA_MAXASHIFT;
>
> zfs_max_auto_ashift = val;
>
> return (0);
> }
> SYSCTL_PROC(_vfs_zfs, OID_AUTO, max_auto_ashift,
> CTLTYPE_U64 | CTLFLAG_MPSAFE | CTLFLAG_RW, 0, sizeof(uint64_t),
> sysctl_vfs_zfs_max_auto_ashift, "QU",
> "Cap on logical -> physical ashift adjustment on new top-level vdevs.");
>
748a794,795
> mvd->vdev_logical_ashift = cvd->vdev_logical_ashift;
> mvd->vdev_physical_ashift = cvd->vdev_physical_ashift;
779a827,828
> cvd->vdev_logical_ashift = mvd->vdev_logical_ashift;
> cvd->vdev_physical_ashift = mvd->vdev_physical_ashift;
1123c1172,1173
< uint64_t ashift = 0;
---
> uint64_t logical_ashift = 0;
> uint64_t physical_ashift = 0;
1153c1203,1204
< error = vd->vdev_ops->vdev_op_open(vd, &osize, &max_osize, &ashift);
---
> error = vd->vdev_ops->vdev_op_open(vd, &osize, &max_osize,
> &logical_ashift, &physical_ashift);
1250a1302,1312
> vd->vdev_physical_ashift =
> MAX(physical_ashift, vd->vdev_physical_ashift);
> vd->vdev_logical_ashift = MAX(logical_ashift, vd->vdev_logical_ashift);
> vd->vdev_ashift = MAX(vd->vdev_logical_ashift, vd->vdev_ashift);
>
> if (vd->vdev_logical_ashift > SPA_MAXASHIFT) {
> vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
> VDEV_AUX_ASHIFT_TOO_BIG);
> return (EINVAL);
> }
>
1258d1319
< vd->vdev_ashift = MAX(ashift, vd->vdev_ashift);
1261,1263c1322
< * Detect if the alignment requirement has increased.
< * We don't want to make the pool unavailable, just
< * issue a warning instead.
---
> * Make sure the alignment requirement hasn't increased.
1265c1324
< if (ashift > vd->vdev_top->vdev_ashift &&
---
> if (vd->vdev_ashift > vd->vdev_top->vdev_ashift &&
1267,1270c1326,1328
< cmn_err(CE_WARN,
< "Disk, '%s', has a block alignment that is "
< "larger than the pool's alignment\n",
< vd->vdev_path);
---
> vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
> VDEV_AUX_BAD_LABEL);
> return (EINVAL);
1579a1638,1643
> /*
> * Maximize performance by inflating the configured ashift for
> * top level vdevs to be as close to the physical ashift as
> * possible without exceeding the administrator specified
> * limit.
> */
1580a1645,1655
> vdev_ashift_optimize(vdev_t *vd)
> {
> if (vd == vd->vdev_top &&
> (vd->vdev_ashift < vd->vdev_physical_ashift) &&
> (vd->vdev_ashift < zfs_max_auto_ashift)) {
> vd->vdev_ashift = MIN(zfs_max_auto_ashift,
> vd->vdev_physical_ashift);
> }
> }
>
> void
2597a2673,2676
> vs->vs_configured_ashift = vd->vdev_top != NULL
> ? vd->vdev_top->vdev_ashift : vd->vdev_ashift;
> vs->vs_logical_ashift = vd->vdev_logical_ashift;
> vs->vs_physical_ashift = vd->vdev_physical_ashift;