From nobody Tue Jul 19 07:37:19 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 4Ln9dq6cNDz4Wbnn; Tue, 19 Jul 2022 07:37:19 +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 4Ln9dq5m7kz3pnb; Tue, 19 Jul 2022 07:37:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658216239; 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=y7c0xhRkeYNnBXXro+WyRv6R104/SQ+rYbdOW+LSTM0=; b=MVKKy11eRgg/Tb4tYQ3mh7/27W0ktTZpZAw9AlWe8wy3WYL/ld2zEQrHNMi0TlB60zdCa4 eqF5fLu7/o7JI4tVzzOhU2QQNJdD2kwzos/3r9phkf9APO7El0J3C4igjQ8M5kW6bwPoYy XMoZE9FCHhXYDoPPizLvrgkr/1TkIZEFhhbtHuUSU7deyNW8/KYY1BJ12Yc6SmcUG11A4x RPPE70KmAmbXMHasIWPCb52Uar767tzqFswKp/XqpJxQF6Ae3VrEFsYuhL3/NaJr6naGAj QGPD9PQW8LTFsLsXduP0hu7NG4mWXyQI17zIL1qUXIAJosMqfQRrFrGCO5vlAA== 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 4Ln9dq4lgKz19SJ; Tue, 19 Jul 2022 07:37:19 +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 26J7bJ3s021454; Tue, 19 Jul 2022 07:37:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26J7bJno021453; Tue, 19 Jul 2022 07:37:19 GMT (envelope-from git) Date: Tue, 19 Jul 2022 07:37:19 GMT Message-Id: <202207190737.26J7bJno021453@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: a290c3d70398 - stable/13 - Remove PAGE_SIZE from hastd 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: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a290c3d703981a54f3c24333d046727a7109db59 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658216239; 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=y7c0xhRkeYNnBXXro+WyRv6R104/SQ+rYbdOW+LSTM0=; b=dyDQ7MVOmDPrzfwdD+o2DvgVeC67hgXrjVn8AsfcTZxdFLI8z3H1UyWwOXFzKrEVVTxpR1 LGFS6te6L8yf/sB/sPDDkjT9cIvS7asS8ITrJu0ZdTZ8EUCWjTdWIkONDyYr8GLMBL2ZGA cJRblwduCQmOG7MCMzSP0rGn4NfzY/bd37dby1oQlEB2g7tAmCdg3443GvsVlwKc16fOs3 saDAcjonjHinCbbwfBMqq+16Xf4AU4PJPEAurMhXQdg4cfT5SooRfapENZr2BT5eQkh+LH MCtBd7F3qyLAfopGdtYglbGdbIl8HDWqXW+lXTrxDLK3FpGx3JyNq54oeztQnw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658216239; a=rsa-sha256; cv=none; b=J9yTHAQzPOmdguNEiw1mqf2vIKigYEflXCfPRMOqBVN/1BKrFenaWpAdu57olpOufm6q1/ 2f4YSQ9pV4v+whHFl6UnczXJ8wkcei5nDD//KvBG83d/WVWaHO6c3/vom24IONMMUKMhun NFCIJ9BdHvRxqYnp37uxlFHB4QsMmvMuXHfhH3TgqJhGt+4Cn5OBWsVfDtxYE9lFQ8iQjs hSIouYCxRtg1YrLTpdW5jVITYNck6nVHMFV4XLAiJDqwlP5U6TtjR+C/OME5mbG3Ebk9qH 6lexnUtRQrpKmeyMT+Pzv8j9ENv0ZHKj2jmR1GUQB3up3dt1Vb/+eoL0/kB5wA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=a290c3d703981a54f3c24333d046727a7109db59 commit a290c3d703981a54f3c24333d046727a7109db59 Author: Andrew Turner AuthorDate: 2022-05-03 13:59:33 +0000 Commit: Andrew Turner CommitDate: 2022-07-19 07:03:30 +0000 Remove PAGE_SIZE from hastd It may not be known at compile time so we should detect it at run time. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35118 (cherry picked from commit ea578b34cb35505e7253c4d8f279fed1d38380ee) --- sbin/hastd/ebuf.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sbin/hastd/ebuf.c b/sbin/hastd/ebuf.c index 22d3251ec75c..83f99f834288 100644 --- a/sbin/hastd/ebuf.c +++ b/sbin/hastd/ebuf.c @@ -70,12 +70,14 @@ struct ebuf * ebuf_alloc(size_t size) { struct ebuf *eb; + size_t page_size; int rerrno; eb = malloc(sizeof(*eb)); if (eb == NULL) return (NULL); - size += PAGE_SIZE; + page_size = getpagesize(); + size += page_size; eb->eb_start = malloc(size); if (eb->eb_start == NULL) { rerrno = errno; @@ -88,7 +90,7 @@ ebuf_alloc(size_t size) * We set start address for real data not at the first entry, because * we want to be able to add data at the front. */ - eb->eb_used = eb->eb_start + PAGE_SIZE / 4; + eb->eb_used = eb->eb_start + page_size / 4; eb->eb_size = 0; eb->eb_magic = EBUF_MAGIC; @@ -215,17 +217,18 @@ static int ebuf_head_extend(struct ebuf *eb, size_t size) { unsigned char *newstart, *newused; - size_t newsize; + size_t newsize, page_size; PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); - newsize = eb->eb_end - eb->eb_start + (PAGE_SIZE / 4) + size; + page_size = getpagesize(); + newsize = eb->eb_end - eb->eb_start + (page_size / 4) + size; newstart = malloc(newsize); if (newstart == NULL) return (-1); newused = - newstart + (PAGE_SIZE / 4) + size + (eb->eb_used - eb->eb_start); + newstart + (page_size / 4) + size + (eb->eb_used - eb->eb_start); bcopy(eb->eb_used, newused, eb->eb_size); @@ -243,11 +246,12 @@ static int ebuf_tail_extend(struct ebuf *eb, size_t size) { unsigned char *newstart; - size_t newsize; + size_t newsize, page_size; PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); - newsize = eb->eb_end - eb->eb_start + size + ((3 * PAGE_SIZE) / 4); + page_size = getpagesize(); + newsize = eb->eb_end - eb->eb_start + size + ((3 * page_size) / 4); newstart = realloc(eb->eb_start, newsize); if (newstart == NULL)