From nobody Tue Apr 16 20:13:08 2024 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 4VJwFw5vSGz5H0bS; Tue, 16 Apr 2024 20:13:08 +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 4VJwFw3Czmz4tpw; Tue, 16 Apr 2024 20:13:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298388; 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=SWfgNThFvZP4DkW4oufbMzx9s2g79aQDT/hbLgi8iyE=; b=h9Wfggg2nKH2V5Gowdw5lRHEtc/JdG3X1Jb6lGWpET7ggC55NJB4mqLd/AwjyfMj/VyxnV OT7tsMjtMRYrcEFxB4FXuwberz6G0iUsALX2EquYQDYsxXjhxdajN19g9/xi3JqZZDBX2U 14RZaJ7zIeYhfwxgPxBwNG2Jp08qFet08jxHxGzBRsoGTqokH7X7zQwmik4lyNmz3nCXUn OFOVFWVTinW5U+u/56ff+jMDTQ3hfa6pnc6ekNa0hc50ArRy7kTkstzDKT/j/MDgiWdnRg FHP8fDjoZc+NIQEr7KfdmIWGOeMRHojlX9hDXDqH+jVXUvgRdK6SP01BKQSC6w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713298388; a=rsa-sha256; cv=none; b=eUp27yB60sSuezEOHHyc0+IP4MsrF2K3kwHaUClwKAl1DAO3uRXPg7H1Fm14fisV9prNzH Z8zwL9uhoRBsGX0pc/eJ5aibnz9vghhtpwlB0ZD66BSEIrWnNAXWHBqfxRfHBZ5YD1w/DD kQJFcvF0R2cUdRUsILj+2/ppULd6zgK59OniC29KQnDTjCA9OP/ncsPeT+Npai4mx1t231 WdFsQqCnGXoP5s5SaZYhysgl/YK5/dwy3FFVDygel+B7WZgsMcuyrNAzLX4RPSu37nZ7Dq HtOWju8LbgMVD69rJlKT6zaEO/1Bjlf3RhMS1PQr3ddpuDmkYtrwRA0ZCHob5g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298388; 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=SWfgNThFvZP4DkW4oufbMzx9s2g79aQDT/hbLgi8iyE=; b=e6LpewZHnn9C5M9Ex6Oq45h/PPorDlD3jAry41gzkBAZMBsG7qH3kkvIVHxAmvRi5lPqOw LdUZE1NhZYKZz5bh1x1iyzTBNqvQnZH9Go7RVmatOoYBHHdOHww96bKe+lRPwB0/1xLu6a Qd4+3YpTqCszmy7hBRoCbdwU4f6zKwQtPCfuC+EHehA3bQ92TfYYpay9CJXEqwkfGSV55n w0I8U8PbYeFU8iaOrO3J0FPU2WeeyJYCFSRzddSt0mUYZsj6oYGf7synCeovZAGiPNGoAf dFl/EpcmI8oIYgIb+hU88ouJ5M+t8NvakC7mqpsYCfV1BHOH9vTfNXppF/Zxhw== 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 4VJwFw2ngTzxWT; Tue, 16 Apr 2024 20:13:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43GKD8XM038831; Tue, 16 Apr 2024 20:13:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43GKD8Ql038828; Tue, 16 Apr 2024 20:13:08 GMT (envelope-from git) Date: Tue, 16 Apr 2024 20:13:08 GMT Message-Id: <202404162013.43GKD8Ql038828@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 7209dd3eba78 - stable/14 - kboot: Implement write support for hostdisk 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 7209dd3eba787f07484570edaac5aa0b8db96f18 Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=7209dd3eba787f07484570edaac5aa0b8db96f18 commit 7209dd3eba787f07484570edaac5aa0b8db96f18 Author: Warner Losh AuthorDate: 2024-02-22 15:17:48 +0000 Commit: Warner Losh CommitDate: 2024-04-16 19:54:26 +0000 kboot: Implement write support for hostdisk Don't assume that strategy is only called for read. Check the passed flag for F_READ or F_WRITE and fail if it is neither. Open the disks for writing and call host_read/host_write depending on that flag. Sponsored by: Netflix Reviewed by: kevans, gallatin Differential Revision: https://reviews.freebsd.org/D44016 (cherry picked from commit b3e76e3d9e2262c4b79e81e63e09bfe62c1f6baa) --- stand/kboot/kboot/hostdisk.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/stand/kboot/kboot/hostdisk.c b/stand/kboot/kboot/hostdisk.c index 423151983523..a9117d4c1c9d 100644 --- a/stand/kboot/kboot/hostdisk.c +++ b/stand/kboot/kboot/hostdisk.c @@ -305,7 +305,6 @@ hostdisk_strategy(void *devdata, int flag, daddr_t dblk, size_t size, struct devdesc *desc = devdata; daddr_t pos; int n; - int64_t off; uint64_t res; uint32_t posl, posh; @@ -313,12 +312,14 @@ hostdisk_strategy(void *devdata, int flag, daddr_t dblk, size_t size, posl = pos & 0xffffffffu; posh = (pos >> 32) & 0xffffffffu; - if ((off = host_llseek(desc->d_unit, posh, posl, &res, 0)) < 0) { - printf("Seek error on fd %d to %ju (dblk %ju) returns %jd\n", - desc->d_unit, (uintmax_t)pos, (uintmax_t)dblk, (intmax_t)off); + if (host_llseek(desc->d_unit, posh, posl, &res, 0) < 0) return (EIO); - } - n = host_read(desc->d_unit, buf, size); + if (flag & F_READ) + n = host_read(desc->d_unit, buf, size); + else if (flag & F_WRITE) + n = host_write(desc->d_unit, buf, size); + else + return (EINVAL); if (n < 0) return (EIO); @@ -339,7 +340,7 @@ hostdisk_open(struct open_file *f, ...) va_end(vl); fn = dev2hd(desc)->hd_dev; - desc->d_unit = host_open(fn, O_RDONLY, 0); + desc->d_unit = host_open(fn, O_RDWR, 0); if (desc->d_unit <= 0) { printf("hostdisk_open: couldn't open %s: %d\n", fn, errno); return (ENOENT);