From owner-svn-src-head@freebsd.org Wed Oct 25 16:01:20 2017 Return-Path: Delivered-To: svn-src-head@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 40A99E4E38A; Wed, 25 Oct 2017 16:01:20 +0000 (UTC) (envelope-from asomers@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 0EAD57396C; Wed, 25 Oct 2017 16:01:19 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9PG1JWl032408; Wed, 25 Oct 2017 16:01:19 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9PG1JKC032407; Wed, 25 Oct 2017 16:01:19 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201710251601.v9PG1JKC032407@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 25 Oct 2017 16:01:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324991 - head/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: head/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Commit-Revision: 324991 X-SVN-Commit-Repository: base 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.23 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: Wed, 25 Oct 2017 16:01:20 -0000 Author: asomers Date: Wed Oct 25 16:01:19 2017 New Revision: 324991 URL: https://svnweb.freebsd.org/changeset/base/324991 Log: Fix zpool_read_all_labels when vfs.aio.enable_unsafe=0 Previously, zpool_read_all_labels was trying to do 256KB reads, which are greater than the default MAXPHYS and therefore must go through the slow, unsafe AIO path. Shrink these reads to 112KB so they can use the safe, fast AIO path instead. MFC after: 1 week X-MFC-With: 324568 Sponsored by: Spectra Logic Corp Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c Wed Oct 25 15:30:53 2017 (r324990) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c Wed Oct 25 16:01:19 2017 (r324991) @@ -930,7 +930,7 @@ zpool_read_all_labels(int fd, nvlist_t **config) struct aiocb aiocbs[VDEV_LABELS]; struct aiocb *aiocbps[VDEV_LABELS]; int l; - vdev_label_t *labels; + vdev_phys_t *labels; uint64_t state, txg, size; int nlabels = 0; @@ -940,15 +940,15 @@ zpool_read_all_labels(int fd, nvlist_t **config) return (0); size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t); - if ((labels = calloc(VDEV_LABELS, sizeof (vdev_label_t))) == NULL) + if ((labels = calloc(VDEV_LABELS, sizeof (vdev_phys_t))) == NULL) return (0); memset(aiocbs, 0, sizeof(aiocbs)); for (l = 0; l < VDEV_LABELS; l++) { aiocbs[l].aio_fildes = fd; - aiocbs[l].aio_offset = label_offset(size, l); + aiocbs[l].aio_offset = label_offset(size, l) + VDEV_SKIP_SIZE; aiocbs[l].aio_buf = &labels[l]; - aiocbs[l].aio_nbytes = sizeof(vdev_label_t); + aiocbs[l].aio_nbytes = sizeof(vdev_phys_t); aiocbs[l].aio_lio_opcode = LIO_READ; aiocbps[l] = &aiocbs[l]; } @@ -962,17 +962,18 @@ zpool_read_all_labels(int fd, nvlist_t **config) (void)aio_return(&aiocbs[l]); } } + free(labels); return (0); } for (l = 0; l < VDEV_LABELS; l++) { nvlist_t *temp = NULL; - if (aio_return(&aiocbs[l]) != sizeof(vdev_label_t)) + if (aio_return(&aiocbs[l]) != sizeof(vdev_phys_t)) continue; - if (nvlist_unpack(labels[l].vl_vdev_phys.vp_nvlist, - sizeof (labels[l].vl_vdev_phys.vp_nvlist), &temp, 0) != 0) + if (nvlist_unpack(labels[l].vp_nvlist, + sizeof (labels[l].vp_nvlist), &temp, 0) != 0) continue; if (nvlist_lookup_uint64(temp, ZPOOL_CONFIG_POOL_STATE,