From nobody Fri Jun 17 09:43:55 2022 X-Original-To: dev-commits-src-main@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 8270C85DC6F; Fri, 17 Jun 2022 09:43:56 +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 4LPYyh08jDz4db6; Fri, 17 Jun 2022 09:43:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655459036; 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=47ArryceRtRc2dAExmsYve8/IlSJu3rz4+x6/OdzASI=; b=nz9ZRXEe2XaNz72JUuX0DBt6VhXHApvd7mPdvaJPftuI3d2L2gVyhCUHfVH1JPumYEQcu0 6a1gLZC5Uc8CGS8WJAoVQ+/G38dOL8TwGyaidfsjIfJNdJLBL9iUIyE/xrV/amWxcnF3TA aJuMuI9ObcwsUonI4aTUQ1m9rQMk0gZYo9MKL+IsBGUcwlg7Ei3dWGANzqtxgvaJ5g/0lQ 5ISBc0iUxxuGv4F7DJqlN6O0YZEIiud9+j1g/6KMMuEdGD6tuKujg3i6Tq7vXdR5Fga4Wf 1MhFim30X81JhWApWAto8gUbohiUczcHwPshqzhMNUx4mg3xQQbVENq701n4FQ== 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 B1A671D704; Fri, 17 Jun 2022 09:43:55 +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 25H9htxk012916; Fri, 17 Jun 2022 09:43:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25H9htkI012915; Fri, 17 Jun 2022 09:43:55 GMT (envelope-from git) Date: Fri, 17 Jun 2022 09:43:55 GMT Message-Id: <202206170943.25H9htkI012915@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: ea578b34cb35 - main - Remove PAGE_SIZE from hastd List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: ea578b34cb35505e7253c4d8f279fed1d38380ee Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655459036; 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=47ArryceRtRc2dAExmsYve8/IlSJu3rz4+x6/OdzASI=; b=NepbXVRo38xzaNVww80/+y1v0IvH4zDkpPJ8rWH0Z5gmaSPl9uSLnk9L+Rho0g1y5h1AoV bOJChZPKvHwc473n55N21HWbt8dzdGSIu/4QuY+oZnwjtSXXCl6Kev7+uzsv8bteSQJxgV skFE3kpl/O+riCe2JCxjUs14teixr8T0MXPCf52PCrLpcyqosYtvxSnnRGHefdkw0aLRVC KUzwOv9JStGJnCTqz5cQ4ls2k41qx6XPho39FYPitfHX09Iinp6IkCZE1qYzmh0HlequhA SQ20JQVnRDr4FDbOCnrEYbpMrkj6bZQbrqnXLCNaIuRVd28+0O0QRU1Afw3E9w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655459036; a=rsa-sha256; cv=none; b=IUi0mg4k+hSD4QTD85jKw/KE1/cfU6hYNz3pu+XxCjq6rGfYZKasfK1piM61cXL7Lx15lA R0kQI14cAn1jykkgVBAz0S7DRB6rgF9nwnw9lW94KVuan3mVFbZCRYsJsHCVfEvw7WuHBr iQ/fEnqYuPJIMZx8rgmpoRBM8CJjeF281MA3tEbQ7oUL4zZ9RUrW7bUOqn933v1GQgTYxk 3DcxQ1ywFKE8ThKfAoYWmiMR1hwqcAWOlE48C1IM6ogmDgH+asmEvst0vEQUzkJa1nlT61 SBQYSxQRKXUvCZNkrHH+qWouwZOATcXD/grEK5siLd2ppy3n4BlHZMOIb6xZcQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=ea578b34cb35505e7253c4d8f279fed1d38380ee commit ea578b34cb35505e7253c4d8f279fed1d38380ee Author: Andrew Turner AuthorDate: 2022-05-03 13:59:33 +0000 Commit: Andrew Turner CommitDate: 2022-06-17 09:36:17 +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 --- 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)