From nobody Tue Jan 18 20:29:11 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D5190196D3BE; Tue, 18 Jan 2022 20:29:11 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JdgNR5f8jz3F5K; Tue, 18 Jan 2022 20:29:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642537751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=z2vDHWF+JuDEDzI4c6dUluDggA3LObkqleoeCYqqKy8=; b=jffkfh9516kJZExQL7EAdz73vVJF3snSJNrsXE7bXgmy5PTFbRI5m2yXY0ZtDLsVA/i5n2 9GOJakiz27on8AiJs9zhsPkiwpzVQ+xlPYqP71dA3YsgD4E7QVMQyZ8YEv+gGQ33rTjK/t DMTEMiRo2cGDUTkDe8ck0TjGZSmTs3PkkhR/ezqkTxeIJ3T/sjje+5xyIlcT+V1RPVC2es /kRuiHsinphNDYFBCb7k9t4GS5CH5tBwaczDT0ymSnVPkMAuWBh51/GSs9yFG51y+Y2xRw P89IihIRMOtKVx/HIHMPIX0Ce6FZw9ibiUvuL4fR2gZH7/q3tF7LbGWTA50gYQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A1A1E27978; Tue, 18 Jan 2022 20:29:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20IKTBuD067196; Tue, 18 Jan 2022 20:29:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20IKTBbK067195; Tue, 18 Jan 2022 20:29:11 GMT (envelope-from git) Date: Tue, 18 Jan 2022 20:29:11 GMT Message-Id: <202201182029.20IKTBbK067195@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Wing Subject: git: ae9ea22e14bf - main - bhyve: get mediasize for character devices when resizing virtio-blk List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ae9ea22e14bf523aee508f1fe07091580b528a2e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642537751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=z2vDHWF+JuDEDzI4c6dUluDggA3LObkqleoeCYqqKy8=; b=v5Rl5U48bb2wjLic4/+ryoSY1L/wtTx+s536hHrMA+T7nNuTVk0THSTUCygNK4HsOjltGH 2pbEfvE2SrtojoHE5dp5rqEXNXozSdHaxod6OAEhgg1JPxXbEXFVhi89ft4apIXAPFWoTf RJuZOuvIDXPD+qv1f7hOT+9R0C+2AEauOuSdTKkDpnGZLOZpEj/tVliSkTGnArYbZI0A4W 5BkLAcGVg5iboY7vcwgZsfvTSDywgPtWFIkf0OoMkJLIG2Bqr/Ve17t2tOQ0y/GLTKWE48 SxzYM+MR0FrDtjzCZhBG9X5v1/F8vxsQG+3OS5Hu2GSytp1Mvs/keLVaXGBHaQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642537751; a=rsa-sha256; cv=none; b=EK1D7c4SZfbSHN5dglLQ/9tBlSPUoz4SllZU7N9D2EHXeS0Y6lBO3a/1kLqSkIJqvaHS9L +pcyNdBKMjPGFd+EXfRlvLGgeV0S/sFw93eDYtF9AsMKMuL544XqaPciFdR06O3TDppOYA 63F17pjMOpCJfclCHFaKY/YOpM9b6yxdVfx7bKv9nrubgeETegCLy8tBSwbegcfBX8Dtt+ XNjlxDjzPwuXT3nIt231qUvNTWowfV3XVEvm8hwBYJsjqCN7OJGvbW1fIvToTVeQyJg0Qv Ewbl580zonjLNVB6Tmu4HYqhkecSG4h26q38wgja2r23ffS5D5+KBm+YWMwf5g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=ae9ea22e14bf523aee508f1fe07091580b528a2e commit ae9ea22e14bf523aee508f1fe07091580b528a2e Author: Robert Wing AuthorDate: 2022-01-18 20:26:49 +0000 Commit: Robert Wing CommitDate: 2022-01-18 20:26:49 +0000 bhyve: get mediasize for character devices when resizing virtio-blk Reviewed by: imp, allanjude, jhb Differential Revision: https://reviews.freebsd.org/D33403 --- usr.sbin/bhyve/block_if.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c index 4003bc438a58..217f7181de75 100644 --- a/usr.sbin/bhyve/block_if.c +++ b/usr.sbin/bhyve/block_if.c @@ -667,14 +667,24 @@ blockif_resized(int fd, enum ev_type type, void *arg) { struct blockif_ctxt *bc; struct stat sb; + off_t mediasize; if (fstat(fd, &sb) != 0) return; + if (S_ISCHR(sb.st_mode)) { + if (ioctl(fd, DIOCGMEDIASIZE, &mediasize) < 0) { + EPRINTLN("blockif_resized: get mediasize failed: %s", + strerror(errno)); + return; + } + } else + mediasize = sb.st_size; + bc = arg; pthread_mutex_lock(&bc->bc_mtx); - if (sb.st_size != bc->bc_size) { - bc->bc_size = sb.st_size; + if (mediasize != bc->bc_size) { + bc->bc_size = mediasize; bc->bc_resize_cb(bc, bc->bc_resize_cb_arg, bc->bc_size); } pthread_mutex_unlock(&bc->bc_mtx);