3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2013 by Delphix. All rights reserved.
24 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2013 Joyent, Inc. All rights reserved.
26 */
27
28 #include <sys/zfs_context.h>
29 #include <sys/zfs_zone.h>
30 #include <sys/spa_impl.h>
31 #include <sys/refcount.h>
32 #include <sys/vdev_disk.h>
33 #include <sys/vdev_impl.h>
34 #include <sys/fs/zfs.h>
35 #include <sys/zio.h>
36 #include <sys/sunldi.h>
37 #include <sys/efi_partition.h>
38 #include <sys/fm/fs/zfs.h>
39
40 /*
41 * Virtual device vector for disks.
42 */
43
531 if ((error = ldi_ioctl(dvd->vd_lh, DKIOCGMEDIAINFOEXT,
532 (intptr_t)dkmext, FKIOCTL, kcred, NULL)) == 0) {
533 capacity = dkmext->dki_capacity - 1;
534 blksz = dkmext->dki_lbsize;
535 pbsize = dkmext->dki_pbsize;
536 } else if ((error = ldi_ioctl(dvd->vd_lh, DKIOCGMEDIAINFO,
537 (intptr_t)dkm, FKIOCTL, kcred, NULL)) == 0) {
538 VDEV_DEBUG(
539 "vdev_disk_open(\"%s\"): fallback to DKIOCGMEDIAINFO\n",
540 vd->vdev_path);
541 capacity = dkm->dki_capacity - 1;
542 blksz = dkm->dki_lbsize;
543 pbsize = blksz;
544 } else {
545 VDEV_DEBUG("vdev_disk_open(\"%s\"): "
546 "both DKIOCGMEDIAINFO{,EXT} calls failed, %d\n",
547 vd->vdev_path, error);
548 pbsize = DEV_BSIZE;
549 }
550
551 *ashift = highbit(MAX(pbsize, SPA_MINBLOCKSIZE)) - 1;
552
553 if (vd->vdev_wholedisk == 1) {
554 int wce = 1;
555
556 if (error == 0) {
557 /*
558 * If we have the capability to expand, we'd have
559 * found out via success from DKIOCGMEDIAINFO{,EXT}.
560 * Adjust max_psize upward accordingly since we know
561 * we own the whole disk now.
562 */
563 *max_psize += vdev_disk_get_space(vd, capacity, blksz);
564 zfs_dbgmsg("capacity change: vdev %s, psize %llu, "
565 "max_psize %llu", vd->vdev_path, *psize,
566 *max_psize);
567 }
568
569 /*
570 * Since we own the whole disk, try to enable disk write
571 * caching. We ignore errors because it's OK if we can't do it.
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
24 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2013 Joyent, Inc. All rights reserved.
26 */
27
28 #include <sys/zfs_context.h>
29 #include <sys/zfs_zone.h>
30 #include <sys/spa_impl.h>
31 #include <sys/refcount.h>
32 #include <sys/vdev_disk.h>
33 #include <sys/vdev_impl.h>
34 #include <sys/fs/zfs.h>
35 #include <sys/zio.h>
36 #include <sys/sunldi.h>
37 #include <sys/efi_partition.h>
38 #include <sys/fm/fs/zfs.h>
39
40 /*
41 * Virtual device vector for disks.
42 */
43
531 if ((error = ldi_ioctl(dvd->vd_lh, DKIOCGMEDIAINFOEXT,
532 (intptr_t)dkmext, FKIOCTL, kcred, NULL)) == 0) {
533 capacity = dkmext->dki_capacity - 1;
534 blksz = dkmext->dki_lbsize;
535 pbsize = dkmext->dki_pbsize;
536 } else if ((error = ldi_ioctl(dvd->vd_lh, DKIOCGMEDIAINFO,
537 (intptr_t)dkm, FKIOCTL, kcred, NULL)) == 0) {
538 VDEV_DEBUG(
539 "vdev_disk_open(\"%s\"): fallback to DKIOCGMEDIAINFO\n",
540 vd->vdev_path);
541 capacity = dkm->dki_capacity - 1;
542 blksz = dkm->dki_lbsize;
543 pbsize = blksz;
544 } else {
545 VDEV_DEBUG("vdev_disk_open(\"%s\"): "
546 "both DKIOCGMEDIAINFO{,EXT} calls failed, %d\n",
547 vd->vdev_path, error);
548 pbsize = DEV_BSIZE;
549 }
550
551 *ashift = highbit64(MAX(pbsize, SPA_MINBLOCKSIZE)) - 1;
552
553 if (vd->vdev_wholedisk == 1) {
554 int wce = 1;
555
556 if (error == 0) {
557 /*
558 * If we have the capability to expand, we'd have
559 * found out via success from DKIOCGMEDIAINFO{,EXT}.
560 * Adjust max_psize upward accordingly since we know
561 * we own the whole disk now.
562 */
563 *max_psize += vdev_disk_get_space(vd, capacity, blksz);
564 zfs_dbgmsg("capacity change: vdev %s, psize %llu, "
565 "max_psize %llu", vd->vdev_path, *psize,
566 *max_psize);
567 }
568
569 /*
570 * Since we own the whole disk, try to enable disk write
571 * caching. We ignore errors because it's OK if we can't do it.
|