From nobody Wed Feb 23 17:44:45 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 A184319E8037; Wed, 23 Feb 2022 17:44:45 +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 4K3k253zMkz3Dnm; Wed, 23 Feb 2022 17:44:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645638285; 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=9auAjpM6pCDljCdBTqLQuA9P6ch/D+5FeDP/JDj32FA=; b=x5ujJoWPUzzmjj8G/mtOGDHlcIroEsfDsxOxL24IOsMa8mlViCWfXI7ym5z2BSeVatJauI J9dGX+hZ8TMPviGOvVHrRM4goOs8aB8IDWdj42gYuqlqbyYG+rES14+p2fngAsueBpvptm mnrY6cc+xhdaKPuhfLJskjTex6BkcV2csy0UYSiJTvW8IPlExgmavtBf46p0OYD2RpNf7C FRCO3Zae0S/ouybvbXPXu7mwNhj+LbYmek8tSoH6V8YOmhwAiMzkmVkZmW0zmVK+ZxcfVp RP3E+ALArY6IPJKKeV86rNhG1NKAkLSuasoPMknxtkcXQyS7BCuAfGimheml6g== 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 643AD1C3D2; Wed, 23 Feb 2022 17:44:45 +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 21NHijHb088412; Wed, 23 Feb 2022 17:44:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21NHijkj088411; Wed, 23 Feb 2022 17:44:45 GMT (envelope-from git) Date: Wed, 23 Feb 2022 17:44:45 GMT Message-Id: <202202231744.21NHijkj088411@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Wing Subject: git: 847cdccdb0f1 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 847cdccdb0f1992b74f0c73805461396070511fc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645638285; 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=9auAjpM6pCDljCdBTqLQuA9P6ch/D+5FeDP/JDj32FA=; b=oFetL4r4l/On5bzRl1it9FU9AbK9El451GZVFeNBFdJxjqSV9xoz33Kc39xMS/wYqyW2ne Q7z//+Srk19d9ehiGBeTJKg3e5XIKuiexy1u5yyS1PWjYRKVXJGmW1wgkzyFi65yMmG1S/ HAWR63FOw5pHNNbOewz2iJUHiRCA1VdNBTpRdkl8Ep1GtIQQU/LI+A41fweAtyxk7J1tK3 hQXTHperf1LhdB6IRM29p3NVo5pICd/TSi31Rqxl4i7ZpPiqyhE7sCuUAJt1iufhM+t9Jw I387os6n5oFVIxjvJ8AUG4mphMcVxrZa8+gC/wRvJEwjN032cAY2r+rUd/Jdkw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645638285; a=rsa-sha256; cv=none; b=MqQF/E6t6XKkngrAhZWdqkvzKFHOBVwdlPExhBIPldtbhT6i4OfXAlhgKCzCd8W3uqHK9/ GRUcC98RIsYavkGYi8gfZRzSfosdhnJfHbdxs4wiWGmpOS9srCaMe5sveHekOF46oBLdvk 2M6GRgiyly3IzYqt2+4/7Ih4bMKJgA3E41Y89ScPGSopEusc8cfPGQt743J2HRRkpedBEn yPtN7Z6QH99tJQ6vfeBpj/EAnWiBZxjzNdi07Ad3s9VV3K0nZND1sNa3XurrufX9QkzdlW gDk6zmFa5K2SjHLb0C8GcI9gZULJ1EqmMgZvh/HXrYOvHsRHXy4PWtyZ0MxfrA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=847cdccdb0f1992b74f0c73805461396070511fc commit 847cdccdb0f1992b74f0c73805461396070511fc Author: Robert Wing AuthorDate: 2022-01-18 20:26:49 +0000 Commit: Robert Wing CommitDate: 2022-02-23 17:43:14 +0000 bhyve: get mediasize for character devices when resizing virtio-blk Reviewed by: imp, allanjude, jhb Differential Revision: https://reviews.freebsd.org/D33403 (cherry picked from commit ae9ea22e14bf523aee508f1fe07091580b528a2e) --- 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 b12029ec4f04..0d41b5175166 100644 --- a/usr.sbin/bhyve/block_if.c +++ b/usr.sbin/bhyve/block_if.c @@ -651,14 +651,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);