From owner-svn-src-stable@freebsd.org Fri Mar 17 11:45:17 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 42371D0E7CA; Fri, 17 Mar 2017 11:45:17 +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 mx1.freebsd.org (Postfix) with ESMTPS id 1CE941EE8; Fri, 17 Mar 2017 11:45:17 +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 v2HBjGYi005876; Fri, 17 Mar 2017 11:45:16 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2HBjGHH005875; Fri, 17 Mar 2017 11:45:16 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703171145.v2HBjGHH005875@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 17 Mar 2017 11:45:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315446 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Mar 2017 11:45:17 -0000 Author: mav Date: Fri Mar 17 11:45:16 2017 New Revision: 315446 URL: https://svnweb.freebsd.org/changeset/base/315446 Log: MFC r309856: Postpone ZVOL media/block size caching till first open. At least on FreeBSD there are no legal way to access media or get its size without opening device/provider first. Postponing this caching allows to skip several disk seeks per ZVOL/snapshot during import. For HDD pool with 1 ZVOL in dev mode with 1000 snapshots this reduces pool import time from 40 to 10 seconds. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Fri Mar 17 11:44:16 2017 (r315445) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Fri Mar 17 11:45:16 2017 (r315446) @@ -594,14 +594,14 @@ zvol_create_minor(const char *name) zfs_soft_state_t *zs; zvol_state_t *zv; objset_t *os; - dmu_object_info_t doi; #ifdef illumos + dmu_object_info_t doi; minor_t minor = 0; char chrbuf[30], blkbuf[30]; #else struct g_provider *pp; struct g_geom *gp; - uint64_t volsize, mode; + uint64_t mode; #endif int error; @@ -667,20 +667,12 @@ zvol_create_minor(const char *name) zv = kmem_zalloc(sizeof(*zv), KM_SLEEP); zv->zv_state = 0; - error = zap_lookup(os, ZVOL_ZAP_OBJ, "size", 8, 1, &volsize); - if (error) { - kmem_free(zv, sizeof(*zv)); - dmu_objset_disown(os, zvol_tag); - mutex_exit(&zfsdev_state_lock); - return (error); - } error = dsl_prop_get_integer(name, zfs_prop_to_name(ZFS_PROP_VOLMODE), &mode, NULL); if (error != 0 || mode == ZFS_VOLMODE_DEFAULT) mode = volmode; DROP_GIANT(); - zv->zv_volsize = volsize; zv->zv_volmode = mode; if (zv->zv_volmode == ZFS_VOLMODE_GEOM) { g_topology_lock(); @@ -690,7 +682,7 @@ zvol_create_minor(const char *name) pp = g_new_providerf(gp, "%s/%s", ZVOL_DRIVER, name); pp->flags |= G_PF_DIRECT_RECEIVE | G_PF_DIRECT_SEND; pp->sectorsize = DEV_BSIZE; - pp->mediasize = zv->zv_volsize; + pp->mediasize = 0; pp->private = zv; zv->zv_provider = pp; @@ -733,10 +725,12 @@ zvol_create_minor(const char *name) sizeof (rl_t), offsetof(rl_t, r_node)); list_create(&zv->zv_extents, sizeof (zvol_extent_t), offsetof(zvol_extent_t, ze_node)); +#ifdef illumos /* get and cache the blocksize */ error = dmu_object_info(os, ZVOL_OBJ, &doi); ASSERT(error == 0); zv->zv_volblocksize = doi.doi_data_block_size; +#endif if (spa_writeable(dmu_objset_spa(os))) { if (zil_replay_disable) @@ -828,6 +822,7 @@ zvol_remove_minor(const char *name) int zvol_first_open(zvol_state_t *zv) { + dmu_object_info_t doi; objset_t *os; uint64_t volsize; int error; @@ -847,6 +842,15 @@ zvol_first_open(zvol_state_t *zv) return (error); } + /* get and cache the blocksize */ + error = dmu_object_info(os, ZVOL_OBJ, &doi); + if (error) { + ASSERT(error == 0); + dmu_objset_disown(os, zvol_tag); + return (error); + } + zv->zv_volblocksize = doi.doi_data_block_size; + error = dmu_bonus_hold(os, ZVOL_OBJ, zvol_tag, &zv->zv_dbuf); if (error) { dmu_objset_disown(os, zvol_tag);