From owner-svn-src-head@FreeBSD.ORG Sat Apr 6 17:24:01 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 87A5E84B; Sat, 6 Apr 2013 17:24:01 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 79F55820; Sat, 6 Apr 2013 17:24:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r36HO1qD070133; Sat, 6 Apr 2013 17:24:01 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r36HO18T070122; Sat, 6 Apr 2013 17:24:01 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201304061724.r36HO18T070122@svn.freebsd.org> From: Martin Matuska Date: Sat, 6 Apr 2013 17:24:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249209 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Apr 2013 17:24:01 -0000 Author: mm Date: Sat Apr 6 17:24:00 2013 New Revision: 249209 URL: http://svnweb.freebsd.org/changeset/base/249209 Log: MFV r249186: Do not list read-only pools in zpool.cache Reduce diff against vendor in unused vdev_disk.c Illumos ZFS issues: 3639 zpool.cache should skip over readonly pools 3640 want automatic devid updates MFC after: 1 week Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c Directory Properties: head/sys/cddl/contrib/opensolaris/ (props changed) Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c Sat Apr 6 17:20:22 2013 (r249208) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c Sat Apr 6 17:24:00 2013 (r249209) @@ -220,7 +220,15 @@ spa_config_sync(spa_t *target, boolean_t */ nvl = NULL; while ((spa = spa_next(spa)) != NULL) { - if (spa == target && removing) + /* + * Skip over our own pool if we're about to remove + * ourselves from the spa namespace or any pool that + * is readonly. Since we cannot guarantee that a + * readonly pool would successfully import upon reboot, + * we don't allow them to be written to the cache file. + */ + if ((spa == target && removing) || + !spa_writeable(spa)) continue; mutex_enter(&spa->spa_props_lock); Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c Sat Apr 6 17:20:22 2013 (r249208) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c Sat Apr 6 17:24:00 2013 (r249209) @@ -144,6 +144,8 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi int error; dev_t dev; int otyp; + boolean_t validate_devid = B_FALSE; + ddi_devid_t devid; /* * We must have a pathname, and it must be absolute. @@ -192,7 +194,6 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi error = EINVAL; /* presume failure */ if (vd->vdev_path != NULL) { - ddi_devid_t devid; if (vd->vdev_wholedisk == -1ULL) { size_t len = strlen(vd->vdev_path) + 3; @@ -241,9 +242,10 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi * If we were unable to open by path, or the devid check fails, open by * devid instead. */ - if (error != 0 && vd->vdev_devid != NULL) + 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 all else fails, then try opening by physical path (if available) @@ -252,6 +254,9 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi * level vdev validation will prevent us from opening the wrong device. */ if (error) { + if (vd->vdev_devid != NULL) + validate_devid = B_TRUE; + if (vd->vdev_physpath != NULL && (dev = ddi_pathname_to_dev_t(vd->vdev_physpath)) != NODEV) error = ldi_open_by_dev(&dev, OTYP_BLK, spa_mode(spa), @@ -273,6 +278,25 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi } /* + * Now that the device has been successfully opened, update the devid + * if necessary. + */ + if (validate_devid && spa_writeable(spa) && + ldi_get_devid(dvd->vd_lh, &devid) == 0) { + if (ddi_devid_compare(devid, dvd->vd_devid) != 0) { + char *vd_devid; + + vd_devid = ddi_devid_str_encode(devid, dvd->vd_minor); + zfs_dbgmsg("vdev %s: update devid from %s, " + "to %s", 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); + } + ddi_devid_free(devid); + } + + /* * Once a device is opened, verify that the physical device path (if * available) is up to date. */