From nobody Fri Oct 04 07:45:43 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 4XKgZb63ktz5Y5j6; Fri, 04 Oct 2024 07:45:43 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XKgZb5TDhz437H; Fri, 4 Oct 2024 07:45:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728027943; 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=htIAc26rdfI5FPV+avL7s6kuqkYIaeGVdLb8AP6DLsk=; b=CnwKuNYlcXyw7m0qjomYqHl76aG871axcoArNASwURejaZDtIB4gC0te7qXA7Jw4e71t/t vjiqgmY18Oto7GcgfBO7JRLa+MP/ydUCca05ehQ0N43FGNY0C+W7UXdEHU/Xdnn1vLh3yU AIKO7ed0oRT4J5sROgZ/ql+ZeRUwDLmIYPhYgIn8pa98I2cD2K8IzHFQG3KvEzyp3dZO2D AhwvJLtAXp+cTFRonbGat5pDeJMJM80o7GZzBL767u0NQ4ouVt0W5UJtcg/L/gcv+oyLWE KQpMQVpYwuDUlLQTI3GxcPmxnXLTRD5FBwoc6q8QOk/LEo1C4VMk/3PKdU5yUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728027943; 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=htIAc26rdfI5FPV+avL7s6kuqkYIaeGVdLb8AP6DLsk=; b=YGlQspMbgNwILL+NnwCT2ukOOVUo0RJkSyQv4c5vnvrlYcMBguiws0UyWIi25yheCy1uLY blj08BOQVPX7WfzJMrtOLw9PI9gVhkXHbEiZBwEedPSSBoypHCbNfbjc82Yug+Cy09SLr1 sXCT8FYfihUqBi++8g921boeRMbIvXrwNZeH4OROJndqX4qD5L8A3Tjl6QO43Er4zzmvZl DYOk3sGzzzGYTKDmt40jNu9qFIWxL7RDn2SVDLUUUvUSz6dEpKur/mSs3ecqjdIyuVQpmy Leky7VzdW8ZBDUHPB5E6eYTJfOkGW7MB6K8ItBveWULdwDWUcwuvPb7y/1QBdw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728027943; a=rsa-sha256; cv=none; b=BU16LVZj7FPPu+k5JMV2YVxkG1oFMwFaX0Nk3I4cRqxJH4/+p182483Lqxmg4rZzhKWi1o BqpxC4aejsKqV2vGsabtGeRPxypf5hVz2tC6B8gu7ZacXLMdKQFFh40atkIHO3RiEftcfb b0xvRJedOozX59s210yE52OobwQO+/N4Yj4C94cdqdiXHjwxeb7ly6ExyUOJSZaW9T6iib IXmCSjIfiY9c1zdk1D/ZwnwHaV94GPXSPG/4awjBFzKIeaflKdsrhXOm6LHQJ3wXMTxmD/ 6g7jZCiDwLZmapzTKwSoPtLdx0fQ2KmqgVb76uAeyVS8XKKga6iRqA7ghhG6uQ== 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 4XKgZb4n2DzQTh; Fri, 4 Oct 2024 07:45:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4947jh8c018493; Fri, 4 Oct 2024 07:45:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4947jhwn018490; Fri, 4 Oct 2024 07:45:43 GMT (envelope-from git) Date: Fri, 4 Oct 2024 07:45:43 GMT Message-Id: <202410040745.4947jhwn018490@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: 75734c4360fc - main - tmpfs: check residence in data_locked 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: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 75734c4360fcd5c70ab9650683ae47ca11aea15f Auto-Submitted: auto-generated The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=75734c4360fcd5c70ab9650683ae47ca11aea15f commit 75734c4360fcd5c70ab9650683ae47ca11aea15f Author: Doug Moore AuthorDate: 2024-10-04 07:44:19 +0000 Commit: Doug Moore CommitDate: 2024-10-04 07:44:19 +0000 tmpfs: check residence in data_locked tmpfs_seek_data_locked should return the offset of the first page either resident in memory or in swap, but may return an offset to a nonresident page. Check for residence to fix that. Reviewed by: alc, kib Differential Revision: https://reviews.freebsd.org/D46879 --- sys/fs/tmpfs/tmpfs_vnops.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index b278c3153863..fa9945a9074a 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -2099,7 +2099,7 @@ static off_t tmpfs_seek_data_locked(vm_object_t obj, off_t noff) { vm_page_t m; - vm_pindex_t p, p_m, p_swp; + vm_pindex_t p, p_swp; p = OFF_TO_IDX(noff); m = vm_page_find_least(obj, p); @@ -2108,15 +2108,24 @@ tmpfs_seek_data_locked(vm_object_t obj, off_t noff) * Microoptimize the most common case for SEEK_DATA, where * there is no hole and the page is resident. */ - if (m != NULL && vm_page_any_valid(m) && m->pindex == p) + if (m != NULL && m->pindex == p && vm_page_any_valid(m)) return (noff); p_swp = swap_pager_find_least(obj, p); if (p_swp == p) return (noff); - p_m = m == NULL ? obj->size : m->pindex; - return (IDX_TO_OFF(MIN(p_m, p_swp))); + /* + * Find the first resident page after p, before p_swp. + */ + while (m != NULL && m->pindex < p_swp) { + if (vm_page_any_valid(m)) + return (IDX_TO_OFF(m->pindex)); + m = TAILQ_NEXT(m, listq); + } + if (p_swp == OBJ_MAX_SIZE) + p_swp = obj->size; + return (IDX_TO_OFF(p_swp)); } static off_t