vdev_disk.c (332525) | vdev_disk.c (332530) |
---|---|
1/* 2 * CDDL HEADER START 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 --- 6 unchanged lines hidden (view full) --- 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. | 1/* 2 * CDDL HEADER START 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 --- 6 unchanged lines hidden (view full) --- 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, 2015 by Delphix. All rights reserved. | 23 * Copyright (c) 2012, 2016 by Delphix. All rights reserved. |
24 * Copyright 2016 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/spa_impl.h> 30#include <sys/refcount.h> 31#include <sys/vdev_disk.h> --- 288 unchanged lines hidden (view full) --- 320 * 321 * 3. Otherwise, the device may have moved. Try opening the device 322 * by the devid instead. 323 */ 324 if (vd->vdev_devid != NULL) { 325 if (ddi_devid_str_decode(vd->vdev_devid, &dvd->vd_devid, 326 &dvd->vd_minor) != 0) { 327 vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL; | 24 * Copyright 2016 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/spa_impl.h> 30#include <sys/refcount.h> 31#include <sys/vdev_disk.h> --- 288 unchanged lines hidden (view full) --- 320 * 321 * 3. Otherwise, the device may have moved. Try opening the device 322 * by the devid instead. 323 */ 324 if (vd->vdev_devid != NULL) { 325 if (ddi_devid_str_decode(vd->vdev_devid, &dvd->vd_devid, 326 &dvd->vd_minor) != 0) { 327 vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL; |
328 vdev_dbgmsg(vd, "vdev_disk_open: invalid " 329 "vdev_devid '%s'", vd->vdev_devid); |
|
328 return (SET_ERROR(EINVAL)); 329 } 330 } 331 332 error = EINVAL; /* presume failure */ 333 334 if (vd->vdev_path != NULL) { 335 --- 76 unchanged lines hidden (view full) --- 412 */ 413 if (error && vd->vdev_path != NULL) 414 error = ldi_open_by_name(vd->vdev_path, spa_mode(spa), 415 kcred, &dvd->vd_lh, zfs_li); 416 } 417 418 if (error) { 419 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED; | 330 return (SET_ERROR(EINVAL)); 331 } 332 } 333 334 error = EINVAL; /* presume failure */ 335 336 if (vd->vdev_path != NULL) { 337 --- 76 unchanged lines hidden (view full) --- 414 */ 415 if (error && vd->vdev_path != NULL) 416 error = ldi_open_by_name(vd->vdev_path, spa_mode(spa), 417 kcred, &dvd->vd_lh, zfs_li); 418 } 419 420 if (error) { 421 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED; |
422 vdev_dbgmsg(vd, "vdev_disk_open: failed to open [error=%d]", 423 error); |
|
420 return (error); 421 } 422 423 /* 424 * Now that the device has been successfully opened, update the devid 425 * if necessary. 426 */ 427 if (validate_devid && spa_writeable(spa) && 428 ldi_get_devid(dvd->vd_lh, &devid) == 0) { 429 if (ddi_devid_compare(devid, dvd->vd_devid) != 0) { 430 char *vd_devid; 431 432 vd_devid = ddi_devid_str_encode(devid, dvd->vd_minor); | 424 return (error); 425 } 426 427 /* 428 * Now that the device has been successfully opened, update the devid 429 * if necessary. 430 */ 431 if (validate_devid && spa_writeable(spa) && 432 ldi_get_devid(dvd->vd_lh, &devid) == 0) { 433 if (ddi_devid_compare(devid, dvd->vd_devid) != 0) { 434 char *vd_devid; 435 436 vd_devid = ddi_devid_str_encode(devid, dvd->vd_minor); |
433 zfs_dbgmsg("vdev %s: update devid from %s, " 434 "to %s", vd->vdev_path, vd->vdev_devid, vd_devid); | 437 vdev_dbgmsg(vd, "vdev_disk_open: update devid from " 438 "'%s' to '%s'", vd->vdev_devid, vd_devid); |
435 spa_strfree(vd->vdev_devid); 436 vd->vdev_devid = spa_strdup(vd_devid); 437 ddi_devid_str_free(vd_devid); 438 } 439 ddi_devid_free(devid); 440 } 441 442 /* --- 43 unchanged lines hidden (view full) --- 486 &vdev_disk_dgrd_callb, (void *) vd, &lcb->lcb_id); 487 } 488skip_open: 489 /* 490 * Determine the actual size of the device. 491 */ 492 if (ldi_get_size(dvd->vd_lh, psize) != 0) { 493 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED; | 439 spa_strfree(vd->vdev_devid); 440 vd->vdev_devid = spa_strdup(vd_devid); 441 ddi_devid_str_free(vd_devid); 442 } 443 ddi_devid_free(devid); 444 } 445 446 /* --- 43 unchanged lines hidden (view full) --- 490 &vdev_disk_dgrd_callb, (void *) vd, &lcb->lcb_id); 491 } 492skip_open: 493 /* 494 * Determine the actual size of the device. 495 */ 496 if (ldi_get_size(dvd->vd_lh, psize) != 0) { 497 vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED; |
498 vdev_dbgmsg(vd, "vdev_disk_open: failed to get size"); |
|
494 return (SET_ERROR(EINVAL)); 495 } 496 497 *max_psize = *psize; 498 499 /* 500 * Determine the device's minimum transfer size. 501 * If the ioctl isn't supported, assume DEV_BSIZE. --- 418 unchanged lines hidden --- | 499 return (SET_ERROR(EINVAL)); 500 } 501 502 *max_psize = *psize; 503 504 /* 505 * Determine the device's minimum transfer size. 506 * If the ioctl isn't supported, assume DEV_BSIZE. --- 418 unchanged lines hidden --- |