From patchwork Wed Jan 18 09:43:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13105974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A67C1C54EBE for ; Wed, 18 Jan 2023 09:43:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECC2B6B0078; Wed, 18 Jan 2023 04:43:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA5686B007B; Wed, 18 Jan 2023 04:43:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C328E6B007D; Wed, 18 Jan 2023 04:43:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B0B176B0078 for ; Wed, 18 Jan 2023 04:43:55 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 960BBA0395 for ; Wed, 18 Jan 2023 09:43:55 +0000 (UTC) X-FDA: 80367433230.03.DC8403F Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf04.hostedemail.com (Postfix) with ESMTP id 22F064000C for ; Wed, 18 Jan 2023 09:43:52 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="zb1P9ij/"; spf=none (imf04.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674035033; a=rsa-sha256; cv=none; b=8bcWxnqIOKWL4lyvIlF4PoVZ6+KAJj1jFCf6oEWiGsucuvtQDXLkZ+SvzZ05OFeSuLYEfL EwUL0CRxaQuu/td5OacDGvEJnazsQ7huBW5GMJnky+nU2dr8siZOKGEsbJXnDqGZHPKGCv DX8/Z6ZLEeyiA9c76/0Q+txcm30ij6w= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="zb1P9ij/"; spf=none (imf04.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674035033; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MhCSeZxb0+ckteL2o3EcN0B0EMYZcaQYxCAND8YfTVw=; b=aBdBU9D5CLqElWMowTcT6q6rdGYsSHvsfp/D9jupqNmZ8vJEd5f59kPGH1CuMwKXXTaSIo yy61aJiFbPGO2cQa+ZsgQAin4eWA1aScUcuJ5fOh5w3piKwH4InyJ9UX4vUTNQrMlG4bwc RWmFoT9ypcgb63qey5176RDQWOCo22I= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=MhCSeZxb0+ckteL2o3EcN0B0EMYZcaQYxCAND8YfTVw=; b=zb1P9ij/tKigVouQ1O/C4uCAS7 +JypLZQNpDNL8SKR+sx/aWG6SqmtWucbKq/npM9f01Nx4vipYaGkmRmfWPM8//WBMOWyul+joXZdf kI5DelXAG5u3Mial8ZsWDnwcWoQEls3QmRsMZpx+Ma9ZXSGvSOElPAlQ+CVHpa0i0ip+rT5GjIbdg S5G36phYR1i2oNyuWdEu+/jo4jmYoCDTehy+LLF2qrMRA/2CXC2tH9oCz02ukaqRRI8A/Yxuj3r11 ZC3nBMs5rlV1N/an3gFPLb/4i4RUC1kPq64ESJTixD6mQn5Lrv1DKGai8eyUnSX8o2BGpovyOd4r7 +F3UHI8g==; Received: from 213-147-167-250.nat.highway.webapn.at ([213.147.167.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI4yo-0009vw-M1; Wed, 18 Jan 2023 09:43:39 +0000 From: Christoph Hellwig To: Andrew Morton , Matthew Wilcox , Hugh Dickins Cc: linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nilfs@vger.kernel.org Subject: [PATCH 1/9] mm: don't look at xarray value entries in split_huge_pages_in_file Date: Wed, 18 Jan 2023 10:43:21 +0100 Message-Id: <20230118094329.9553-2-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118094329.9553-1-hch@lst.de> References: <20230118094329.9553-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Queue-Id: 22F064000C X-Rspamd-Server: rspam01 X-Stat-Signature: 536dc7qbgjc4nw66xe18rwa6zzx9zgns X-HE-Tag: 1674035032-823738 X-HE-Meta: U2FsdGVkX1/FIgAISF3IUkNnvIVCC7icKdIoe9rRXvMsIgqATetMuVh9MvRRtQBEMYGrtjg+qpPwr2Ae6hkMflklTxaWAqUII2cqBG6SN8w18extsFjsgjVrSAaXXq9Q6MGI7WznGbcYebuL4rQhNKb4wRv1BMnTVjmhXsIdHLm92O/lz36z7mytD91U/U4Y00kIozulMbjr81cd91uMa2XOvMWBAQtSCwgD8o/LCB9cHzX+jW8ZLYvqKaO31688VG8hn82L0O+wQ9F1awMZLtcFctyXuOQS4D0gr0hDODi3IVpayMIaR5Q7XtanECJu+kmVVUDiodd1RZDM7UsRdcpqcJGNmpvYEmu6iS6jXcxrf9gWzInn1CNDjNpZuoVxeQW39r3/AEagviDYShtMo2aJSa4tNlESxjitD25pFtmB+HDD0a33yJJqKkSeX2MMxufMpaXgIrT4CDsb7i/sL5cOSogmSaJ+EtN8ULQJttmX1+MiUE52zgrwWFocXSH0PNs47U8pvv7glZfShhZQMkpJb5B7qumQA+IKWLCmaA33+lm9MypfEVliUvG9W0UykMdBVl302lhY11V8ho/Zydk2UfKTtamkhKzpvoE4cok8GvXf2d43Do3OmUBaGyGQI/FTQPQSQ7ulpjFh734qyMGHHKTRkSZe7gsM+SZEqKMs5pN+E+zMe5cR3k9ZcVGpvcec8Nx5DN64HYTinkPkbHk7wpqyxPBbvqje1skqeh5Hny40okPcRSTsHWQtCpjgR66zpi6xOTQ826DuixEoM06pydpGn1sP1u7oMkfdAIUWnMPU9+4hMcEHUK53T833u1ISnafdGjxLhJobRpKN2cfB5EIblOCO+8my5zLLuw+/L7GwnOaepF2NHueiR4nxjvcNddkHFEsgGsTB4dCu9/E04UGRH1tLbp487nkgFl13Mc9qgaDDld2QSV+eFtnQmTUf9CeCYxQDeH+aK2b Oxi82b7B vcSj0DYyu8sapdboDmzO3TbVpAGCTTbvHOOaAH2kW9N64XrqpWELXkAAy+YJGjadjSDcMl74Gi7q7A6chO5ckNqcK2n10jINtZh03vvvdY2t2GPdOn1crzgM1pXWRsqx448T7F+Fa0eBVIvVAeCeo0AlEVRD4Zi33CHk/6RIzN6YHtDYkbkGBKXnGwEZFvOGKEf09agiba9YP36gf/KEXJndcX/71vUvsVLmdExs6fqNWuiM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: split_huge_pages_in_file never wants to do anything with the special value enties. Switch to using filemap_get_folio to not even see them. Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- mm/huge_memory.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1d6977dc6b31ba..a2830019aaa017 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3100,11 +3100,10 @@ static int split_huge_pages_in_file(const char *file_path, pgoff_t off_start, mapping = candidate->f_mapping; for (index = off_start; index < off_end; index += nr_pages) { - struct folio *folio = __filemap_get_folio(mapping, index, - FGP_ENTRY, 0); + struct folio *folio = filemap_get_folio(mapping, index); nr_pages = 1; - if (xa_is_value(folio) || !folio) + if (!folio) continue; if (!folio_test_large(folio)) From patchwork Wed Jan 18 09:43:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13105973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21645C38159 for ; Wed, 18 Jan 2023 09:43:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 519716B0074; Wed, 18 Jan 2023 04:43:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A7036B007B; Wed, 18 Jan 2023 04:43:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26F596B007D; Wed, 18 Jan 2023 04:43:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 16DD06B0074 for ; Wed, 18 Jan 2023 04:43:55 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DCE74A0559 for ; Wed, 18 Jan 2023 09:43:54 +0000 (UTC) X-FDA: 80367433188.11.7C8D2C5 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf01.hostedemail.com (Postfix) with ESMTP id 72C0A40008 for ; Wed, 18 Jan 2023 09:43:53 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=fWwuU2mF; dmarc=none; spf=none (imf01.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674035033; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OEkmrOTp9bp0MHf7fBWQdFeBfwkVijLbFt/ZuD+SID8=; b=oemTuv/y4cfav4eO8ZIQJbKDZfWtATj9/inQwiZfa+AE2BwqTtM5SaXIevtWyeI24Q/Deo +DZkjuu8FR2rnvK+u8rISVgUNjyxeQRKxr5khYf+NFbkDK/4kfX5XtAvE7ZRP3DSxC8Ejm O78fG8GROGXrVkALVAbRp4YX5amgBxM= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=fWwuU2mF; dmarc=none; spf=none (imf01.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674035033; a=rsa-sha256; cv=none; b=Qke91QvXxahdui2FfZUaGk8lb457DvH8u1BQXyHyVVi3jNRxyx+NBFJ7Tfqc/k1rMFbBjV /tXLFP1mp6wntSrKv+DpCl8jA0fdlJVSsvLElX0oWuOFCeogRlVq9WGXCE88G6YLBMAfar kW45hYuPp4xmzgTEFL06FNfBwqvjVjY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=OEkmrOTp9bp0MHf7fBWQdFeBfwkVijLbFt/ZuD+SID8=; b=fWwuU2mFDmXn7LwEaystbVgNKf 6W93ZUCVYBEuM6BrPk3yZuB09IzyaYZNsTkpzicBlyvZKyWPX0ki0J49msMlHfuxugAu1eEpI689X y3CMYNJbf3x3e3glDVCfRkR2AGRlBUjvBFY2PU2onSO73vKdDz+4yihTQap94U2geZXsUIy3Nugm1 wwPypEDOLE1/EGs/LD+ckYeTYmWPL3OM5Ra2Ppy9xP69HNLk6e/o8aBvYgPktsz2IXYbniaEeToGZ 4S8+Y9JfE4TjlT4PHg3Q+l/NnOBJcLddPWjYBKnTtMY7K5Z+TnqSyyRu9ooFbBu2aIsdGxbH9f2oO xXZ8yYKQ==; Received: from 213-147-167-250.nat.highway.webapn.at ([213.147.167.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI4yt-0009wo-CP; Wed, 18 Jan 2023 09:43:43 +0000 From: Christoph Hellwig To: Andrew Morton , Matthew Wilcox , Hugh Dickins Cc: linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nilfs@vger.kernel.org Subject: [PATCH 2/9] mm: make mapping_get_entry available outside of filemap.c Date: Wed, 18 Jan 2023 10:43:22 +0100 Message-Id: <20230118094329.9553-3-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118094329.9553-1-hch@lst.de> References: <20230118094329.9553-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 72C0A40008 X-Stat-Signature: i34cdyad1m8u1piaakfutqn4pin7bcxf X-HE-Tag: 1674035033-788102 X-HE-Meta: U2FsdGVkX1/K8I6vOPpaC46WFyT/VTc+QgzJL2y7/dd441YYYljLv8FucV/+ON+Mcd6Fguk3m5BFcIdXTnmskU+M0U0gOwnMe5sstVx4Y8OycUzpFfcAtlxFSzq7VweBJCGZflU05leKDpsg1zzZlY1gZIWPJ9RaYhGWXFmsj+KGjRRRvdUEECB8LBB3iB6MD18vekkbH4XSLE29hEJU8SAB+lJ5XX+LqAfEFUCNZjNGJpKH5DJkJWsVqW0iWU5PiKxoSGA4GrOsLxIBGkIpCp9dNlFvouJO3GvwM++cJ7Zv6565D2lCu3nrG3pGFw+kpi/dcHHOb2kHOeYS/cvaLF5qTp0+CxK/CnyhVn934kk+3V35lwiS8vqg/KakkItsIKhOo4hRQZ4f5fdnq2kVXlLcAPzHy+DX5Im/HkdgW50RkrhsVVdqdK34pyxinvvEHzl9wtG3RRCzMc0TxOWAsUA0c9BWPkCSRyS9En6xgN6iEF8AMtGNy0hEbjyiDeycgVeuDHLeP3MUgls2vx3JJQTKVfNLxe+6uv6ZC0dxd/0633Tq1Es7usBzuVc2ZAP9OmaDnz1sLVx/shSZYbustGiXB/zkRrsCo3443dKdJdk9GuKOgXn/YTEzMjC6FYpguN86eDoLONHxBc4KVipdBVwL49lAKXgUdtpvP/G9PtM6tNjQt5xXmscwcOSKeVjNC/cxoHZWMnk+oLjSW5D7ji2GrxdL5a7L620/iMWqWLPybdOQzYucoaKaEuTsfogMSNj70/mkIYnnRMgTDhwUOF87J7wrkFzAqfWqVAtAEgZq5D0JuCSit7BWfCAlbZLWmAEsiDyUdmr8uCIaTbdQdL3yc/cSqve7+GT8IpseQ+hEWEn1bCyR+vDWLfA5aRlkXQBZ861tJdKDvDP7Ou1ncfOC9yS64r8aJAGB4kh855ZEjZ4yKqJ8JPsyLvXSu9Gt0+eY+jtJFoCZE5HDDry gTiMZL02 C2DkRJKGlrbY74J8aJzrQUF2uFulpmB0+JObee8WNNhfMkG+C7Q3NUDQvtcybdU2oF3QtY8I2DAfpJ8tVDlV6fK7FiVX5DRNM2/oYGN2tKFIXdDB5SfkpRDckCN8b5eJwMkSsWs7fdgBI874qDPpKn6zUL5TVfRkfPcccS15OimAeEk/0WqtEJOQ3wt5RsHmP8gwauBjkfrrOxYtuneAOd2AOtmR1I43CJ0JDfU7mnFJ+pcg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: mapping_get_entry is useful for page cache API users that need to know about xa_value internals. Rename it and make it available in pagemap.h. Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 1 + mm/filemap.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 9f108168377195..24dedf6b12be49 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -507,6 +507,7 @@ pgoff_t page_cache_prev_miss(struct address_space *mapping, #define FGP_ENTRY 0x00000080 #define FGP_STABLE 0x00000100 +void *filemap_get_entry(struct address_space *mapping, pgoff_t index); struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, int fgp_flags, gfp_t gfp); struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index, diff --git a/mm/filemap.c b/mm/filemap.c index c915ded191f03f..ed0583f9e27512 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1834,7 +1834,7 @@ EXPORT_SYMBOL(page_cache_prev_miss); */ /* - * mapping_get_entry - Get a page cache entry. + * filemap_get_entry - Get a page cache entry. * @mapping: the address_space to search * @index: The page cache index. * @@ -1845,7 +1845,7 @@ EXPORT_SYMBOL(page_cache_prev_miss); * * Return: The folio, swap or shadow entry, %NULL if nothing is found. */ -static void *mapping_get_entry(struct address_space *mapping, pgoff_t index) +void *filemap_get_entry(struct address_space *mapping, pgoff_t index) { XA_STATE(xas, &mapping->i_pages, index); struct folio *folio; @@ -1915,7 +1915,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, struct folio *folio; repeat: - folio = mapping_get_entry(mapping, index); + folio = filemap_get_entry(mapping, index); if (xa_is_value(folio)) { if (fgp_flags & FGP_ENTRY) return folio; From patchwork Wed Jan 18 09:43:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13105975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61AE8C38159 for ; Wed, 18 Jan 2023 09:44:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C34F76B007B; Wed, 18 Jan 2023 04:43:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B6E976B007D; Wed, 18 Jan 2023 04:43:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A367C6B007E; Wed, 18 Jan 2023 04:43:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8ED4F6B007B for ; Wed, 18 Jan 2023 04:43:58 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4CDD71A028C for ; Wed, 18 Jan 2023 09:43:58 +0000 (UTC) X-FDA: 80367433356.19.CB78F3D Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf20.hostedemail.com (Postfix) with ESMTP id C7C551C0006 for ; Wed, 18 Jan 2023 09:43:56 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=oK86k6pK; spf=none (imf20.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674035036; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1tivNYnlYVjl+dCfTLCmKC5DzLdFgx18xVeklobnFOc=; b=IOhvaTYvkO9YfmSrAPlCy94xvqos1Tqv0ALXS+sgUY7c9I0fPu5cOcx8uTD2YQwz/ItnGC S4noS1DkqfnDlBg+7/uh/+QwuJ9I3mrxRg8/j78cq0FQP+9k/heXuF3jhjsmLkdFnv0IwH xOOCJ8ve5YPVXBR62zmAxvohUbIMhL4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=oK86k6pK; spf=none (imf20.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674035036; a=rsa-sha256; cv=none; b=7Hnq5nsVfc0v37czJFZc6HsR4WBLRLFcRyAwuc1R8tt5RKvMAeK10uG3WdMtDeN91hJD27 j4bWlgezE0u16gosAW9mcIcrx0c/IJmzTkMIOZUe8s1KL1n2i6Pw9t0KP7JBLPUSR2a/MP RYyi9XZNOSbJOuyo20ZjgkL9DEFMRQg= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=1tivNYnlYVjl+dCfTLCmKC5DzLdFgx18xVeklobnFOc=; b=oK86k6pKeZIcKg+Va0m3zSYnjp gdfBbtk752RFEObSR9dD/b0hSJZ+q6liwdtaOTuc+dZZjdn0uEBzCqUHQzMjPvwG/Uy75gc4xEjYT Zc6N0l/AGGagjNvK0usj0Ru2kn67AlvrxYxEIlLGFWVxDaD3WX4PRNuqYGnhJ+eTsWFF4cJ/nIic7 8ZA18lYUNGRHuUCEsd4YsVPU+DUCq5f/B4gOa9Vj5CrRRw+uKTHIiRdsE0s7zrKs48MkWSVwFXKmZ CcxQZeEif++QTTZv/8MNZaoq60DHPDo1DfYTsTFm1cnoaVz2hBTo7sJJbPBtPznpgeAWzzQ/Vqvco bg2FpGKQ==; Received: from 213-147-167-250.nat.highway.webapn.at ([213.147.167.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI4yx-0009xj-Fn; Wed, 18 Jan 2023 09:43:48 +0000 From: Christoph Hellwig To: Andrew Morton , Matthew Wilcox , Hugh Dickins Cc: linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nilfs@vger.kernel.org Subject: [PATCH 3/9] mm: use filemap_get_entry in filemap_get_incore_folio Date: Wed, 18 Jan 2023 10:43:23 +0100 Message-Id: <20230118094329.9553-4-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118094329.9553-1-hch@lst.de> References: <20230118094329.9553-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Stat-Signature: 4i3zhdrfq7gscfnkgo6rhozdr7b18u58 X-Rspam-User: X-Rspamd-Queue-Id: C7C551C0006 X-Rspamd-Server: rspam06 X-HE-Tag: 1674035036-522409 X-HE-Meta: U2FsdGVkX1+tgI2wZECn02BF6Rl/ZA3fNqo2lXtC1+cJUD9ygDVbNUHZ7w2ph6apEEjzaR5tDFoBdO9Yrds49ncbTFC/EoWeI8f4FS5Z/OpENnsIa8B9sy+DorvJheBAyPxSAunHbIq2xk94xqRwGb3kZaSA1iXRE6UdhnqIMKBhSy45XJUnLygS4BS7F05Wk+FCTbCYbcQNiLknWPt/WvFW0U73uQ7wpmwgHdEeQC2vN3TGKbPW5VRldwFL9bXQ7cRW5cL6erv/8O1nuv5EE8ubIoxq8YUMicSvL/8pRzmWR4LOpWp5bNaYlCRP2aR1oBebPKmmoMXjiL4W8LguqHkOd7EdtICB9sFfWAksEY+FHXGMdu6gMXFQ+zQc9S1MdRMdxK2Zx0FSM/EPWkWvixCbDLkYS8uG0Ud/UJ8ixxOQrVbRA0kFleFsoBWuGztSRvreGb0JsIOk0PPSVK+fx4vgD9QDGz1/2N3uT+0kLsPpV9UxJF66HqC4U6/n4yMSEjYxZZv4pbW2P1doQIO68N2KijAjAdj8j1GJKlSR1SCVs6ApJntWgsi5n9dg6SXmn797X88X2W3MZSP6KXxBBf3Wz+WXOLx4ish3MEzbifLJ9EVmBbtBHZy/xHmQuZieGcV+lelhUDW/17O4bs9TYEBN8szuNG6chwlqkYd1kNulCGn3b2f4DriNBDY1nKB4u2quIOsW1HqGUuk0EQ9WERurQQZzEhfvGV64shNBiSyp1DPcqowZNmm6WCX30qvz77EN0R2Sbc0oQ8M1mGLz3r4GNkFWzc2lLeijXBm/Dle3eWATMdHRQ0vf1zBlYmfoWh8/x1VUwLM0Nb8q7weTfimW/8H410uwDa7mtty/K7Vt/qWdEx92+ztgw9rHdRIb3kk6WVmH7PrdILXDy7joUh5WKhDiXZ+a0qnDtHZk5Dg45PUa4ECfj2lDaOgEOgxDCJcVhH7D9+ysxYPn3q+ tk9xSthO cQPDFIpeo3QyNYy+8VetVYhTLBTgwnLyg+73N3xp90kOrpT237XJQZwI17Jn8yulv9//C9EmWsusvFK7K7zY8AkDvu5RVtbIQZJo9z9nBtG/FEybvrZhf3p4jsqF8Ub5XC7/FWBu5n2d0P43AtPA2ph9tXx6qrm0E80UrARmN3bXUSes+JPP1bssmRanvupSpTirKnWcA5iNy5Dk+fT/sv7lVMTOdcw/S/RJonDiof1W2m0U= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: filemap_get_incore_folio wants to look at the details of xa_is_value entries, but doesn't need any of the other logic in filemap_get_folio. Switch it to use the lower-level filemap_get_entry interface. Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- mm/swap_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index cb9aaa00951d99..c39ea34bc4fc10 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -380,7 +380,7 @@ struct folio *filemap_get_incore_folio(struct address_space *mapping, { swp_entry_t swp; struct swap_info_struct *si; - struct folio *folio = __filemap_get_folio(mapping, index, FGP_ENTRY, 0); + struct folio *folio = filemap_get_entry(mapping, index); if (!xa_is_value(folio)) goto out; From patchwork Wed Jan 18 09:43:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13105976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9182C32793 for ; Wed, 18 Jan 2023 09:44:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41D346B007D; Wed, 18 Jan 2023 04:44:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F41B6B007E; Wed, 18 Jan 2023 04:44:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2957B6B0080; Wed, 18 Jan 2023 04:44:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1AA716B007D for ; Wed, 18 Jan 2023 04:44:03 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 869F0160A61 for ; Wed, 18 Jan 2023 09:44:02 +0000 (UTC) X-FDA: 80367433524.02.04C6166 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf21.hostedemail.com (Postfix) with ESMTP id 1701F1C0003 for ; Wed, 18 Jan 2023 09:44:00 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=siItTvaO; spf=none (imf21.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674035041; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=O83tPX7xDqfBHS0UmyQszE340fKZLFsVV7AVtaYRimc=; b=3NjheYJvbYgGtp6dlyqItANXVQ2joA/ux+wUIwJcNsmX4r+sNJrIv4xWvkybu8+dR9mzxH iDvZhscQoa2u96M9IdE1qG7sOIPFiBzdfQhKv5m1EJonGwBZRMz6EOXWKCV4yKj8HNJd2R rUik34BPk5NQxP7BHyc7Nq5sduU3YdM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=siItTvaO; spf=none (imf21.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674035041; a=rsa-sha256; cv=none; b=s2TsLgq9pVNQTPVKwTM6cTTZY+bpSmmEq7/sUYeXw6Xh+qRMdMWwYJaFSYfV0uropn82ri c+aXreT84f4gHjBDb9D/syBmXjbcETxZuMvWkPh1elGqB/yCoREidHz1zSa1mbg/0JpHPo 4NpC4o6ggW2xdDlyqddPxyTu4sZW+Oo= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=O83tPX7xDqfBHS0UmyQszE340fKZLFsVV7AVtaYRimc=; b=siItTvaO8AsDZE3ndylUPIO/O7 O8rbSLynnMNtdE+Stj5GPSclr0XcMLZj+dKghCCW91lanRkY7aH4RCo3QLiVUBRy+6YnE08rYe474 nYyWYpyVKCaiYpK2GGKX0C9Il9QGUIdNlez4FB93mChOl/ONhLOg14psRvpOcZfD0/x88ZoKZRjx4 Y9z9UDYRy4b0bASegjboX45Xi47n6T065RATsSq713wYwK/3AzncosVsQt3BXdHtlCUbg84/3QCkr obJDhpJGPXGRphz9ppkZYpG43bea+N0N/sTKMifzKhDvT4kVfxWKRrlPE5UM2N1ShnUoiRJGYZTmr eeFJ4fCQ==; Received: from 213-147-167-250.nat.highway.webapn.at ([213.147.167.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI4z2-0009zZ-Qn; Wed, 18 Jan 2023 09:43:53 +0000 From: Christoph Hellwig To: Andrew Morton , Matthew Wilcox , Hugh Dickins Cc: linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nilfs@vger.kernel.org Subject: [PATCH 4/9] shmem: remove shmem_get_partial_folio Date: Wed, 18 Jan 2023 10:43:24 +0100 Message-Id: <20230118094329.9553-5-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118094329.9553-1-hch@lst.de> References: <20230118094329.9553-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 1701F1C0003 X-Stat-Signature: zjymeusgt9sdwwhd1dk6kqk8umcdx81s X-HE-Tag: 1674035040-12968 X-HE-Meta: U2FsdGVkX18g6/kSz0Uv+50NbUTJHQd34fEabohm9Ocf9B7UXgLVxvbYwmoI3jgXZW4moRgf1kIXQF48LF6yWV/hWtr2Ev+g2GjMLLoJiNUpyOmJTXFLQ6SndKSe8IIGOXuMF3vX05sQwS8+thwM+qm4gRr51i+s/2uBXW/gYBxWRwRkAk4/PGt+e0XiLOBvKavOo5s8jDwzVipo4GJ0/UJ4Rp0p9qyhyQhZD/Sxrrs2BBvsoZSp7WFx+OCpgJCpJPOib/CoZd1OgNsflMU9cwSmIi28lAJ31zCZNV/egiK0XQj1VAC/LDc9H811aESzTKgYweEZZtVjVy3K8p7bBMV6bL1cTGbmUedXpkQiY6eHLCvPGhu0pZidc4g5vRZ2vRFBrJtUdfAcBfI3S+3kF6mvFY27mb1nA9ca9ObG8Ybz+nRFewaMmfp8cP3enUTPtATTwJAvq9AuF7mjLTLLLKZ3fy2RgKOD5aJMpGOh6xZxjqphZQ74puMtdOIify2vqRwhmFtLE5vkeD6qDc+YPPg/D6e8XoJI+Z4Zx5PrYlH8qOXi5NrySEJjl0oMorNRmRhQUdX7CQSUkArEjKmzun+uCB/jENkOyHD5G2zHU3WZFpcLaR8FfHB/DwF999yCzCVoLak0G6nJWiST/4g9opudijUmjippJT0ALwj3IaqBzp1RCHffxbb/gjpnJm16phL4PbBC4H5gJDFopkcdtF50yeBbhaHM39Jitbgm0TZoTJaINteTkeASiEQ5eC4fa9tO8aqDZfaNUcoYL0zkc7C27JFRCcPoClRQL0yAHPKgUsZ3goM0HidFcdpTdsHxQjIXA0MWdqaa1mKcS+9ztUNzUeeyZm0slLBVFpDPfejZVNh/ktkMPDVM6WkHLnhSkfLdi6a4hoAe5bSR+CxBbKDtg23dGVZiADiIccpN6ZkK0EXfw2Yo00SUd7C3uw9m9akhBorbGMacREbPH56 sU2U9YZq VS2fd5ZqL/2QwGH7Gs0ckn0Vqp/vrNCxEFaI6vDNZKkt2hQUcr6GTJgXIUVEb/MPMjZDptHfYmh1QD7WbYCVWqxyFq+VATW+x4zNJofIuOO5Uf+zn0sjbFhLmUbw4TDQqrEf4xjUQEamXSmEYqzTVb2ifi/crlqiuWy+Gwebi4HOIt0XnOPOgSUsmEH6fzVWtw+8LM+BGMw7RNIQFnLCx+CDvQ5rHxRO/Mc/Yz+ZP+azC3gw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add a new SGP_FIND mode for shmem_get_partial_folio that works like SGP_READ, but does not check i_size. Use that instead of open coding the page cache lookup in shmem_get_partial_folio. Note that this is a behavior change in that it reads in swap cache entries for offsets outside i_size, possibly causing a little bit of extra work. Signed-off-by: Christoph Hellwig --- include/linux/shmem_fs.h | 1 + mm/shmem.c | 46 ++++++++++++---------------------------- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index d09d54be4ffd99..7ba160ac066e5e 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -105,6 +105,7 @@ enum sgp_type { SGP_CACHE, /* don't exceed i_size, may allocate page */ SGP_WRITE, /* may exceed i_size, may allocate !Uptodate page */ SGP_FALLOC, /* like SGP_WRITE, but make existing page Uptodate */ + SGP_FIND, /* like SGP_READ, but also read outside i_size */ }; int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, diff --git a/mm/shmem.c b/mm/shmem.c index 9e1015cbad29f9..e9500fea43a8dc 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -877,27 +877,6 @@ void shmem_unlock_mapping(struct address_space *mapping) } } -static struct folio *shmem_get_partial_folio(struct inode *inode, pgoff_t index) -{ - struct folio *folio; - - /* - * At first avoid shmem_get_folio(,,,SGP_READ): that fails - * beyond i_size, and reports fallocated pages as holes. - */ - folio = __filemap_get_folio(inode->i_mapping, index, - FGP_ENTRY | FGP_LOCK, 0); - if (!xa_is_value(folio)) - return folio; - /* - * But read a page back from swap if any of it is within i_size - * (although in some cases this is just a waste of time). - */ - folio = NULL; - shmem_get_folio(inode, index, &folio, SGP_READ); - return folio; -} - /* * Remove range of pages and swap entries from page cache, and free them. * If !unfalloc, truncate or punch hole; if unfalloc, undo failed fallocate. @@ -957,7 +936,8 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, goto whole_folios; same_folio = (lstart >> PAGE_SHIFT) == (lend >> PAGE_SHIFT); - folio = shmem_get_partial_folio(inode, lstart >> PAGE_SHIFT); + folio = NULL; + shmem_get_folio(inode, lstart >> PAGE_SHIFT, &folio, SGP_FIND); if (folio) { same_folio = lend < folio_pos(folio) + folio_size(folio); folio_mark_dirty(folio); @@ -971,14 +951,16 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, folio = NULL; } - if (!same_folio) - folio = shmem_get_partial_folio(inode, lend >> PAGE_SHIFT); - if (folio) { - folio_mark_dirty(folio); - if (!truncate_inode_partial_folio(folio, lstart, lend)) - end = folio->index; - folio_unlock(folio); - folio_put(folio); + if (!same_folio) { + folio = NULL; + shmem_get_folio(inode, lend >> PAGE_SHIFT, &folio, SGP_FIND); + if (folio) { + folio_mark_dirty(folio); + if (!truncate_inode_partial_folio(folio, lstart, lend)) + end = folio->index; + folio_unlock(folio); + folio_put(folio); + } } whole_folios: @@ -1900,7 +1882,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, if (folio_test_uptodate(folio)) goto out; /* fallocated folio */ - if (sgp != SGP_READ) + if (sgp != SGP_READ && sgp != SGP_FIND) goto clear; folio_unlock(folio); folio_put(folio); @@ -1911,7 +1893,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, * SGP_NOALLOC: fail on hole, with NULL folio, letting caller fail. */ *foliop = NULL; - if (sgp == SGP_READ) + if (sgp == SGP_READ || sgp == SGP_FIND) return 0; if (sgp == SGP_NOALLOC) return -ENOENT; From patchwork Wed Jan 18 09:43:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13105977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F625C004D4 for ; Wed, 18 Jan 2023 09:44:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C817E6B007E; Wed, 18 Jan 2023 04:44:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C326B6B0080; Wed, 18 Jan 2023 04:44:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD2B06B0081; Wed, 18 Jan 2023 04:44:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9D93F6B007E for ; Wed, 18 Jan 2023 04:44:08 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 78483A07F9 for ; Wed, 18 Jan 2023 09:44:08 +0000 (UTC) X-FDA: 80367433776.27.54C8187 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id 0F9D240017 for ; Wed, 18 Jan 2023 09:44:06 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=UfEL4nxo; spf=none (imf07.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674035047; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pFy30vhWl9l9ZgLMa817B3/6WEg0wrb2z/Np7E/EF8c=; b=Kzc/NOCoGsZfC4F6VDOiEcBFbNoXm11ox7e6sECzlF02JRh0EKU5XyWTC9WKnqGoZsfoGE U2b5H5Wes3I0uJxbCK3YdeM1v5g6YVKXYBndFd8rs1oxT0vU9cxHrBcxdxlduABbkv/kyd mGfHhpTfxjdVrXKy0hf6Zp075tYyNrI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=UfEL4nxo; spf=none (imf07.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674035047; a=rsa-sha256; cv=none; b=TOfWv2lzu1WNojX3tCa7eayURNVwVhB0Y4T74S9Q+5LeidHnPI54zodsyxIjk2HwofnJUz YBt44DKK/TaTfBjY3A/FnshRr+95390CfqDRx6OXo9H9IuwiRd8WzkdzxRDXtBG4pCP6PO 516ZM8+TGXtFCtfFtqNWJCB2AROP41g= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=pFy30vhWl9l9ZgLMa817B3/6WEg0wrb2z/Np7E/EF8c=; b=UfEL4nxoIkflPHGo7FW/goZ6Ae xIpR/d0qI5IJrraY/1iGKXWGHdji2iuHKy5HnLQI8g45xl0egjQwt440BkyDBzLOtbS3WTE77JRoB YVbEr2AoQ50WmGx37VByiYGoCLP0d5MCV4wzb6443KaglnqflCP6aueRjRXiu9loX+HJZJVZbLoYZ 7L8+14Vq+wI6LGjevGMbFYs4iFg/sLVFkhIO9VUWEW0VoKzm/xPjwyPDaa3qLJ2urhMKmMYcXaer+ mXjsx+091criZqeGU7fbDpZee25pjlDMItJhPegKjbf5a4mRmpe2UFeAd60n54qiLHBmIq6wh9a1Q m2aDbOQw==; Received: from 213-147-167-250.nat.highway.webapn.at ([213.147.167.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI4z7-000A13-OH; Wed, 18 Jan 2023 09:43:59 +0000 From: Christoph Hellwig To: Andrew Morton , Matthew Wilcox , Hugh Dickins Cc: linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nilfs@vger.kernel.org Subject: [PATCH 5/9] shmem: open code the page cache lookup in shmem_get_folio_gfp Date: Wed, 18 Jan 2023 10:43:25 +0100 Message-Id: <20230118094329.9553-6-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118094329.9553-1-hch@lst.de> References: <20230118094329.9553-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 4ecjfxenftbfiprfdwn3beaped6gm1f8 X-Rspamd-Queue-Id: 0F9D240017 X-HE-Tag: 1674035046-13909 X-HE-Meta: U2FsdGVkX1/Zzvqp3pvTE656Z6wyn9SeNKxPT7VZD2UJrWi5CCA5Hyw9Zvj9LWYsuotRt6+Wx8S4lG1TRve2c2ERxStUZlXHk90oOD7rdwaGGyt7o00iG2jyLTkzUO7OUJYaKwayyN6wpgqsW3IBhM4+E6y6QgANlR5chdWIm+BYVLklyqvKn04Hju2fLU1WA6Ei73WXJftzzFd+pBeifRpIgCuf+Jczy+4TKhdjid8H3GwPA/xFcAWJtNh7ZIEdaG29T4lmUNwepon6gdyViCdqVIjKl2FyoQpBWd4X1uKpi0SOyhNWqB29UG0IaBSXMHb9h79DD0TVDnGN/kjqyR4yjIXcQNC/LT96xe2ZPgZJfLPTiVfdz0/sjOwBl1L5wKhlIb5di/nBNR9NEU4gafiKfToa+LJRMRyDV8Eltvz4Sr3P2T5nRHflPWGlb2gLKpNqRlf3UhBXyJUfS3cPRVc6nQZxHVTo4DKS+/XZwvcuR4guw6Hko4lyVOSXxk7Xsr9nQOA0qX5lh0ppNZ1hlaRVHZQK5hAaJo2vy8ArZW23ws3LnBhtBFT7/sszq9SJAJnqFa4GFkQqlmTUMQ20G2yNGlL1NC1Pt5EET9MmcCJZrfQsRasfP3nfREGBAEJNLteQsrsLGl5hyOf5Klr2Pvk1noxdnY3QtqeGcj3CbOuLB5YLQJqErq1xr5tTaXO0B3TaxQ/ubsBixqCVb3sgpBce1MMKN24cVIf4Cuqpd3LtotiMzTOoBET8nhbWmqWh0ne43bmWsTMHo8REUgGvhbOqPKCHT+GZETo2yLK/bD4AGhID8wO6Yob2+MdEmVAUnyho6XbPcRnrJp0/b6FiBNbPYaRv2qi1oE8v7qtJABZxz1HutBUqh0ae5UKrytLtzGwN/H+5r9Qrl1kOdlCaUtbQeRUHExqAH06Ue6SMBvT71sd3KHE5d48pbocMz6sjoWfjrA49pua+mnFFiio QWH5kYDa r8v8f9kveT0VUu9+0uNk2SDFA1kRBoRKynbYO15lIT/WFQWvBYtBRrHD+qyqeCYR4WOg9SHnyuFP0EBUoc4yE6EBJZ69KtFLtVAW9EJ0BYErEq+lXQ9ZBGJksrSNNyXF05yfYcyUvz4RATkg5U+hRavz4kNAqrnqlYrCAiYzf8+OTtKcaZ8t0pWZO8966u9ELMBOECWCbb/9GX+noHi1wCMPxOkSoXYGjKnnyGQ4sH1qpQxY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use the very low level filemap_get_entry helper to look up the entry in the xarray, and then: - don't bother locking the folio if only doing a userfault notification - open code locking the page and checking for truncation in a related code block This will allow to eventually remove the FGP_ENTRY flag. Signed-off-by: Christoph Hellwig --- mm/shmem.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index e9500fea43a8dc..769107f376562f 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1856,12 +1856,10 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, sbinfo = SHMEM_SB(inode->i_sb); charge_mm = vma ? vma->vm_mm : NULL; - folio = __filemap_get_folio(mapping, index, FGP_ENTRY | FGP_LOCK, 0); + folio = filemap_get_entry(mapping, index); if (folio && vma && userfaultfd_minor(vma)) { - if (!xa_is_value(folio)) { - folio_unlock(folio); + if (!xa_is_value(folio)) folio_put(folio); - } *fault_type = handle_userfault(vmf, VM_UFFD_MINOR); return 0; } @@ -1877,6 +1875,14 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, } if (folio) { + folio_lock(folio); + + /* Has the page been truncated? */ + if (unlikely(folio->mapping != mapping)) { + folio_unlock(folio); + folio_put(folio); + goto repeat; + } if (sgp == SGP_WRITE) folio_mark_accessed(folio); if (folio_test_uptodate(folio)) From patchwork Wed Jan 18 09:43:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13105978 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E2A7C32793 for ; Wed, 18 Jan 2023 09:44:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 359886B0075; Wed, 18 Jan 2023 04:44:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 309C06B0080; Wed, 18 Jan 2023 04:44:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D20E6B0081; Wed, 18 Jan 2023 04:44:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0DED46B0075 for ; Wed, 18 Jan 2023 04:44:14 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 84669C072D for ; Wed, 18 Jan 2023 09:44:13 +0000 (UTC) X-FDA: 80367433986.29.75C831B Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf22.hostedemail.com (Postfix) with ESMTP id 020F8C0015 for ; Wed, 18 Jan 2023 09:44:11 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=tjja759e; spf=none (imf22.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674035052; a=rsa-sha256; cv=none; b=uLag+LiLt6QNXMuhYjJSQn7y/2eRO0nQNSfDXNXJczp12APutgcF/3Cna7WF5KP8Yk/aBa hYtqQSbdF1o+odajq8FIXXN/Zyk/uQIgt8qX7SamSGqgF5vAhTjV+25A1gZy06bQcw6aO3 XmyI7Ij2q75yWuSbn+1oFiF219yhIC4= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=tjja759e; spf=none (imf22.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674035052; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=72dbPnQldghXJsWt6hBZ/ADNkiEKaZsKzxCkekJEdAU=; b=lLsJGV4MKPSSMmAyXy6UgiReumYTVu1u+p9vLqCLDrExJgkA+bzHS/Lb93TmwaLt72CWo0 xkCbZA5UmIxghmBDYul7c9IMcsUsZDlR9k1+XdbV9ZTacOy2mu/IAfVYeU71AsGmDPqrmp 72MZqYIbk7Tt/2cctxIAHONCpeImSIo= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=72dbPnQldghXJsWt6hBZ/ADNkiEKaZsKzxCkekJEdAU=; b=tjja759eWnm9v7J+IWUXZozttN OxM313yixMNrLZv2p6AMh7dEVQGQVttdzzpXCUjYtd/HJPHTDFptjOcJ/ztghPLG4FjwymkosilRR 71WeRyXnd9cVWvfYK3gwuP8UaCscXZDWNsVkdryui1LtBz7pHrZZlDwm9tOHPzeUWlqVpzLwqs/Nv mQ1wr0mKPRM1oh8fBHkrDd2dD+F4LxbURzWCJO9Qy9VO5kKDaaZ+uUch5hrYQMx04GTYHXBA0yLFD xDHDaJbPbxJzhcRQVGE0fXG65DXX8GVYqTbsMDsQUxetnUYXCE7Y+e2Jxxpl5o1Oq0PIR9p1np8O6 uUlibs6Q==; Received: from 213-147-167-250.nat.highway.webapn.at ([213.147.167.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI4zD-000A5d-GP; Wed, 18 Jan 2023 09:44:04 +0000 From: Christoph Hellwig To: Andrew Morton , Matthew Wilcox , Hugh Dickins Cc: linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nilfs@vger.kernel.org Subject: [PATCH 6/9] mm: remove FGP_ENTRY Date: Wed, 18 Jan 2023 10:43:26 +0100 Message-Id: <20230118094329.9553-7-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118094329.9553-1-hch@lst.de> References: <20230118094329.9553-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Queue-Id: 020F8C0015 X-Rspamd-Server: rspam01 X-Stat-Signature: u994ywcq6wtdntzftbjsupocyic38rtc X-HE-Tag: 1674035051-682239 X-HE-Meta: U2FsdGVkX1/5HvqMb47KSCp2DfFA1l6T7sqZ1ltTiBxlyZwLHx7LbBLMfSG9eZke2vyC6zs5xlvsqPbDnJw9PejvHRgwXL/jjAUvQhXLLXZpCnGHHMPPrJG9P5xI3D8u/J0vs4P35YFIAJmtngiYz+UvLsult0bmbg8S+t/gNBJ0cQ8UgbuULgJPY6VkCAd9Zn/E2JYfWPy7yJKXeF0Lf5IYhbjvWPuhhOuLomGA94G8RF7OxgfsHur6TYwwbcbzJnGGGgvliw9M/zMkmjl3+8vLBSYpHDalmlChuHml6xVR1fAYb+YPLtQTHToCekgnu0MBcz+6KJbm7yqqxU33Mvs0jkMWLkO1aW56q66xn6/l46jVK4/ObgLVg2sd1l9xx3Wly/J3xzw9Beh7myBzgqNlV61e8+57Qd3QUVKfBvWPUDoLKLkpby5FYsAs01VQayaX59IKIekfmV9l70MYzyAK4sjpChqnmTrQR6thiK9Rm+bELjpjTgO3DOGIxJUR9eZR4PXf72cbRoppCdaGg/kYPIa2zpZDrqDjwW/PX01/yC5IpcVfwwBBCOoR100OzJIxwrxljVPkPnWs7udtm84PLLIA77iSyuGNfORGYTikHmJP33yb5uRp9z3W9PwHQvWAhIfI+Bzc+YeDpcP1GR+6QC6iZXuYqNCkaQjWRzw3mH8eVUZz7LAoMyPmJAkpTWytULFmDo6QeSO4ZrHDSchHXvzaCzxHihHP8EcmUxwr6uzVZxqAad06U+O+rijbF+yjCD7pWxP3ycgUor2w3BTie1pHb1T3yGnlVpSZ7rbWEKYcEapgR+DsT/FP2fTplfB/7BYqFJ5zdjNncJozjH2vPm1gGwUT0h0m1buBxN0M351XVajzyz/9l3h2cjCm4qADJuunA5FCcijikKZ1qS0heb7UVrEcwYgY9c0gOhQtII3cUJlcbyA7KE3tTtFLhixFZsiV7kAIcEa8vsO EEwS+lAy tQXDqK+iWP7cVItQwdI5AM+5zP4WiVZdci59NTjH+9woKWajQFkQ+5seqmVlvqJft5WoG5p6MI5P4Mb7JgUpKnHTKKQhfVmM6+zLT6tyJ1M+7qpxBdQhwDHYglrn28QKlH3de1DTUm3TumMy31vEteSQc5p0NHHlEDx5xuvBicLg5PKMI2iP2nwALFw/ZasLKOfUUDmvhbfLIQzs/lDhQPRiQ2dUO3rkC/TiLCxzik7jaR18= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: FGP_ENTRY is unused now, so remove it. Signed-off-by: Christoph Hellwig --- include/linux/pagemap.h | 3 +-- mm/filemap.c | 7 +------ mm/folio-compat.c | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 24dedf6b12be49..e2208ee36966ea 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -504,8 +504,7 @@ pgoff_t page_cache_prev_miss(struct address_space *mapping, #define FGP_NOFS 0x00000010 #define FGP_NOWAIT 0x00000020 #define FGP_FOR_MMAP 0x00000040 -#define FGP_ENTRY 0x00000080 -#define FGP_STABLE 0x00000100 +#define FGP_STABLE 0x00000080 void *filemap_get_entry(struct address_space *mapping, pgoff_t index); struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, diff --git a/mm/filemap.c b/mm/filemap.c index ed0583f9e27512..35baadd130795c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1889,8 +1889,6 @@ void *filemap_get_entry(struct address_space *mapping, pgoff_t index) * * * %FGP_ACCESSED - The folio will be marked accessed. * * %FGP_LOCK - The folio is returned locked. - * * %FGP_ENTRY - If there is a shadow / swap / DAX entry, return it - * instead of allocating a new folio to replace it. * * %FGP_CREAT - If no page is present then a new page is allocated using * @gfp and added to the page cache and the VM's LRU list. * The page is returned locked and with an increased refcount. @@ -1916,11 +1914,8 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, repeat: folio = filemap_get_entry(mapping, index); - if (xa_is_value(folio)) { - if (fgp_flags & FGP_ENTRY) - return folio; + if (xa_is_value(folio)) folio = NULL; - } if (!folio) goto no_page; diff --git a/mm/folio-compat.c b/mm/folio-compat.c index 18c48b55792635..f3841b4977b68e 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -97,8 +97,8 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index, struct folio *folio; folio = __filemap_get_folio(mapping, index, fgp_flags, gfp); - if (!folio || xa_is_value(folio)) - return &folio->page; + if (!folio) + return NULL; return folio_file_page(folio, index); } EXPORT_SYMBOL(pagecache_get_page); From patchwork Wed Jan 18 09:43:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13105979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A959EC004D4 for ; Wed, 18 Jan 2023 09:44:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46B166B0080; Wed, 18 Jan 2023 04:44:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 41B1C6B0081; Wed, 18 Jan 2023 04:44:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30A686B0082; Wed, 18 Jan 2023 04:44:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2267C6B0080 for ; Wed, 18 Jan 2023 04:44:18 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E8E651A0323 for ; Wed, 18 Jan 2023 09:44:17 +0000 (UTC) X-FDA: 80367434154.29.FF628F8 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf18.hostedemail.com (Postfix) with ESMTP id 7C91A1C0013 for ; Wed, 18 Jan 2023 09:44:16 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=U8yFVdeB; spf=none (imf18.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674035056; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4WwjtPTvg3dbfLBE9vX5iRJAtphGCEZEkdJLVGyAJuo=; b=Q1/2+yCGy4DCvZfpFlWZcfR0QyaEVTvirdxzK6oEfIQ952MoV1z9zM5T+FYe8fK4qGIO/S EdxOEwRQwh6kDhVExitlNrAq5yFLPbrsrj5qGJS6WsoUuTAFHm6HJZDZFiupE6GQ9bXps+ uKnUGP0c3yL/BJ+5zPMyOIbv35BM1ic= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=U8yFVdeB; spf=none (imf18.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674035056; a=rsa-sha256; cv=none; b=gL33V/wmWmJUHzNcvPV6mEETDNq37mXyQWobciEHYD7ONulTNyqqvogqo1Nrf6/GDcMF3o ZfGXwALuDPksCvPCIv33C4LrjMu3GZOuReSgdU39q9RBR7t1snROzsAm1FxQffxlYt0Blq oxMKxovmtlbk6HZHzu9Ms4qR3MKgIWQ= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=4WwjtPTvg3dbfLBE9vX5iRJAtphGCEZEkdJLVGyAJuo=; b=U8yFVdeBOBI3AACbEFkiQ4355D kLv+LRYHlKEtA4P6BWETKJS4fAVkK8iUpRlBVj9bR3Z5JxNdzQrN7aBF2SXwp2ePM5gNif1cFI7cL DyUfxGZQ28zOPddZXEXlOfBeZcxkQhHcv1emVkZOzOmdX02aeXOEB1DkUHEQ2/7g4XZ+Fmx9l3UHI YMGHla2dEMTRRR/zKlZBZvvUFGurgIdckmw7tTsDDGQdh7vK99tqsGnmvLAIuksqS+qEGzkmWqgtR +53as9e9nNgosns1KccGTJVaRfjXJygIT64MdzQBaIAoGVFyt2ILegAxzv+cBLG4sjOlhTtqe7jpE HXxflEVw==; Received: from 213-147-167-250.nat.highway.webapn.at ([213.147.167.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI4zI-000A8d-6U; Wed, 18 Jan 2023 09:44:09 +0000 From: Christoph Hellwig To: Andrew Morton , Matthew Wilcox , Hugh Dickins Cc: linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nilfs@vger.kernel.org Subject: [PATCH 7/9] gfs2: handle a NULL folio in gfs2_jhead_process_page Date: Wed, 18 Jan 2023 10:43:27 +0100 Message-Id: <20230118094329.9553-8-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118094329.9553-1-hch@lst.de> References: <20230118094329.9553-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7C91A1C0013 X-Stat-Signature: puk9o6w93kyfy5u43ifdnjmdj17p7tkp X-Rspam-User: X-HE-Tag: 1674035056-350003 X-HE-Meta: U2FsdGVkX1/uMkJUbnrErboywbBDzlytyEgbyKaPwwmdRJlHWttYkNlmL9id1AqQV8SuVxAe/pKD1HEt7jshbTpRolm/+JBPSW9FRoi30vzQPZ61ocA+cZaIJCD/nTYRrfmbj52wV8tzi8fFCyzLxeJ6Ka4nbVNavL3B2wHvcPO+rU8mah8uEEmbUuUREmRKgFhfXsKu2MS2g3SSysUz2CFwvl4LsO/geWn94iA/flfYRB9KAHa9omd5A1twd1UOBumojLY/65sUmXMNNbbcKxL4POjOmSoCSxuYwmJSC5ooWT7PLRWGK5Y9p1MtSKDWcJ0A/9uJBAprwM0JYaOAsjog8kFOMHAW5bm4D05WOut9yffLK7RbmpyCGCF/yjf38qrC+AUj/MzB/FWU7uVSSyTrb1wrFfnLtlbMGkyw7ugul56hMrIYwfPbl1274toiCJe5sGv8V8Q/ak9hSS1U/DPBmubgFmtN8CAOAwxG8WfJy0nmtX6LyZXdSvI1MBc+84WBUPIMHwU/TjO0Ud6KFGYCcGRuOp2Ytk3Wud0UryKpGF5PcxL321ny1uK1WwmeKLwcXo7STaqCWFPa+i+SbFwrY7/P11OS1oBF/cOMLSJhYt07UEqKIy892IrxEn3VAedF0ARK/R2UAGEYHzjrpQRopeG5LnXcx1aoY6a0v3y0r7aj1hsbxFa+r2sElpdxVHIAzHzW3Yo2LbU5RsCPLQN6BE1RuQo7TGtlflWms1tpNaQ9MGiy8hdyixgSHHmEHOA2tGU6lYe3HPeR/O1mc6lqxcFYRTao9WtaK7O1wQ6fP0Rd++a4SaEQ4rxMAHI8s0dvnNhkP/E9OskauQUE8pNmu1WhmBU9cz6aB8Eg2Ru/Ue4LoH490T3vAC2msGz9isZz+kapB1v6F3+vq6hA0JOHD21KHDs4rYHj0tGHDu3uUQfWQrCg0j1yhbNf40EdtxKdX3UDexT2yUqGXba zsx+ZXvy 44l8/urQCsR/oPv7gVCxakECtntz8Zd6GoDoVPNSBxpzoNUPJFlSbhsHJlpTVG33NHVfd63OBAr2Gt8H594w6z07dZfU8/QcengD+p9kJHLuANoiqycLOIKAxQkKPypKIia0Tb3TqV5NkmzkcflA0Cthr29SDaxDU3hXdgSfL6IgW5UTf6rxX6oPxaEelM+K1TCTbbjoVpwLltCR4fhuUKkf1/YUqDMgMrN0SmJGJh9V4Ie4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: filemap_get_folio can return NULL, so exit early for that case. Signed-off-by: Christoph Hellwig --- fs/gfs2/lops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 1902413d5d123e..51d4b610127cdb 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -472,6 +472,8 @@ static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index, struct folio *folio; folio = filemap_get_folio(jd->jd_inode->i_mapping, index); + if (!folio) + return; folio_wait_locked(folio); if (folio_test_error(folio)) From patchwork Wed Jan 18 09:43:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13105980 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 590FDC32793 for ; Wed, 18 Jan 2023 09:44:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF29C6B0081; Wed, 18 Jan 2023 04:44:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA2396B0082; Wed, 18 Jan 2023 04:44:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D92B16B0083; Wed, 18 Jan 2023 04:44:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CACBE6B0081 for ; Wed, 18 Jan 2023 04:44:23 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A78CAA079B for ; Wed, 18 Jan 2023 09:44:23 +0000 (UTC) X-FDA: 80367434406.21.7D97EFE Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf13.hostedemail.com (Postfix) with ESMTP id 3BAC320010 for ; Wed, 18 Jan 2023 09:44:22 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=mSCDCWin; spf=none (imf13.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674035062; a=rsa-sha256; cv=none; b=qOY7vngBR/Q887YjvR7DTlwLwKvLZC7b6vBleFlqb1VGZCan2Eo24m6Cn/sylzEcrZQvTF PFd7ePHkL5woYLNRb/klGzGay0ctV/uaJ5i/MS4+irwUgURTZ8662xoQNQWXGQc+mCqHov jjPf+TtPZdqeOH4tHdRXRJKwqcskZZ0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=mSCDCWin; spf=none (imf13.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674035062; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ewY31mbHxOfBtCPdgdKzYjQ0wPkqac5AmSjDkb40tFw=; b=RqbYdrOdDyFZuemGgaPPnyYXG4kDheg+RimlstIcogDgQGsNkC2wnlFLPVJdbeWoSoDzl2 5yp0tnbxn3l8Wogs0OuAh8XWBCEs6n2wxBiT4StTzBqMnLwZxGsM15Mpq4xNt+WgpX443b nt4TmpLPrAN5cRavaztllryeXOzKuZo= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=ewY31mbHxOfBtCPdgdKzYjQ0wPkqac5AmSjDkb40tFw=; b=mSCDCWinUY/HS19oiHLIYU7HTJ xzmM8Qtfxh3HIuymTISooTmX6MPgoflOa0QEqARdl58+fsr8DnAM2OmWVtGDhwxK56ZTcXRoTQBYc N7fS0PP9RlpPUqBe8Z+JfSMNivMFeCH8O7mEix/D9DJC2FhilwruTYNIfFp2CAtuxiaCqX8cB8ypc i6fXmBJvEW6wRvYpqVZjOFWDrJdIQ7/z/dJm65mWiD83UIjIo8LqP0ZpBFAIe1yPaI115hKSn+ooa r/wDnRGHqtfS0o2zlJoQ8uewHgGSm9sJ9WvQUpk1dqyVo0wKkPBdMHEn+BtUTrCt3neypSrdkLX+J OaMKoOxQ==; Received: from 213-147-167-250.nat.highway.webapn.at ([213.147.167.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI4zN-000ABI-Gv; Wed, 18 Jan 2023 09:44:14 +0000 From: Christoph Hellwig To: Andrew Morton , Matthew Wilcox , Hugh Dickins Cc: linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nilfs@vger.kernel.org Subject: [PATCH 8/9] btrfs: handle a NULL folio in extent_range_redirty_for_io Date: Wed, 18 Jan 2023 10:43:28 +0100 Message-Id: <20230118094329.9553-9-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118094329.9553-1-hch@lst.de> References: <20230118094329.9553-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Queue-Id: 3BAC320010 X-Rspamd-Server: rspam01 X-Stat-Signature: pr755h698p3iigtohqkhti9rhusip13g X-HE-Tag: 1674035062-623845 X-HE-Meta: U2FsdGVkX19pJgelc36f0mGyqXqCBMZkS31c8fwUcU3j6m+4/yR1a2e5KDaKL+S6qaD6stJBgCrAk3/GCoJk0dms+TJqPRZ3UskISOK7zqBOmKNL20Ra/GPC0r37Sn0r5tewwyC3fqE7y8srbHXD1CKl7LSi/XXzqAUOeRSC6kbGszopLe7TNEhcZYRVj1zuY7kT7oZDSyZb24ehcQZbInDFBZIjmFX65lEOFyXm2MYThHeXT2bJbIckm8EJTf+VFXX2tMhhQjYdwwotEjxNvQfS01z+GqrouROTcuZMaGZ5XWs7srdR2sAvpe8ibqiTxbyw2vszD8utlTu2UbN+PwTChaFLQj2KIwQTfT9DebH2N3BTzSRrLeS6uMAauW8TNoK1AG7S9O/WtcW2aP4I9wmQXraPGw0GnWV5xbv2mOph+HSKefQKPJ1mD9HBqGeElaMouvD1UdQh4aeSJ4PuKcdDL2CFffJRUnTTi/RLsfIkCJWUl4anXRitMfN3MLRyRLQzU5bn3I7Jg3A6Lqp+4pH+DQJf/SELajq23Fn/lwKAzid2OZwtBLKqpAwWI48rgLDKn/jHvbfBpixuMXEnK1FNQ3NGJsGv3/n89Uw++LPVxWgKaSzPqx3q14yM2sp0Adji3DufRjoAw6aAyJmUOPD6bxuMMf2AC4KMcYFDUZNiekqMRMNzJuLZE+O9dwbREXOCCTyYmxDNEGyWb9QAKFCSnUWX4V4W+JWECDvU3DZuJXW3QFiIVF/YUen7OWybsBpd6xu8LFXMLxxmUl8VBYpkcnXV3EcsXB8I3nzrWZ4GMicbdymUovO0PWFpggZZ/1TgBDUYefqVskhNj5ltdwSwe2J4GKq3vo3D3sqG/4BeHhnYTHHFjYNVG4HVRiKbFWZbea7Qybc+NXjffF16nkJnJIILDsPfBfs869TmZurvKOLQpb1Tre7M3iKzG7NTDYLYUEsG3UNrCUjfGPm eOo6tzgP TEK9+zTp7BT6Mv84rnVEmKfMRS/G+4rRB2Cw3mRRJ/YVBhLa33xl+DyDNwZRyxMR+K9q5+4FKpEIWEOnakCCKUDxP/0k5bPY0bLDzs1EWoUAVmM6ltqCXpFCsf13Z4sfuN4iqb1n7WzDN1d0dYtLyEPO/oW9khubiAmGMUXrXyw7Df5uF9mYlnLul6qOUrICwU1LvnhCD19R5GsMdcMVGOtZtuuEOY13pbM4MBG4iBba86SA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: filemap_get_folio can return NULL, skip those cases. Signed-off-by: Christoph Hellwig --- fs/btrfs/extent_io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index d55e4531ffd212..a54d2cf74ba020 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -230,6 +230,8 @@ void extent_range_redirty_for_io(struct inode *inode, u64 start, u64 end) while (index <= end_index) { folio = filemap_get_folio(mapping, index); + if (!folio) + continue; filemap_dirty_folio(mapping, folio); folio_account_redirty(folio); index += folio_nr_pages(folio); From patchwork Wed Jan 18 09:43:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13105981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4AD1C32793 for ; Wed, 18 Jan 2023 09:44:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5072A6B0071; Wed, 18 Jan 2023 04:44:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B7C16B007D; Wed, 18 Jan 2023 04:44:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3586D6B0083; Wed, 18 Jan 2023 04:44:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 25FAA6B0071 for ; Wed, 18 Jan 2023 04:44:28 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F35201402EE for ; Wed, 18 Jan 2023 09:44:27 +0000 (UTC) X-FDA: 80367434616.30.ACE08C9 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf05.hostedemail.com (Postfix) with ESMTP id 4A86C100002 for ; Wed, 18 Jan 2023 09:44:26 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="TQTt/SAb"; spf=none (imf05.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674035066; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=J1bJRn8dMRq79u1+uHawGew6oUOcQ5MnfgpdoCFCIVE=; b=5yJKYC76VxesBzVH6LKOzAs6WClsFX2GEqv4LF89VeqJOJHNSGxsf7SNW8iMcw9AEFvyii o16tfB6G6S55ve4n58PAt5lRHy+EPHAWIDNYAKviZTp7uHU0O7WYs77snREiqqSAChq+tp 8+txWdqdGmOPIzKsPI1ywnZJ65TY7DE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="TQTt/SAb"; spf=none (imf05.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674035066; a=rsa-sha256; cv=none; b=dc1cP4XpkDgvmSTqNUXRLof41uwDvZ1KvpaD7HjHG3lToVL6B8RufWzNcm/wBmxeb4+fc0 WMTlPkt99acU2ICb0PK+X9WBMYKgXL+W85IyE66bYDB6F/NWzoAddnKLB9RxhHsQXQp74e KQOVdWvg/eHdT9XwEw8djrUXEcq1Ing= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=J1bJRn8dMRq79u1+uHawGew6oUOcQ5MnfgpdoCFCIVE=; b=TQTt/SAbg4Elgy7FQ74N+cMV0y 8A+E+kNYML31DWmWs4Vll09VogMb8nddkG06zsPFdV8usGFtyocAqnXN57cmrApq8eZZjnL4n+ifZ WTSXrwV4tlafd1chRE92COzvQG7fg1aSkHlPqml0E6wNASis14pGRrZ4ApGcYImCTW6fX1CTWzUv2 bu3Rale/X80o1JAwkRlkaLUYwMlLzC4QSa5D1tLsDmBgZbAfJpqFOeq/9AzBGbfOUTNRSkmZdrP4t O3Z3gS4V0zEibcUY0AsGOZXdCIYf7ruz2tu+uNRuzijI7EEK8vCpT2jpVCQcGCF3fi9K3tobLD2K6 xqM08S8g==; Received: from 213-147-167-250.nat.highway.webapn.at ([213.147.167.250] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI4zR-000AD8-W6; Wed, 18 Jan 2023 09:44:18 +0000 From: Christoph Hellwig To: Andrew Morton , Matthew Wilcox , Hugh Dickins Cc: linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nilfs@vger.kernel.org Subject: [PATCH 9/9] mm: return an ERR_PTR from __filemap_get_folio Date: Wed, 18 Jan 2023 10:43:29 +0100 Message-Id: <20230118094329.9553-10-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118094329.9553-1-hch@lst.de> References: <20230118094329.9553-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Queue-Id: 4A86C100002 X-Stat-Signature: p9a6gxtwhse9jyhk7e4ood5aq7asq1sb X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1674035066-305289 X-HE-Meta: U2FsdGVkX19OclQqW8uUcolqxUnDIrt+hUvvVYup/KqLwDJMG84iQQdeOdrvP8f1YYOygxOkLqcBT0Jwt/HB4Hxwth0BEj3JirP5go5z1GoL2ShOQy/Y7Eh0BTUSVmTkTQ9kEQeHPtgCgtQxSFdeUMjkIL17IMNKQadIidtO55wYALqEManEmB+RuBHiIwbl8Iyb05GzA2vkj36RtcDb28wcAnHyvQMf2Y1SdeRMdwdvijV+nAn2ZMqAJgxEBoS8fQerw60eh3vKHINf9pvgWNEgELqWAyACgaxMvFESNABOxDvFZQzrYpf6VBGp7R5F4JyhdDR9p7xca9E1pJswjRnBPYEFUy3ZexPz02fsPTbVVc7Tme4lUNTvI96ODeVyjUaE5GS3mRUpfeHEGtQ/NdqiPmRJZpJiRvpQgF7KusoLEN+OAt/kJKInqVOVRZo1pDJgzcXEolOhODEZdl5A/Ko6E5Qzpwdy08GJhnL+r7SLu+EDT0Mkb4gUYlRVzFykL5e6UmVC7UkTMf5H6e6csMbsVptruGT75YlwKpfsPlsRJYUXgxyQlA4KnuuonMCH7pddiLrIXWV2f6qp17hKYl/V/Gr553eUCZZo0Cax5hvt9KvxUzLP8M3SNRLfH/H6V39EoNU94MhbFH3xrM9X7psnCd2EPKmAB53MKCMnMIrR+blHS1JWh1Z7QqN9PBmq50Qi909y0e1LwMUIVqmlwcKUaCPS7Zl6NIqGvRu9y8roF9zd6LHOLJdI2dJ4lerBEH945iK5qQh98OASbPirlPy4EiapimgGZqnNIbDNkWEYhvumEsXvYnFXV1+VeX+aTn9GXU6kd21vBHbO4+KVDWlyNoyF7HQwNsd2+RzfWnM7P7DXaiLT5pb4bNrdIz9gtT4GZ2/T7b1W1h876tyQbAEmFnvRwB5DWP7qtanzuw3HwrVEMLgmQb1WCF9V/lXCdhGd1Qi+16lfyMNEXYM Xi4xGWP9 u/25qIKG16R6HyUmbNYsJhSJ66eypCTlqhmGfaQs6K4+x0jG06tlZOsfooMmQxOab6wT/W7FgoNsY28UaMlz7dD6JKxSG2A9ranKSSyz387tZYDzzJe32xbuD/q5TGr5Qs+FOHpSw6UESPBSCxJ9/4LCmXa8hhqvuVI43AYqdLEJpFuqLcsADfSgGSykEHDTtSLqLfD3SjprLdxYJakPY9i8W9j95vX9oaZU4N2LyhZU4Ikc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Instead of returning NULL for all errors, distinguish between: - no entry found and not asked to allocated (-ENOENT) - failed to allocate memory (-ENOMEM) - would block (-EAGAIN) so that callers don't have to guess the error based on the passed in flags. Also pass through the error through the direct callers: filemap_get_folio, filemap_lock_folio filemap_grab_folio and filemap_get_incore_folio. Signed-off-by: Christoph Hellwig --- fs/afs/dir.c | 10 +++++----- fs/afs/dir_edit.c | 2 +- fs/afs/write.c | 4 ++-- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent_io.c | 2 +- fs/ext4/inode.c | 2 +- fs/ext4/move_extent.c | 8 ++++---- fs/gfs2/lops.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/iomap/buffered-io.c | 6 +++--- fs/netfs/buffered_read.c | 4 ++-- fs/nilfs2/page.c | 6 +++--- mm/filemap.c | 14 ++++++++------ mm/folio-compat.c | 2 +- mm/huge_memory.c | 2 +- mm/memcontrol.c | 2 +- mm/mincore.c | 2 +- mm/shmem.c | 4 ++-- mm/swap_state.c | 15 ++++++++------- mm/swapfile.c | 4 ++-- mm/truncate.c | 15 ++++++++------- 21 files changed, 57 insertions(+), 53 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index b7c1f8c84b38aa..41d0b4203870be 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -319,16 +319,16 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key) struct folio *folio; folio = filemap_get_folio(mapping, i); - if (!folio) { + if (IS_ERR(folio)) { if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) afs_stat_v(dvnode, n_inval); - - ret = -ENOMEM; folio = __filemap_get_folio(mapping, i, FGP_LOCK | FGP_CREAT, mapping->gfp_mask); - if (!folio) + if (IS_ERR(folio)) { + ret = PTR_ERR(folio); goto error; + } folio_attach_private(folio, (void *)1); folio_unlock(folio); } @@ -524,7 +524,7 @@ static int afs_dir_iterate(struct inode *dir, struct dir_context *ctx, */ folio = __filemap_get_folio(dir->i_mapping, ctx->pos / PAGE_SIZE, FGP_ACCESSED, 0); - if (!folio) { + if (IS_ERR(folio)) { ret = afs_bad(dvnode, afs_file_error_dir_missing_page); break; } diff --git a/fs/afs/dir_edit.c b/fs/afs/dir_edit.c index 0ab7752d1b758e..f0eddccbdd9541 100644 --- a/fs/afs/dir_edit.c +++ b/fs/afs/dir_edit.c @@ -115,7 +115,7 @@ static struct folio *afs_dir_get_folio(struct afs_vnode *vnode, pgoff_t index) folio = __filemap_get_folio(mapping, index, FGP_LOCK | FGP_ACCESSED | FGP_CREAT, mapping->gfp_mask); - if (!folio) + if (IS_ERR(folio)) clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); else if (folio && !folio_test_private(folio)) folio_attach_private(folio, (void *)1); diff --git a/fs/afs/write.c b/fs/afs/write.c index 2d3b08b7406ca7..cf1eb0d122c275 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -232,7 +232,7 @@ static void afs_kill_pages(struct address_space *mapping, _debug("kill %lx (to %lx)", index, last); folio = filemap_get_folio(mapping, index); - if (!folio) { + if (IS_ERR(folio)) { next = index + 1; continue; } @@ -270,7 +270,7 @@ static void afs_redirty_pages(struct writeback_control *wbc, _debug("redirty %llx @%llx", len, start); folio = filemap_get_folio(mapping, index); - if (!folio) { + if (IS_ERR(folio)) { next = index + 1; continue; } diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 7d5da43a89ee7f..f1035e0bcf8c6a 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4034,7 +4034,7 @@ static int wait_dev_supers(struct btrfs_device *device, int max_mirrors) folio = filemap_get_folio(device->bdev->bd_inode->i_mapping, bytenr >> PAGE_SHIFT); - if (!folio) { + if (IS_ERR(folio)) { errors++; if (i == 0) primary_failed = true; diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index a54d2cf74ba020..faaab9fae66d66 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -230,7 +230,7 @@ void extent_range_redirty_for_io(struct inode *inode, u64 start, u64 end) while (index <= end_index) { folio = filemap_get_folio(mapping, index); - if (!folio) + if (IS_ERR(folio)) continue; filemap_dirty_folio(mapping, folio); folio_account_redirty(folio); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index fb6cd994e59afa..ee8f82c7acf9ff 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5391,7 +5391,7 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode) while (1) { struct folio *folio = filemap_lock_folio(inode->i_mapping, inode->i_size >> PAGE_SHIFT); - if (!folio) + if (IS_ERR(folio)) return; ret = __ext4_journalled_invalidate_folio(folio, offset, folio_size(folio) - offset); diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 2de9829aed63bf..7bf6d069199cbb 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -141,18 +141,18 @@ mext_folio_double_lock(struct inode *inode1, struct inode *inode2, flags = memalloc_nofs_save(); folio[0] = __filemap_get_folio(mapping[0], index1, fgp_flags, mapping_gfp_mask(mapping[0])); - if (!folio[0]) { + if (IS_ERR(folio[0])) { memalloc_nofs_restore(flags); - return -ENOMEM; + return PTR_ERR(folio[0]); } folio[1] = __filemap_get_folio(mapping[1], index2, fgp_flags, mapping_gfp_mask(mapping[1])); memalloc_nofs_restore(flags); - if (!folio[1]) { + if (IS_ERR(folio[1])) { folio_unlock(folio[0]); folio_put(folio[0]); - return -ENOMEM; + return PTR_ERR(folio[1]); } /* * __filemap_get_folio() may not wait on folio's writeback if diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 51d4b610127cdb..9e8a00cee8afc1 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -472,7 +472,7 @@ static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index, struct folio *folio; folio = filemap_get_folio(jd->jd_inode->i_mapping, index); - if (!folio) + if (IS_ERR(folio)) return; folio_wait_locked(folio); diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 48f1a8ad22431e..19dac1fbcd3705 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -697,7 +697,7 @@ static void hugetlbfs_zero_partial_page(struct hstate *h, struct folio *folio; folio = filemap_lock_folio(mapping, idx); - if (!folio) + if (IS_ERR(folio)) return; start = start & ~huge_page_mask(h); diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 356193e44cf07f..ab5a5a5a3e0283 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -614,8 +614,8 @@ static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, folio = __filemap_get_folio(iter->inode->i_mapping, pos >> PAGE_SHIFT, fgp, mapping_gfp_mask(iter->inode->i_mapping)); - if (!folio) { - status = (iter->flags & IOMAP_NOWAIT) ? -EAGAIN : -ENOMEM; + if (IS_ERR(folio)) { + status = PTR_ERR(folio); goto out_no_page; } @@ -882,7 +882,7 @@ static int iomap_write_delalloc_scan(struct inode *inode, /* grab locked page */ folio = filemap_lock_folio(inode->i_mapping, start_byte >> PAGE_SHIFT); - if (!folio) { + if (IS_ERR(folio)) { start_byte = ALIGN_DOWN(start_byte, PAGE_SIZE) + PAGE_SIZE; continue; diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index 7679a68e819307..209726a9cfdb9c 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -350,8 +350,8 @@ int netfs_write_begin(struct netfs_inode *ctx, retry: folio = __filemap_get_folio(mapping, index, fgp_flags, mapping_gfp_mask(mapping)); - if (!folio) - return -ENOMEM; + if (IS_ERR(folio)) + return PTR_ERR(folio); if (ctx->ops->check_write_begin) { /* Allow the netfs (eg. ceph) to flush conflicts. */ diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 41ccd43cd9797f..5cf30827f244c4 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -259,10 +259,10 @@ int nilfs_copy_dirty_pages(struct address_space *dmap, NILFS_PAGE_BUG(&folio->page, "inconsistent dirty state"); dfolio = filemap_grab_folio(dmap, folio->index); - if (unlikely(!dfolio)) { + if (unlikely(IS_ERR(dfolio))) { /* No empty page is added to the page cache */ - err = -ENOMEM; folio_unlock(folio); + err = PTR_ERR(dfolio); break; } if (unlikely(!folio_buffers(folio))) @@ -311,7 +311,7 @@ void nilfs_copy_back_pages(struct address_space *dmap, folio_lock(folio); dfolio = filemap_lock_folio(dmap, index); - if (dfolio) { + if (!IS_ERR(dfolio)) { /* overwrite existing folio in the destination cache */ WARN_ON(folio_test_dirty(dfolio)); nilfs_copy_page(&dfolio->page, &folio->page, 0); diff --git a/mm/filemap.c b/mm/filemap.c index 35baadd130795c..4037a132f7adcc 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1905,7 +1905,7 @@ void *filemap_get_entry(struct address_space *mapping, pgoff_t index) * * If there is a page cache page, it is returned with an increased refcount. * - * Return: The found folio or %NULL otherwise. + * Return: The found folio or an ERR_PTR() otherwise. */ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, int fgp_flags, gfp_t gfp) @@ -1923,7 +1923,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, if (fgp_flags & FGP_NOWAIT) { if (!folio_trylock(folio)) { folio_put(folio); - return NULL; + return ERR_PTR(-EAGAIN); } } else { folio_lock(folio); @@ -1962,7 +1962,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, folio = filemap_alloc_folio(gfp, 0); if (!folio) - return NULL; + return ERR_PTR(-ENOMEM); if (WARN_ON_ONCE(!(fgp_flags & (FGP_LOCK | FGP_FOR_MMAP)))) fgp_flags |= FGP_LOCK; @@ -1987,6 +1987,8 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, folio_unlock(folio); } + if (!folio) + return ERR_PTR(-ENOENT); return folio; } EXPORT_SYMBOL(__filemap_get_folio); @@ -3126,7 +3128,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) * Do we have something in the page cache already? */ folio = filemap_get_folio(mapping, index); - if (likely(folio)) { + if (likely(!IS_ERR(folio))) { /* * We found the page, so try async readahead before waiting for * the lock. @@ -3155,7 +3157,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) folio = __filemap_get_folio(mapping, index, FGP_CREAT|FGP_FOR_MMAP, vmf->gfp_mask); - if (!folio) { + if (IS_ERR(folio)) { if (fpin) goto out_retry; filemap_invalidate_unlock_shared(mapping); @@ -3506,7 +3508,7 @@ static struct folio *do_read_cache_folio(struct address_space *mapping, filler = mapping->a_ops->read_folio; repeat: folio = filemap_get_folio(mapping, index); - if (!folio) { + if (IS_ERR(folio)) { folio = filemap_alloc_folio(gfp, 0); if (!folio) return ERR_PTR(-ENOMEM); diff --git a/mm/folio-compat.c b/mm/folio-compat.c index f3841b4977b68e..4cd173336d8589 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -97,7 +97,7 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index, struct folio *folio; folio = __filemap_get_folio(mapping, index, fgp_flags, gfp); - if (!folio) + if (IS_ERR(folio)) return NULL; return folio_file_page(folio, index); } diff --git a/mm/huge_memory.c b/mm/huge_memory.c index a2830019aaa017..b0c9170632e37c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3103,7 +3103,7 @@ static int split_huge_pages_in_file(const char *file_path, pgoff_t off_start, struct folio *folio = filemap_get_folio(mapping, index); nr_pages = 1; - if (!folio) + if (IS_ERR(folio)) continue; if (!folio_test_large(folio)) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 893427aded0191..8bcea91099d218 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5693,7 +5693,7 @@ static struct page *mc_handle_file_pte(struct vm_area_struct *vma, /* shmem/tmpfs may report page out on swap: account for that too. */ index = linear_page_index(vma, addr); folio = filemap_get_incore_folio(vma->vm_file->f_mapping, index); - if (!folio) + if (IS_ERR(folio)) return NULL; return folio_file_page(folio, index); } diff --git a/mm/mincore.c b/mm/mincore.c index a085a2aeabd8e6..386c1aed1a8aef 100644 --- a/mm/mincore.c +++ b/mm/mincore.c @@ -61,7 +61,7 @@ static unsigned char mincore_page(struct address_space *mapping, pgoff_t index) * tmpfs's .fault). So swapped out tmpfs mappings are tested here. */ folio = filemap_get_incore_folio(mapping, index); - if (folio) { + if (!IS_ERR(folio)) { present = folio_test_uptodate(folio); folio_put(folio); } diff --git a/mm/shmem.c b/mm/shmem.c index 769107f376562f..676318f95f7b40 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -603,7 +603,7 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, index = (inode->i_size & HPAGE_PMD_MASK) >> PAGE_SHIFT; folio = filemap_get_folio(inode->i_mapping, index); - if (!folio) + if (IS_ERR(folio)) goto drop; /* No huge page at the end of the file: nothing to split */ @@ -3187,7 +3187,7 @@ static const char *shmem_get_link(struct dentry *dentry, if (!dentry) { folio = filemap_get_folio(inode->i_mapping, 0); - if (!folio) + if (IS_ERR(folio)) return ERR_PTR(-ECHILD); if (PageHWPoison(folio_page(folio, 0)) || !folio_test_uptodate(folio)) { diff --git a/mm/swap_state.c b/mm/swap_state.c index c39ea34bc4fc10..e853d3eecf55bb 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -330,7 +330,7 @@ struct folio *swap_cache_get_folio(swp_entry_t entry, struct folio *folio; folio = filemap_get_folio(swap_address_space(entry), swp_offset(entry)); - if (folio) { + if (!IS_ERR(folio)) { bool vma_ra = swap_use_vma_readahead(); bool readahead; @@ -360,6 +360,8 @@ struct folio *swap_cache_get_folio(swp_entry_t entry, if (!vma || !vma_ra) atomic_inc(&swapin_readahead_hits); } + } else { + folio = NULL; } return folio; @@ -383,22 +385,21 @@ struct folio *filemap_get_incore_folio(struct address_space *mapping, struct folio *folio = filemap_get_entry(mapping, index); if (!xa_is_value(folio)) - goto out; + return folio; if (!shmem_mapping(mapping)) - return NULL; + return ERR_PTR(-ENOENT); swp = radix_to_swp_entry(folio); /* There might be swapin error entries in shmem mapping. */ if (non_swap_entry(swp)) - return NULL; + return ERR_PTR(-ENOENT); /* Prevent swapoff from happening to us */ si = get_swap_device(swp); if (!si) - return NULL; + return ERR_PTR(-ENOENT); index = swp_offset(swp); folio = filemap_get_folio(swap_address_space(swp), index); put_swap_device(si); -out: return folio; } @@ -425,7 +426,7 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, folio = filemap_get_folio(swap_address_space(entry), swp_offset(entry)); put_swap_device(si); - if (folio) + if (!IS_ERR(folio)) return folio_file_page(folio, swp_offset(entry)); /* diff --git a/mm/swapfile.c b/mm/swapfile.c index a5729273480e07..a128b61b6b8c91 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -136,7 +136,7 @@ static int __try_to_reclaim_swap(struct swap_info_struct *si, int ret = 0; folio = filemap_get_folio(swap_address_space(entry), offset); - if (!folio) + if (IS_ERR(folio)) return 0; /* * When this function is called from scan_swap_map_slots() and it's @@ -2096,7 +2096,7 @@ static int try_to_unuse(unsigned int type) entry = swp_entry(type, i); folio = filemap_get_folio(swap_address_space(entry), i); - if (!folio) + if (IS_ERR(folio)) continue; /* diff --git a/mm/truncate.c b/mm/truncate.c index 7b4ea4c4a46b20..86de31ed4d3238 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -375,7 +375,7 @@ void truncate_inode_pages_range(struct address_space *mapping, same_folio = (lstart >> PAGE_SHIFT) == (lend >> PAGE_SHIFT); folio = __filemap_get_folio(mapping, lstart >> PAGE_SHIFT, FGP_LOCK, 0); - if (folio) { + if (!IS_ERR(folio)) { same_folio = lend < folio_pos(folio) + folio_size(folio); if (!truncate_inode_partial_folio(folio, lstart, lend)) { start = folio->index + folio_nr_pages(folio); @@ -387,14 +387,15 @@ void truncate_inode_pages_range(struct address_space *mapping, folio = NULL; } - if (!same_folio) + if (!same_folio) { folio = __filemap_get_folio(mapping, lend >> PAGE_SHIFT, FGP_LOCK, 0); - if (folio) { - if (!truncate_inode_partial_folio(folio, lstart, lend)) - end = folio->index; - folio_unlock(folio); - folio_put(folio); + if (!IS_ERR(folio)) { + if (!truncate_inode_partial_folio(folio, lstart, lend)) + end = folio->index; + folio_unlock(folio); + folio_put(folio); + } } index = start;