From owner-svn-src-vendor@freebsd.org Mon Jun 3 20:52:21 2019 Return-Path: Delivered-To: svn-src-vendor@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E460015BDBB5; Mon, 3 Jun 2019 20:52:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 89F816F402; Mon, 3 Jun 2019 20:52:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64127B7CA; Mon, 3 Jun 2019 20:52:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x53KqKhh048062; Mon, 3 Jun 2019 20:52:20 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x53KqKvX048061; Mon, 3 Jun 2019 20:52:20 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201906032052.x53KqKvX048061@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 3 Jun 2019 20:52:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r348585 - vendor-sys/illumos/dist/uts/common/fs/zfs X-SVN-Group: vendor-sys X-SVN-Commit-Author: mav X-SVN-Commit-Paths: vendor-sys/illumos/dist/uts/common/fs/zfs X-SVN-Commit-Revision: 348585 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 89F816F402 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2019 20:52:21 -0000 Author: mav Date: Mon Jun 3 20:52:19 2019 New Revision: 348585 URL: https://svnweb.freebsd.org/changeset/base/348585 Log: 9683 Allow bypassing devid in vdev_disk_open() illumos/illumos-gate@6fe4f3002ca33af5ab7123ed78d81899dadf2fbb Reviewed by: Sara Hartse Reviewed by: George Wilson Approved by: Dan McDonald Author: Pavel Zakharov Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/vdev_disk.c Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/vdev_disk.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/vdev_disk.c Mon Jun 3 20:49:20 2019 (r348584) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/vdev_disk.c Mon Jun 3 20:52:19 2019 (r348585) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2016 by Delphix. All rights reserved. + * Copyright (c) 2012, 2018 by Delphix. All rights reserved. * Copyright 2016 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2013 Joyent, Inc. All rights reserved. */ @@ -57,6 +57,21 @@ typedef struct vdev_disk_ldi_cb { ldi_callback_id_t lcb_id; } vdev_disk_ldi_cb_t; +/* + * Bypass the devid when opening a disk vdev. + * There have been issues where the devids of several devices were shuffled, + * causing pool open failures. Note, that this flag is intended to be used + * for pool recovery only. + * + * Note that if a pool is imported with the devids bypassed, all its vdevs will + * cease storing devid information permanently. In practice, the devid is rarely + * useful as vdev paths do not tend to change unless the hardware is + * reconfigured. That said, if the paths do change and a pool fails to open + * automatically at boot, a simple zpool import should re-scan the paths and fix + * the issue. + */ +boolean_t vdev_disk_bypass_devid = B_FALSE; + static void vdev_disk_alloc(vdev_t *vd) { @@ -313,6 +328,16 @@ vdev_disk_open(vdev_t *vd, uint64_t *psize, uint64_t * dvd = vd->vdev_tsd; /* + * Allow bypassing the devid. + */ + if (vd->vdev_devid != NULL && vdev_disk_bypass_devid) { + vdev_dbgmsg(vd, "vdev_disk_open, devid %s bypassed", + vd->vdev_devid); + spa_strfree(vd->vdev_devid); + vd->vdev_devid = NULL; + } + + /* * When opening a disk device, we want to preserve the user's original * intent. We always want to open the device by the path the user gave * us, even if it is one of multiple paths to the same device. But we @@ -374,6 +399,19 @@ vdev_disk_open(vdev_t *vd, uint64_t *psize, uint64_t * if (error == 0 && vd->vdev_devid != NULL && ldi_get_devid(dvd->vd_lh, &devid) == 0) { if (ddi_devid_compare(devid, dvd->vd_devid) != 0) { + /* + * A mismatch here is unexpected, log it. + */ + char *devid_str = ddi_devid_str_encode(devid, + dvd->vd_minor); + vdev_dbgmsg(vd, "vdev_disk_open: devid " + "mismatch: %s != %s", vd->vdev_devid, + devid_str); + cmn_err(CE_NOTE, "vdev_disk_open %s: devid " + "mismatch: %s != %s", vd->vdev_path, + vd->vdev_devid, devid_str); + ddi_devid_str_free(devid_str); + error = SET_ERROR(EINVAL); (void) ldi_close(dvd->vd_lh, spa_mode(spa), kcred); @@ -397,6 +435,10 @@ vdev_disk_open(vdev_t *vd, uint64_t *psize, uint64_t * if (error != 0 && vd->vdev_devid != NULL) { error = ldi_open_by_devid(dvd->vd_devid, dvd->vd_minor, spa_mode(spa), kcred, &dvd->vd_lh, zfs_li); + if (error != 0) { + vdev_dbgmsg(vd, "Failed to open by devid (%s)", + vd->vdev_devid); + } } /* @@ -443,6 +485,9 @@ vdev_disk_open(vdev_t *vd, uint64_t *psize, uint64_t * vd_devid = ddi_devid_str_encode(devid, dvd->vd_minor); vdev_dbgmsg(vd, "vdev_disk_open: update devid from " "'%s' to '%s'", vd->vdev_devid, vd_devid); + cmn_err(CE_NOTE, "vdev_disk_open %s: update devid " + "from '%s' to '%s'", vd->vdev_path != NULL ? + vd->vdev_path : "?", vd->vdev_devid, vd_devid); spa_strfree(vd->vdev_devid); vd->vdev_devid = spa_strdup(vd_devid); ddi_devid_str_free(vd_devid);