From patchwork Mon Jan 29 14:34:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535759 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 CA352C47422 for ; Mon, 29 Jan 2024 14:35:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 594AA6B0071; Mon, 29 Jan 2024 09:35:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F4BB6B00A1; Mon, 29 Jan 2024 09:35:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 284046B00A2; Mon, 29 Jan 2024 09:35:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0D8036B0071 for ; Mon, 29 Jan 2024 09:35:16 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CDC6DC0A17 for ; Mon, 29 Jan 2024 14:35:15 +0000 (UTC) X-FDA: 81732596190.22.5D1A1EE Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id E2476140011 for ; Mon, 29 Jan 2024 14:35:13 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3Fs5POjt; dmarc=none; spf=none (imf23.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538913; 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=IGlT4PlWbZpkcMxkrjhe0P1uDfgYrW+CfMT58/K5QjU=; b=mWGIndQBYbTYzJ1zWxZhPpWnP1RTiea7ICAt07iw6WfQDiLvttxZASb23Rq+9A7GbwlkfC OJkbwdF8c3kM4GfXKuip9rQDHI1U2wcb2vZjlwBwMyT83q46BH4/QPJrIYeLTSxaC1zsG7 9acEt0KOUDx6oPLjUcIbghqK10D3th8= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3Fs5POjt; dmarc=none; spf=none (imf23.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538913; a=rsa-sha256; cv=none; b=WMhCi+GfEaNfDFf6VjHTjjtzNrS851Bh/Q0I2FnD3S5mgziaQMkWHfkafLHvHLH4v9HS9E bwLlZC8gEOkFVAR1qgIryhVpPrjSed5E3c6x1aLyJxTzBiJIQcwqQRFvDZvuS/KGzJtESq 8eb0h1xIGzdxMZnW0v9PdzkzH2mY5iI= 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=IGlT4PlWbZpkcMxkrjhe0P1uDfgYrW+CfMT58/K5QjU=; b=3Fs5POjtAGkn+BqEHVp6xhQSfs baUrqJRNT9czpEH3taWzhf88/yg6idYiKhFhOm8gFtid320eB1hJIy8Njote4Affe9rP6YdmKqHzM mDkWf9pHvNSBVkfCwsKEDHsNm9dtmftn7VgP3X4b93DYvF2w0smw5wHY5X+UaL8CN/y/G1eiZtb0p 2aqZZOwCQ3PqCiQiKb71uunekh3OZZm4GyYvCC5ANjO8Ta6CYe9mLpDPRdrRIibr7pJxr6qxdrKVR sim3xdYpq/GpVVlUXhyOIr9QY+5+KJTdlejzcSe+LSoJ+hqIqCEEyEh/50Q5XTPJLxpih+rneGGSS Ewq7XqmA==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSj7-0000000D64G-25E1; Mon, 29 Jan 2024 14:35:10 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 01/20] mm: move mapping_set_update out of Date: Mon, 29 Jan 2024 15:34:43 +0100 Message-Id: <20240129143502.189370-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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-Stat-Signature: hjmn6bothk4rrxdy1fxidyzts39ur93q X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E2476140011 X-HE-Tag: 1706538913-541483 X-HE-Meta: U2FsdGVkX1/qJevk0H7mM+AMb2jSGgSYK6eJ+R1fLaXbIaFYmqaTH/us0dxpu77vbkwfWxZvl72J/9baEUUyzIrKl6/v1j7mAk+lwihKOGSC9xEt7MiC49hhLjnFViAANsihvD90voUSVxAnbRm4BCeqQdrWlI/1XLj0lNOO1GhFxglKsNU+w3SO6/UCJhEbE5kruAqy1mzVlq5+ybHjPjsS6e9ICdl+GFpV9C/5wuK2rj4Y2UMFCR4w0pYUWXJaR0FAIqdfjgbnDtBSx2nLA1PvjwdYPDLDhAOee/fNvdeWCo44rfV+t/hQQZk3OkyjdzcA/LQSPRvxPGauxWtqs24sMUDAHnadG5MQfsgW1m+BhJBVNsJ+U6Eq8rL7jh5Ymvmtc4FByi004YgvzlndQ7FKrzSxh2WBSHPmc1xqhQC0BZ1f0dsT9khx97IhCdLk5KUtxTOCHBpfjBjNZz9vC/Cy3Yo4kxfBveYV+ulc82+jrdpKKh6NcXrxxtMm6axI21KQppWG8+xBRmjQZZE344xCDcbIrosVjmYORvkwbmFbCs63ZIRUwjExB5knpX0F9nustteF4TqckZ3oL0myf6MPr7k9FGmojaIvNxMI5u4z/sPaXeWaP/voq7bhqtv9hXOMkmJWt48qGP0wEh+nZ+YMPgrxToFXB15ZISAml1C83qcsTMCp+MMdFMaGYjVesen2Q5rOLmOm2h66615D/3KpPdYHYlAzz1ZwSMEvmYzLhpwkhGYtvrfk92GEAqzNNnQIH2HRdHkufjCnV0HdEhoe7sTYjiOctLU6lbvEi6QP0oNacU73k4d+C63bFps+a7crOTKhDFj1rn/mlCZrQhwerm/orHrFma9dsHFLiSIPC9Hm25mNaNqJtiUduQ0x+mOhVfREF0+xFn3L/2uATqpWt3Asj/MVCu3fnjCNVvN7VQR6pekYEOS6A2H/3vXmjJn6Gl0j+PgZYMb3Vv3 UTr0EhG4 Oelc+LApwt/4TZ3eWnDyf7QX3iW4+8nCNKvqXefToUAaSjgvYF75tu3wSTs5dkmFnfSe3IcshTSRul1RE1jUNxfNmda3TycJo3eX0841jXtmBTJCrnGChhOQSHzB1Nxh/TWo6bD75KdstKndFyaz+Rr79zvP1Dlrz/BVjPkHiGJ7JWTrdRmcYy9H7p/9bUnk/ow1UprXqCcdGqCuT5vvPBImxx0mDPDO2Xia7ft+bvHCzTNoh1e1Ked5aFYb9dfthZgCzRDS5UO75fI1m4EF+ST4m17w/KgD01Ku9IYx00i3F733fLQF6J+RR9sZiXZJMLoPOd72Qd9wa1DvhqTZYh99N9gicIXIrDRsWSwALUWH97G8nS+MVHt9wTgaEn4brf4MsWNqkUu9NM4O1irxRffEBmGfkhWe2rVs0D7sdaUrKo+EeMMEqHvPobkazRVOfNH5ekrajmjWwCnV6/Zn3V0PRelnahzxnjTyXB40203VPZOSUxLzuofJAJehjeI4pVMpjUfrZpoQriAk= 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: List-Subscribe: List-Unsubscribe: mapping_set_update is only used inside mm/. Move mapping_set_update to mm/internal.h and turn it into an inline function instead of a macro. Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/swap.h | 10 ---------- mm/filemap.c | 9 +++++++++ mm/internal.h | 4 ++++ mm/workingset.c | 1 + 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 4db00ddad26169..755fc64ba48ded 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -350,16 +350,6 @@ void *workingset_eviction(struct folio *folio, struct mem_cgroup *target_memcg); void workingset_refault(struct folio *folio, void *shadow); void workingset_activation(struct folio *folio); -/* Only track the nodes of mappings with shadow entries */ -void workingset_update_node(struct xa_node *node); -extern struct list_lru shadow_nodes; -#define mapping_set_update(xas, mapping) do { \ - if (!dax_mapping(mapping) && !shmem_mapping(mapping)) { \ - xas_set_update(xas, workingset_update_node); \ - xas_set_lru(xas, &shadow_nodes); \ - } \ -} while (0) - /* linux/mm/page_alloc.c */ extern unsigned long totalreserve_pages; diff --git a/mm/filemap.c b/mm/filemap.c index 750e779c23db74..6c8b089f00d26a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -124,6 +124,15 @@ * ->private_lock (zap_pte_range->block_dirty_folio) */ +static void mapping_set_update(struct xa_state *xas, + struct address_space *mapping) +{ + if (dax_mapping(mapping) || shmem_mapping(mapping)) + return; + xas_set_update(xas, workingset_update_node); + xas_set_lru(xas, &shadow_nodes); +} + static void page_cache_delete(struct address_space *mapping, struct folio *folio, void *shadow) { diff --git a/mm/internal.h b/mm/internal.h index f309a010d50fb6..4398f572485f00 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1266,4 +1266,8 @@ static inline void shrinker_debugfs_remove(struct dentry *debugfs_entry, } #endif /* CONFIG_SHRINKER_DEBUG */ +/* Only track the nodes of mappings with shadow entries */ +void workingset_update_node(struct xa_node *node); +extern struct list_lru shadow_nodes; + #endif /* __MM_INTERNAL_H */ diff --git a/mm/workingset.c b/mm/workingset.c index 2260129743282d..f2a0ecaf708d76 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -16,6 +16,7 @@ #include #include #include +#include "internal.h" /* * Double CLOCK lists From patchwork Mon Jan 29 14:34:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535760 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 A191BC47DB3 for ; Mon, 29 Jan 2024 14:35:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71BFB6B00A2; Mon, 29 Jan 2024 09:35:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A3006B00A3; Mon, 29 Jan 2024 09:35:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F8756B00A4; Mon, 29 Jan 2024 09:35:18 -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 2CF2A6B00A2 for ; Mon, 29 Jan 2024 09:35:18 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0B53C80A74 for ; Mon, 29 Jan 2024 14:35:18 +0000 (UTC) X-FDA: 81732596316.26.E935A56 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf27.hostedemail.com (Postfix) with ESMTP id 8640940011 for ; Mon, 29 Jan 2024 14:35:16 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=o0WIyZ8V; dmarc=none; spf=none (imf27.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538916; 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=nnaIGoG1q9qfUz3HCpUPzAYpM+4OPI2B6Bp4snlIbvg=; b=cz0s0gELAcAowf6HLOyK82uosW4lgOBEMF9C5cRH2Yk8LufszCorJCZKQ7dInp73OPPbD+ 7rUY+GXgCrEjFgs5toXU93eFbDn7D19v0Rg11flbtjtYgKpdmfSvDw/9r0VPqxJvwtkzuA 7OtxB5qoYfT+fBbmhA8VKoc89Ol6HpQ= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=o0WIyZ8V; dmarc=none; spf=none (imf27.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538916; a=rsa-sha256; cv=none; b=ZkCcRMjLXAeq/SDSvbKFJ3TcNdZei/lm/4/9yeYGf4y2gA0a2z/n3dwQ/nd59jDNg3Yo+w viy9bovMWupxwpCAcxriKhPQAklc1X6vVIVlpaoflc/w8fzgX2WbkaDOttpN5iLacWVkd2 VCsJkrnBYK6X76xeB7oZA1GL/pCmsY4= 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=nnaIGoG1q9qfUz3HCpUPzAYpM+4OPI2B6Bp4snlIbvg=; b=o0WIyZ8VynAr1Xcm+mMkaMz+sV SItf+DLeOV8R04PtqoOb6bQJw/5IbegZytSrH46ei+cEalfXeMP9Q3AwG84JA/p7W30jjRahB7b6I I0i2y8Vg9255nLLDHqydZ8IPeIv5Obptbgmk4ZOi2X3mIyII6WC/etqw0sNEDffUTdGllpy8TamYv 9rnUAdut6OLyVtun3mjYIYdmC3ftiQ5POh1ohTdFNZk8+SVewkyXtssI5AaHowWd2/A04iYP2t16O jtPse0UbmgdWQMA7Yk8S8knqnUJh4rQYMDwsnK79LQAAD0HDc830QSITk6iZ/6Qs7bC6E/llYyO/Y fQJ6PvYQ==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjA-0000000D65Y-2kjA; Mon, 29 Jan 2024 14:35:13 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 02/20] shmem: move shmem_mapping out of line Date: Mon, 29 Jan 2024 15:34:44 +0100 Message-Id: <20240129143502.189370-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: 8640940011 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: u8rraqbgecgu5fdd6su95cca9nxednj5 X-HE-Tag: 1706538916-24914 X-HE-Meta: U2FsdGVkX18dypMIm04vk0Z6+7ebyqxct6gNYtUlR87NHIOaTQw2lw934ydnWIL/k2T18cngPV4YOFuTjxRGHoZTHnFG1d/r41LhXZKt0zTqHkL1b+jx527Ddp7/8vd+ju6PNY8MI6cd4phGVBHsVxdM5K1OZuKlcXjwdtjuypP8jYVVHRxetY7AmbCkAe6TOWqrF61eF1Ak+eohaO76Jg0gFszFZsUukCNmU+R7YkzL2G15MX4vB4gatIj7KFEHkXZNajlollnjn8o4zA3qAa3MXjiPfWLwieMfD4ZqBO3h6TyXObcMb59+MOnx6UKmdCgsRzdar2JFQaxgjxO6p7wmhumOy7kqvUv7kvnMgwa0VF4rjgOyFLC44PzMbD+V4F5xh3CP3nQ2SkfQAyLz2+KhYYjTx3kmyvGf6Oi8xw17eFAo07zhUikRyhbzfuXT+qMQwvcGG4CecW9dIl1R1v0k2fbGd+hssARBNQQrI67NWyC1g4afinGJb9gG+3XTKY+CZ3P1GMopAmEix2xlqBPqRKxCQYdOaXw6am5D7AMaXkfqRcmyY6nUXo13MFG9+FnhJAPiuf3DMIA74fOgIsl5PU0r016QxGoRzByKACnuyPsgDuufdc9bo7j6Hh5IRMeVDczmAlZf2VvKPjV7LyftWz0BP1Svjm9NEL44ST13gBxYCim/E65nRvYsBGr2I0y6Ut/Auy4+qX5Q4IH7Shr2IZtxBzY+tuMnpMzgfBMIYCKSi5NtwiwdgQBuWch45HrFM9ZJJsmW+rFgUuLPJbjEkJtf394wJBJut2hFAUb+XXEBGqhfth5OoE/97BhD0hz61KUG6bvmWdDpL9MjHTr0U8+IQ237miNzREJieyF+KeKuWXywtkbkPp6H1bvPRQef5+opcdCYtBpRzM5lhkp+rNF1crzcl2v1yyY5Dz0rMrbMAZYti//OXh3KYnyg9TAF0Z4AQfaJyMThRaa hUiQBnEV Jecd6VGFQpcwNokhXO0ell4DYo32dW0B7tILt0WNtT0A3eTL33SLsC4ODSGRvzPfIGBhKHuMSKmfZae03g2/XldHSffZM5GfA+KEQsjwxaBRxDqipwtNwWwP9QnHMG/xC8s0eSO5kq0RpEEPM6p0ywMLBnUY2twKzyUaBY8uLEwxa5xbED4HpLGXTG/CmD3rQIUJ3L0rokuDXoEEdxslZ4BOpNw== 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: List-Subscribe: List-Unsubscribe: shmem_aops really should not be exported to the world. Move shmem_mapping and export it as internal for the one semi-legitimate modular user in udmabuf. Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/shmem_fs.h | 6 +----- mm/shmem.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index 2caa6b86106aa3..6b96a87e4bc80a 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -97,11 +97,7 @@ extern unsigned long shmem_get_unmapped_area(struct file *, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); extern int shmem_lock(struct file *file, int lock, struct ucounts *ucounts); #ifdef CONFIG_SHMEM -extern const struct address_space_operations shmem_aops; -static inline bool shmem_mapping(struct address_space *mapping) -{ - return mapping->a_ops == &shmem_aops; -} +bool shmem_mapping(struct address_space *mapping); #else static inline bool shmem_mapping(struct address_space *mapping) { diff --git a/mm/shmem.c b/mm/shmem.c index d7c84ff621860b..f607b0cab7e4e2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -254,7 +254,7 @@ static void shmem_inode_unacct_blocks(struct inode *inode, long pages) } static const struct super_operations shmem_ops; -const struct address_space_operations shmem_aops; +static const struct address_space_operations shmem_aops; static const struct file_operations shmem_file_operations; static const struct inode_operations shmem_inode_operations; static const struct inode_operations shmem_dir_inode_operations; @@ -263,6 +263,12 @@ static const struct vm_operations_struct shmem_vm_ops; static const struct vm_operations_struct shmem_anon_vm_ops; static struct file_system_type shmem_fs_type; +bool shmem_mapping(struct address_space *mapping) +{ + return mapping->a_ops == &shmem_aops; +} +EXPORT_SYMBOL_GPL(shmem_mapping); + bool vma_is_anon_shmem(struct vm_area_struct *vma) { return vma->vm_ops == &shmem_anon_vm_ops; @@ -4466,7 +4472,7 @@ static int shmem_error_remove_folio(struct address_space *mapping, return 0; } -const struct address_space_operations shmem_aops = { +static const struct address_space_operations shmem_aops = { .writepage = shmem_writepage, .dirty_folio = noop_dirty_folio, #ifdef CONFIG_TMPFS @@ -4478,7 +4484,6 @@ const struct address_space_operations shmem_aops = { #endif .error_remove_folio = shmem_error_remove_folio, }; -EXPORT_SYMBOL(shmem_aops); static const struct file_operations shmem_file_operations = { .mmap = shmem_mmap, From patchwork Mon Jan 29 14:34:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535761 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 8CD94C47422 for ; Mon, 29 Jan 2024 14:35:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EBB96B009C; Mon, 29 Jan 2024 09:35:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 178D56B009F; Mon, 29 Jan 2024 09:35:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E943E6B00A5; Mon, 29 Jan 2024 09:35:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CD0136B00A3 for ; Mon, 29 Jan 2024 09:35:21 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A72F1A19C6 for ; Mon, 29 Jan 2024 14:35:21 +0000 (UTC) X-FDA: 81732596442.22.45FC89E Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id EF6D520005 for ; Mon, 29 Jan 2024 14:35:19 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=tZh4RayM; spf=none (imf03.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538920; 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=m8bNau9njavlNFAZK08RacrmSpqtfTJnRVvJoaaL3Z8=; b=hQdZFmnkQ+dSxLL2lXz5iBh4l14zyv64JXDob+fdP/wue1VCUreB/6rKXx+mmHq4wI7W8X IixgNVsaCiQH+2Sz4f35qhlF46/xMIzeobdO44mzuPYfmNQECBc2Q/6CL/vtjhTq/kxbXh K19x37gtiYn3cpMKfE2tQy7D/HZ5+5o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538920; a=rsa-sha256; cv=none; b=y4c6zpBH2NU3ppUUs4/8XU6ewWlFllb1k/0C7nm8ovvsCAd3Jg+6bWsPko3RGDvk5by+hW Mfra+IQ+tmKt/dbfwXJPmzlnbSozQUnURI5c+B74/1z4Fag7kGn8id486l1UdGHJZH/wcN 854ADcuV/xwxdwqvGylqioLwOSB93Dw= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=tZh4RayM; spf=none (imf03.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=m8bNau9njavlNFAZK08RacrmSpqtfTJnRVvJoaaL3Z8=; b=tZh4RayMLGDoQRkvd8Hg0t+1Kv I48W9YLDAjraY8q9ek8/PmGGt0ycArACUm7FRgz74BLRwh8nyQR3jL09fw7Re5UstEhSLvSvLopvb zPzfJ4gUy6/2S8uZD5ChkpaRNEOQ4qE325YSzD5fexgdt8hoxfsyPIzgmaeZR+UFlo1BdiZJh2Gbc nz3v/spFo/dYrhPH1p8CoWFWf29nSZAA8G3YLoFJiWOzlhIHnrEGubomA5xm71S/mlCp1we6ZP5fP Ay739fM3+N+Y4zjkTWojQeFoQ8kxoiwsDevwbqRJv7xSVd2DchMNqpbjrFNRa9gETU1jh+wfzMyg9 meCkoVgg==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjE-0000000D66L-0Tvd; Mon, 29 Jan 2024 14:35:16 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 03/20] shmem: set a_ops earlier in shmem_symlink Date: Mon, 29 Jan 2024 15:34:45 +0100 Message-Id: <20240129143502.189370-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: EF6D520005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 3j1coondg1z5fbi46jqhqyry71aiot69 X-HE-Tag: 1706538919-631012 X-HE-Meta: U2FsdGVkX1+atY89j96Ifd8T7ny9oSBacVmtIfY8yfHxQqK6ipeVFMI9WXjJ3IH/GqOz0fZRgTmBpFIvkQ0r0et8xUQrPukoKsteXYOxlJgf/m8ICAmU8dZI1o0X21wfmc58VYsBCd0s41FJq1nZtQfAgETy0tfSn1W9RpKyO6doSXcGSh9OnxN0Z3OU45fx3kyQgM8Lm9L/pLC9z2NY4eCkEFHYWK/2ewu4IhXqph9QudWqOywfrXc7DQOkA63UwsIds/OT6bV79zJ5zIpjo+Jtpx1iti2H76oiGQm7KAoLPL3cVyAGx7M3bEdOWqcXz7UCuomUunqEyfbt+7vGRINJy8izxcx3lA7K7s6DqT2wZuNuKdaSR7H0j4ufhZEkBFk2q17p1lyjO+RZPGHU9CcZvK3zHcg9FHxv+qOXerAW8Lr7NusWTq4vcKa8QZlEbyY3HLOdAGHdysy4dWt7xgRrvu/K1T2aPvy0pv01BKUmINWKXTl1TeRt1HJBc6u2qgY9JIM0q0//+xR0HOEzpEiJq7k+BLBKPZLO9zYswMVOejvKVdVa+MfoqrUsuFSKn4YDqs/T2oknauYTh4Z2ZbDOlQ8P7UxjQVVbnNRIOpOxbm3GxODYme+MJC6o5JjqD/o3MqDSF437WLibJeaJ9rVex5zm/ZR0i+k35k1RsDTkkhgKmjMyRK4PFGlw+hvfnHsKBZd2iY6ExD1VaxomeNrgwbAc4UBKwEVrBIgJ9xfTiaBhfFd6QI4eu6q7sJXN3eTc43LMYkGXxkGJ+wdm31VOg2PJDFGCiB+GWKZSxpCM76lIJWtQxrurMPGNgjfv5QVNHXRS2YN+Q34q7LyWOYk/fRB6NnO8Rl8ha4Eu5k8rbrBWfrT1vRdNUYKv8RKQOhjUXgom1AJXvM0sPAcR9jWg+iLLZcwa+JrWgaVNtX2HRFVEBDoLMO/e3XSlcpZXGi+w2OcjKeYOY8W0RV/ cTwWtVIB E06Wdxha6n4oDVz+rwKsvSfzJ3KCHFQpmxNiCxZuMby14KXPJTNuICGsxBgaD4uRVLRP6VTVp0BzYQ7yqhoErB641SgG4pfX//RwEY7Iuqb3BysFMcLlB9nuIxFXBf6xfjt6akwMDFvDO40B8KroKltUSliv0+3/7A5+8yh/K83ur7N9sIAFw1XjbOQiuxLRu5MM4dp8rp8Ck9cKVZQCLGED3i6Sz1nSGY/Nibuqalm35HUY1E04On72m3K7tm3DwYZqRu/5r//JZnvUl3eHUPKaO17mGvoaTl9dLIKvCHibGABuQy0HSezYTlzaoiIaFWJ8xnqaJ6MsnVmosKzuIcrwOSIO0LqR0mOifcDDJpxMBFwQ6qvMkRVOgM+c3zyIMJzn3MBdzlOrWFjRUQkJLzGhyAYKcGfiTbZlc3kAGBxFdUJYDnAyrx5qmG0Hhld+xpZij9QRPwNgvTcIhkEau10ie8LjUWTU6YkhJn2GMMekRDPA3pNV1Ibf3t7vgkFNymBKuQkVi1vUxATY= 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: List-Subscribe: List-Unsubscribe: Set the a_ops in shmem_symlink before reading a folio from the mapping to prepare for asserting that shmem_get_folio is only called on shmem mappings. Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index f607b0cab7e4e2..1900916aa84d13 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3506,10 +3506,10 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir, inode->i_op = &shmem_short_symlink_operations; } else { inode_nohighmem(inode); + inode->i_mapping->a_ops = &shmem_aops; error = shmem_get_folio(inode, 0, &folio, SGP_WRITE); if (error) goto out_remove_offset; - inode->i_mapping->a_ops = &shmem_aops; inode->i_op = &shmem_symlink_inode_operations; memcpy(folio_address(folio), symname, len); folio_mark_uptodate(folio); From patchwork Mon Jan 29 14:34:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535762 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 BE6AAC47DB3 for ; Mon, 29 Jan 2024 14:35:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A94D6B00A6; Mon, 29 Jan 2024 09:35:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 433506B00A5; Mon, 29 Jan 2024 09:35:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AAF36B00A6; Mon, 29 Jan 2024 09:35:26 -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 140026B00A4 for ; Mon, 29 Jan 2024 09:35:26 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E56461404E3 for ; Mon, 29 Jan 2024 14:35:25 +0000 (UTC) X-FDA: 81732596610.15.72AD525 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf01.hostedemail.com (Postfix) with ESMTP id 3B60740020 for ; Mon, 29 Jan 2024 14:35:23 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="2gCP3F/U"; spf=none (imf01.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538923; a=rsa-sha256; cv=none; b=xgBkjfDS/eDV3lufWETXxCqCxfUB6yoYLhD/SKkcowvQadPz+ExCPL05UoS+5yO953YD5b s+drBydHaRUABu26LYGCU/oIrRYuiCueFznu4FUKEgOgOBkMsQGrMVcpa8H7/3nJf1sKbz Cxrk+9gDSf+Nc0e12+3ktfxsmQ8DCSg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="2gCP3F/U"; spf=none (imf01.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538923; 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=G9kCHf8br8WAlr/5Maj7Cft4763G9D9A1HkLivVroEo=; b=mfuxtol9+OzIUEQKXiFu/4fFF5TX1F+3c5m/8Ibo8OnNf4kEf4if7u9Z2o5QJ5m4hRXjyQ VZS0tcozEl9gd2/2SnBneofW2eCfbULts/ieAW69D8/BT0DaaS/WUa1IppZejsC83nvPXU LBbYy2SkmAZnA9TukDuQw8ghjX28Nlc= 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=G9kCHf8br8WAlr/5Maj7Cft4763G9D9A1HkLivVroEo=; b=2gCP3F/UxeEY7kVyHSDZNlItku 82h0FYfRO55DAH0+pxF5F3y3d6lb/9DgXvfZ3qyaDWnkHG+EkuZcW63H2X3pEK947OLLhr/9bDAKP 2M/LMNDWB0LhTx6pzW8UMEtaLtqlZfG+RvwnJ51Ljo8CW2PX2aKGniubgl/RZ/I+NW8vZ/nzlatSW t4V9D+sOq9cFSN8ZsLtBsv4NRRbiaO+fmBa+FWlsaeyMbkd+vfZ77sAIXlZLf973QMosnPttfXbgd hXlF3SQarWOTss2QtuCs0XtjMpeVssyGxodk9Z5cBp5+0xdcwn+g3dW9s/xOLTTm6fQaDEWnPnweR cnhXQ+TA==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjH-0000000D687-2zyb; Mon, 29 Jan 2024 14:35:20 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 04/20] shmem: move the shmem_mapping assert into shmem_get_folio_gfp Date: Mon, 29 Jan 2024 15:34:46 +0100 Message-Id: <20240129143502.189370-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: rspam08 X-Rspamd-Queue-Id: 3B60740020 X-Stat-Signature: 6dm5u9isgmyodc8i5a48yfb6kury6sau X-Rspam-User: X-HE-Tag: 1706538923-461046 X-HE-Meta: U2FsdGVkX18qh+51nPUWYvkOJXNPfNfK7rmnzyA7x1N081BN/JzGarktlXfvGje/CW7YGiL+Awglyh1ZVXYnfJnylYBNjnWr8HmkX1TMAj/i0zzTfEwMo5w+qMOqK0SFE01Y/y6caD97Z5bd37+u7OJa88bsB1kzA7/QuM8OiRwfMLqG8X08hhHXQ5jm++UdB0T5bcrnZeiOrRYbVZvpuxwJQux3xXgUDHpZ1AJMVvPgLNmmiszS6Cxk2ce6iPuyUASG5mcbA/CL1C9BNPc3qTBWkKHlga2QpfSxj8Obux+ZsilIQ7mZYT7mQnSFneEM0WTCcswoSX8aQnrpDzZP5SqikBf63zjfDN+UDlTKlco9sLU/47tNv+emdDFSsEC13/ZnMOK9T9GsyZfRQ1zmZURqH4KSuiqzy1GnpMQX92AYb1cWuTB7fyTc/G2kCMKkBZrck4t8gR0jEC/lzMrfGcPSzfvs3vQcn3wnLdDPVDADesh9xrQtWZzugwkhTRYHGlxYx4FibTP/0lhe0o5UFCauLMNgg4bao7AAmsXK10UyBmUcGCvXN5+BG3zw+RPkeo2jYRp2IeGtJioLEOZwkWOzMo5k9Je/a4U8B+M21JHHbPFHjSQVI1ZEzza+4CQc1PmL/rseBZNbWeHIbNRTtT9IAzSuz5Y+O6BDsAZzS9EpCVOCXhQKBsjAkbk/tvKOzaMHn3FGPUxE80XthNSZr5F/vuiffbRq5cgtcJDpkJlAsztUDT9SKx8he8K4ySSZx7tSFKI9dkvgb+Mds/U0sG61zzAIPWgUdVMUtrCVAh5AVVwZ1PY/W/S/l8Jlx/pZQiWiQfvQky4XbQFqaJTEsmVbfF07aGHkqQ8UwVWeHIdIuWnP8AkJMR2s5DrtqDrgb0KKOXajlJRz3phgBOvNFOVnoTYtKacDgr7Rzdc/a4Zhz1u8vNWsuExMxBwThHXV4b5kN0blNWk9CMA+GZo J9+kB86V 0UaUAbgCSz56oR+vebj0E9tj0mphFvoeQfpG6XKT+VQSJx88s7rrk6zPfynqClzETBMcQswOKga8ub82+K81fkBjL888uI9nz4JcpaLphN31sQkWzrkCQE10WUMKCMD1nH74T4PywKMDnzvL3/c4AvR7cCG45G/JtnSQM/+mdjbBi7kIf07zl0mQ6cHwPd3iwgf33Cd8YaugdssZV5KPIl44J5COmHGAdUg19sYG5PqFThz/hoFygd5M5ReDB01eqnLxnkQ/AOJNxZafaFpwcGVVI8uYjfuxWMna4HRNbq7/V/I0uDZvoEofdq7jYh8BWyLs2qRylWU4zq3FVEuayAEBFMLnfeo2UVEmHzFphE3CorEcybiunx6fcF3093w6J98JIdZZLqDB2NRwUAxrh/fIZmJwpWgBJwoWP3LqVH8TVRYtVOf8hLlIwqjv+09UvIOYYKLX5fY9qW86BiTVDzWR32kmgXytZm+eskPylMHywqAi03Djv6no7AsRE6EmqagzG12ZfKZ245uEkmP18vmGFrqHYi6RRsVnzcMK/2OD8SQyd51+Vp9WJaf4NtJZt34KAct7sp2hUe+U= 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: List-Subscribe: List-Unsubscribe: Move the check that the inode really is a shmemfs one from shmem_read_folio_gfp to shmem_get_folio_gfp given that shmem_get_folio can also be called from outside of shmem.c. Also turn it into a WARN_ON_ONCE and error return instead of BUG_ON to be less severe. Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Darrick J. Wong --- mm/shmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 1900916aa84d13..ad533b2f0721a7 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1972,6 +1972,9 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, int error; bool alloced; + if (WARN_ON_ONCE(!shmem_mapping(inode->i_mapping))) + return -EINVAL; + if (index > (MAX_LFS_FILESIZE >> PAGE_SHIFT)) return -EFBIG; repeat: @@ -4915,7 +4918,6 @@ struct folio *shmem_read_folio_gfp(struct address_space *mapping, struct folio *folio; int error; - BUG_ON(!shmem_mapping(mapping)); error = shmem_get_folio_gfp(inode, index, &folio, SGP_CACHE, gfp, NULL, NULL); if (error) From patchwork Mon Jan 29 14:34:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535763 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 2E315C47DB3 for ; Mon, 29 Jan 2024 14:35:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC4BF6B00A4; Mon, 29 Jan 2024 09:35:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A4C3D6B00A5; Mon, 29 Jan 2024 09:35:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C5706B00A7; Mon, 29 Jan 2024 09:35:29 -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 7262E6B00A4 for ; Mon, 29 Jan 2024 09:35:29 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4FB65C09B6 for ; Mon, 29 Jan 2024 14:35:28 +0000 (UTC) X-FDA: 81732596736.09.64CE016 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf25.hostedemail.com (Postfix) with ESMTP id 6A6A1A001C for ; Mon, 29 Jan 2024 14:35:26 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dm2yohlU; spf=none (imf25.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538926; 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=sbna0CyeYoAgz7SQMNzBd+8sEOvcwkV3+E75n3nY3SM=; b=p0uxiFUI8LfqMjsHfZ9KoyFBceNiNBCYT+i0tYldZ3gijZAbG28LS9+PSCbFVfvvIXnmZf 7ytBoqhfmDUrkx9iQtA1FDP1ZZ+yAbwtAvt26VlLZZnv+UNcgHQBGNrbvZ/ZDJ8Be7eEaT 9fI7a1NqsPJlTd3f2R/8JSxkIRlatXQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538926; a=rsa-sha256; cv=none; b=hfM+oArSNU3nlhhK/aDskLaV3+8gAEKW1HcjRJnuulnKYETZLJX6TNXU9qWTaOsOmo7/WT ja8IGSLWrO+z4ylApQ5mwONLGPQkLUsccQIbfn53POK9EB+LQ49i8OFU52CkTZkJKsGJ+r Di3t2H/goBOCyr0bqGzj8sJbQGK+K8E= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dm2yohlU; spf=none (imf25.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=sbna0CyeYoAgz7SQMNzBd+8sEOvcwkV3+E75n3nY3SM=; b=dm2yohlUA04AgYc6fUHgyd5ApS VtMMvtDqA8FvbyJvysLCIpRSRY+5tRypYODRbJMUkg5khV4Q/nGnnhVRtD6qUkAuCLagjA/jIENrl Zswq/LPZAay+AGzBNV3i1JB3OTqiuljlb+39qmDPrhF5twhzzM2LghfudqIXsIkISWSXFkrmL2WqW JZEL1RXUQLFF0OphQkjfcPn81igW3bBhLA0W+FYUkq3kqb3wNdhbY2PZ7a5viAzLJnd7tMvIoUalI 67M7TWNM979b6PEWzhM6kAf+Vo5QZpybOGg4fQ0CDo7KMKKx1epTdFPHPHRcJXcZ+3p0ask6+uJnB DxZS2doQ==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjL-0000000D69v-0T0M; Mon, 29 Jan 2024 14:35:23 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 05/20] shmem: export shmem_get_folio Date: Mon, 29 Jan 2024 15:34:47 +0100 Message-Id: <20240129143502.189370-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: 6A6A1A001C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: xrb31jx9knfsa5ouyi7neqq77s94co5y X-HE-Tag: 1706538926-851123 X-HE-Meta: U2FsdGVkX1+mryusjWTgUZmbKlTT+Zg4P6ana7gfsgNvi2qqS8aHOAXKtQ2gYloP1+Y7MLqg3OJBzP/GJVih/pRyskLD5+t9ncFfiV7oSFkFVKyKXONGmsrXImUeSwgjhAj1qTNr+ZQAjPHFDibk9zQbtECfSm7LNSTbx6weLX90UheC+YO6aJFm3Nv3jqr46X8HL7PbusHgfpgFRBGfSeLJPSyK2r/z5d5GCvKgQoeFv4HUPug0XLXb9mOjTaFvgL2fR0pU5o5LJqiiB20OjgjO4euKPTj0v+cJcEur28u4DRWcA1NJYPqNp6b1Gv5T0NrUfIaxFc6L9Y0Odq+knbDJk+y5RxrSx96hPlXJ9gmNWvjaJrqeA6qN15Y+5x8NxFGMKFNVG+HnP+1mn5XLxT4Czs60av9wqRS4OfXflMi7F52he6BuN+ZRHBxEFb3Dk+zMNwu49HTB/L4iQHl04sy5hZXc920qw56y/xP/CLVdgDzwlV0zA3JbybY/jom6WKFY/cCoBZ39gEXl6OakIoQLfm0e8csV9YnV+ZY6kYwqHkiIXLohpbQYssSr0l+ewasSTq2346E3xU6qcCBDeCTZtCQQFfxjtAPWrkJCbUb+xaKqmEHIgypGaTTQ0rTaxhookCrXxgS7vRvkBrngJQxic0ileYYiLjOBVwdoPqcK+jV3aYTmMmBxQonS/p0DTsa5xwMqZ/sEGWcvKJwrNNMKI/EJY2oLSCXbUc5GHkCfGGiZw33vejhmx3q/mUA542axQI0pKSIVxYmk+wBF7KWyiFV4NDpkxZL0g1CAzTxEj9ZiRPZa/fmEvyPKf/xUckuhMFhsytsQr1otuLKWMCgGXS/q3/EsT2jwHuvaJDYj+gPv14s3vfqNRzO8iLodrOKTtn0cQU3LklCq6v8QK98kIkOOavDWz0XnKkI0XgSGpHVMSAYjaQsUHesiriqA5LXkdt3VwlZ2Hfy+pBc /m+kQB8G XECa4f3H7F7D8apvERlw2q6jGS1pWdyZXikTXniLPyRC3VHcsfFxn4JBv7KLwdrZNNQ07DSEFfnuzx6BCgBFjO7t7dYh92Unt6ccPBoAhcTJlyrb10B8PODGbhDHbnZxiAI/1nQfvuCh3NukBI+5NRZkCZGOZRCgVqmDTonunttc3WSUyWpGr95v+pQ1UzlSbZ82Wi3gkcIXWKYgguki8qeRlRk0GWwcsgj6jf5uZQzaREz/AH0dP5kspAq8YCDcfhjPD6LwU6OvY6YjPu4iXUDAABwE7qawMMJX1qEg4lRxDWEdzJe4eo1lQIdJkVO9BJZls34N9insTnudT5UAFrd2ehj20w2PvjF/C7qz4X13CVe9YQCszVxqmyuWtoP4BrEe7QKd/LF0YtkNwDuwU/7oiMaQr4rVnzLXPV+VRwmAhMQ/05R3oWqB9NExCVijrugyrwwNLSbo2pmSdJwGe2MLIyq9eCt7fu1nsw9KV50LAvZAddmfDftgZqDBi4PZ2wVvt4u2OlAX/+KprQuI9Wk7kfNgXD42hcw8O4BMn6G2pzdzjCsXXqKlfKyvjHdbAgx0oDYv6mIddHOs= 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: List-Subscribe: List-Unsubscribe: Export shmem_get_folio as a slightly lower-level variant of shmem_read_folio_gfp. This will be useful for XFS xfile use cases that want to pass SGP_NOALLOC or get a locked page, which the thin shmem_read_folio_gfp wrapper can't provide. Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Darrick J. Wong --- mm/shmem.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index ad533b2f0721a7..dae684cd3c99fb 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2137,12 +2137,27 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, return error; } +/** + * shmem_get_folio - find and get a reference to a shmem folio. + * @inode: inode to search + * @index: the page index. + * @foliop: pointer to the found folio if one was found + * @sgp: SGP_* flags to control behavior + * + * Looks up the page cache entry at @inode & @index. + * + * If this function returns a folio, it is returned with an increased refcount. + * + * Return: The found folio, %NULL if SGP_READ or SGP_NOALLOC was passed in @sgp + * and no folio was found at @index, or an ERR_PTR() otherwise. + */ int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, enum sgp_type sgp) { return shmem_get_folio_gfp(inode, index, foliop, sgp, mapping_gfp_mask(inode->i_mapping), NULL, NULL); } +EXPORT_SYMBOL_GPL(shmem_get_folio); /* * This is like autoremove_wake_function, but it removes the wait queue From patchwork Mon Jan 29 14:34:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535764 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 201C9C47DB3 for ; Mon, 29 Jan 2024 14:35:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAB426B00A5; Mon, 29 Jan 2024 09:35:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D32E16B00A7; Mon, 29 Jan 2024 09:35:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAD916B00A8; Mon, 29 Jan 2024 09:35:31 -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 A1E506B00A5 for ; Mon, 29 Jan 2024 09:35:31 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7AAA716030C for ; Mon, 29 Jan 2024 14:35:31 +0000 (UTC) X-FDA: 81732596862.10.5666A1B Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf10.hostedemail.com (Postfix) with ESMTP id EA83BC0016 for ; Mon, 29 Jan 2024 14:35:29 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=OS98c4u6; dmarc=none; spf=none (imf10.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538930; a=rsa-sha256; cv=none; b=aJeCgPuQgz8+O+AGPTfFpRH5NQEaRnDlW/3yAkzIdipyukzEdcGv77aRHaPSAL0F1AL3s1 5UyOTMzXM7QbZD/bDPQkFU5Vdqls9U35OvJZCrw1esYCWomJZG6ENccKhAGxFUeEdGf/2d 9vdr/OyNawFnSDzgHBA39tCGppF+BTU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=OS98c4u6; dmarc=none; spf=none (imf10.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538930; 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=Mb0aKytFq1BGb2HbWrZKS2O+ruK+bI9H1a6C537e2bg=; b=CRWlRDodT3pFG0SVKxBrmx6w9t9YvaphCRYa/4qT7stGD7r1yQjUppFZ5vJJZ+EtrNIrwX qkied4XbojsfC9oVHQXd8WXiUkKnsZGyDoabLcd5NDtHkqukGH97Z3Wnyjv/XGif7iPrH8 9TH1SDvyK57VKBwWgpPKNzocTG/YSbo= 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=Mb0aKytFq1BGb2HbWrZKS2O+ruK+bI9H1a6C537e2bg=; b=OS98c4u60FTr62PDOGi7enyjZK xFXKPLlrimdvB2Iu4fpeltNoMQ2ZC9g1x7jRTBgyNUqupRnsfGawClI8K//Q7U7ki+gOEzcMmXDZx KmLXLMElm44yX2DCrBeGpGjgabWiVCJJ34xQRVUsk6fbAz/7Lw+9NyUjPnXjSW1Dd02/E9HEl9Zr8 MVC31vAdt7xB8N1LsrPdhlQ4fHaYflH5XPOKBVmhmtS//lHZcq+dEyH71ytQQHzBWZ95vRGQRq7Sj 5pgCMxOInG3gOFVxzhTJ1rjkjWmRPxKvuOLpEFut7zP5598KykeJFd/DiWTCGAsBAQ8FVHn+4zvI0 txVJ7Z7A==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjO-0000000D6Bk-3Mce; Mon, 29 Jan 2024 14:35:27 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 06/20] shmem: export shmem_kernel_file_setup Date: Mon, 29 Jan 2024 15:34:48 +0100 Message-Id: <20240129143502.189370-7-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: rspam06 X-Rspamd-Queue-Id: EA83BC0016 X-Stat-Signature: k84jfzaqem8pnhdbduigjwtq4wwka3ma X-HE-Tag: 1706538929-492221 X-HE-Meta: U2FsdGVkX18Ze2Gr7s0d4UGvTnYiXFRqMpnwTD792eYlq7hOmr1LYFbAufzMMA31/d/WInqwyuw/5P79AwZCy2L6vxJLUC+eNyOG00p5BawP29mc5KbrFFf5kyiUJb7+bpC5Igt2OCJHK/NQ23WXLgSyiHZwf21ux2gL6qz6eBt2ZQHW/Fp22Rx9+eEZTdFwxtGecDvdaASIyPfOhfIR45hmS5mwyOUQJsrsMsjRwrko/f/G6Dt8BgRQ9RqIoQyM88/i+hxOvnSPuYDqe7qfY+SDH9co0dw0gTX5oDDq8cYhaxM5WYpLODCCFwQsiyELa5kQftKPzep1ZYFkSDQYPi8tes1wSKYL2BhhbcNYTMNhCrQem4a81VwkpGoLI6zVEEFyRMumLPyOeEtQD57lgDUYmaOUWFf7hbMS8QslaQ4Jqs1hJWZGWB8gwIrfMKh62t7sYBLdHLvaIM7c0W/bPCeMW48KIpLqw04S/jBsHDX6JThJzmdaYfYi5CRxNcBi739tlaLNwf0xD7QE124irveN+eoEDJ1upQ8Wh2BfBxl1BMGtYOx48EfEyMkVPLVCSXc1g3rT/cOV3ZLBPuNEVCnX6ls/I0BbkoXDLlKV4bCOiO1CXH8u0h023ofnFhyuxVdEE/p2KTNZoZDwlZyoGA4HTh0BrBfyvw7NOlabuONqv4Nlc3TWtsj0v8543ir3gMoovIUL3pL4qQw3ZhCl6jco3lYFNknsvjd9co1JWwGkJGL04jNkry499fYtlVbc05ZHATL+IpycZh8Dtw002Wq4ij4woWbemSvQw0FPhX2RcBgg6uCxiHX3pJSvL/5cGgg5TaB9NtDVBJ+9E5tMcdJcGyTnfNz4wuBc2VZRj9g0bGmTqPZk3kmu3VUtqlkXr+xhUTI97Ft/uEPfEfTIg72A9qFxv4A26S34XBhILmBsVgNOgJjtHaozp9DID6LGILqzvwF+TCbviIUHByn /J5D+91P 2GJFcMBkVdh1Jj2e8LFpa7V4xpy3K05bVzbRQ9Xkl0TlvYKGiGI2ZwKCk2aTxcX/WF78NJ7nzeXP/2tazNty1VeRNhTaojlg2j2RjmuVQGPevqyQWXo6UXBt2qFBfCi0XXc5FW++xVuRbae2WjUXCeGYrNeewG1fVtQl2TxuDajPAKHdaYsAr8GZ4AxTRvi/ptVFOvZ3bPXS0Uo0TSSX2bA66Cw== 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: List-Subscribe: List-Unsubscribe: XFS wants to use this for it's internal in-memory data structures and currently duplicates the functionality. Export shmem_kernel_file_setup to allow XFS to switch over to using the proper kernel API. Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Darrick J. Wong --- mm/shmem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/shmem.c b/mm/shmem.c index dae684cd3c99fb..e89fb5eccb0c0a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4856,6 +4856,7 @@ struct file *shmem_kernel_file_setup(const char *name, loff_t size, unsigned lon { return __shmem_file_setup(shm_mnt, name, size, flags, S_PRIVATE); } +EXPORT_SYMBOL_GPL(shmem_kernel_file_setup); /** * shmem_file_setup - get an unlinked file living in tmpfs From patchwork Mon Jan 29 14:34:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535765 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 35D7EC47DDB for ; Mon, 29 Jan 2024 14:35:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A3426B00A7; Mon, 29 Jan 2024 09:35:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B4A46B00A8; Mon, 29 Jan 2024 09:35:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B84A6B00AA; Mon, 29 Jan 2024 09:35:35 -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 39D5A6B00A7 for ; Mon, 29 Jan 2024 09:35:35 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1F9B140A48 for ; Mon, 29 Jan 2024 14:35:35 +0000 (UTC) X-FDA: 81732597030.08.4ED6CD6 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP id 51D6916001F for ; Mon, 29 Jan 2024 14:35:33 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="NAc8SZQ/"; spf=none (imf08.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538933; 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=5+G//0oCp4joBCMNmSMB9VbToHmHFLOf7sf0e46phAg=; b=3IPU3mdtxh0neT3CcKkICCWbXgloLa8P71wD5Vk2ujtQ0vaGYcIMAX5XIgDcvO2uko41MO 0gipjFiAW6agZDRiFTglGciNgcRlS2BBd8kit/8mTK//9HYKyGmx3uxQFIkv90Soq4qiod UxFPcRokBds1UJ7kfwDH3wuCaGIjrFY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538933; a=rsa-sha256; cv=none; b=XEM5daIKV0EYl6b3FvxPgaTaTIbkmCHFTV8r1wwVz3EtHtaSIhsrkH3NxS0P5XPPRfy5D3 ia3gYeKwASo1n00FKRcdKKPNjwVRMH+UFc1HmGrYGt0PD/W7Q/uFFtA6Xj3QnTGZKuSD/q CWlDiltmg5OZfABHoPZw1EwvxheVMF0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="NAc8SZQ/"; spf=none (imf08.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=5+G//0oCp4joBCMNmSMB9VbToHmHFLOf7sf0e46phAg=; b=NAc8SZQ/n7VJjolfOO3ePhisGj W70pOrthIiUlTiGlJCc2choYOwhhXwIshN0f7q4Z4noncpkTT00521IukXLRtVMT6myqdaAOTkG4d 10CzhEmZfzz6BSkWaZEoMpd7QtKZ4zNHLWiwHygIzzTj455ggTnkJVLHSyopIoiEzUYwm+ozPYih0 1Gy3I5e0OYzhajFy+sG7wgnZ48jemInmyzfozXbJYILhbxo3dQUz0gSwrqflOPt7ez6HoC/AhekC9 KHM8nm/Zs4nAGzT+dIAZumEbinj3Okbq0UKD2t2BWIxHhzQR4S/8ZfJsSREftO0p+Ou3ZVmdVwJse r9wxbILA==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjS-0000000D6D0-2Gci; Mon, 29 Jan 2024 14:35:31 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 07/20] shmem: document how to "persist" data when using shmem_*file_setup Date: Mon, 29 Jan 2024 15:34:49 +0100 Message-Id: <20240129143502.189370-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: 51D6916001F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ksbywq9163gue1xukcp5osuktngqta75 X-HE-Tag: 1706538933-885704 X-HE-Meta: U2FsdGVkX19Y/NkaSGkJH851e3/WkMGU3vwoWUMblXRcdp7hmEKxokwBumNLD9vbya1/KRWVt/fOcR38TxCy2JRyONxYjhu3xWhwdcl2DPezgnOmyqXYsuv7an6twQ8ybRveAh2YeJ2C+9Nedf467nu9jc05NFe1jrT1LCW2t4IYNdsoGFleTohiR/fNNvSo50k3r0Dz6lXjot5K7Nog4J0v5VVhfisQSeark2JSImIj+oKxuySUGdzwMZjVzU7DNoCNVeJp17baYL4TX+Kwrfu4flK9koEyZReNdv3YPRrgST0XMMAK8xsLY1NGMbKH6X0EOaJFPrxsG19Og3XlgJf3P5CDR4bJkYhLXU25e+LPFWIpm5raQZpU56Xb+eM2iK1kIOiHBRNuhhmyAttSeik9C+9568uLAd+xpMMoNLVEiKb1pbEah46DGwG9AxfYIL4LR39mNtsWRfCsFqueZGZVTFLvi7R52RnnFTNU0nG9QIkJZGujK83PjUJYbibernSzin2iii8QqIbVMMTFNKS+A6SSsskmdSZ807TcKf2J5IENW8ShUELIJg6F5JxvV6yUuDdmjqFK1K/8Zj2fX3ahJ6BKne1ihPk4CGuxIHNVZWwKFjkY2y0jovjM1crEmGTU6AGa+vju+vcUy6S9LzMOaxjrBuDPX6RIxTjP8xYgGYJEyZ+sS1RH3qs4o1rUdgjKh+KOVB6xDg5AuRd3O3uevQuT/GNaJ9r3mYesYx+8EAR9NaFGq/0EkfO2qt8FsqQqbPQYrGTV2IoTnlNaO0BAP3sqzRw8Ok88qeouhZaK7kfnzmAGLKQozuZ5juoR4S8CcsNWEMdJN0tULo9c+dgv4aCt4Et8mvhNSN47FdZ8BtjwYI98mc5jmn7aLk+OpmU2yFy08a6JXTj6qAFQg79MUV2rf4U5BYVzbnkA6Ko1tu6FQfOjdwb4ZewiwdEY7CNh+auKLhzrZaphfO5 LRod+4xE tKdLMpd9YSm0ypQCQCNW/1Qfzw+Nt1fWjYMX4TNCqQfFp6OyZqALTGXzotdboHjglIOPJTkEtNpFv0qE3F126tDWO/syCBoJEGx2T9M4eJjmEVT6YMrfGPoh+YVFYykFbjbSqIrb8QxPQFgnR13ecy87XP6gENr6ZMr8EQCE+r0sIB3OmIYFV3/c7c8FlRobCsn6ACUp/15NMHcyfi4d1awGhXbznFjKp9cvdbYwTax7Q0kCqub8tSHZ6NAF49j5W1sMG4JhUAKXNg+NBuJRpO0OOXaJUvh7Oxe+p/Gv9FpnoqYvHdHt4Djm44hmuJ+3LthNf9m1HuCRRAJiGZUUQHfH7GHN3bdKg046CWXUF7VH5F+nmzYOvWAxE/BiK+vn7NUhgl31K6RcGXSni4TWqVUnNRQWvogcZK0wu7+rBiYbVStQN1f9L7wt/q+qen8ri1T+Ksmg8BrO/SAbP1HyFoqYuDdzR2121ir7XsEm40L3Rw8UjafPkLGwuOG+wc2sxoVyHZJq4Iz1mwxM= 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: List-Subscribe: List-Unsubscribe: Add a blurb that simply dirtying the folio will persist data for in-kernel shmem files. This is what most of the callers already do. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Matthew Wilcox (Oracle) --- mm/shmem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index e89fb5eccb0c0a..f73dead491b11d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2148,6 +2148,10 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, * * If this function returns a folio, it is returned with an increased refcount. * + * If the caller modifies data in the folio, it must call folio_mark_dirty() + * before unlocking the folio to ensure that the folio is not reclaimed. + * These is no need to reserve space before calling folio_mark_dirty(). + * * Return: The found folio, %NULL if SGP_READ or SGP_NOALLOC was passed in @sgp * and no folio was found at @index, or an ERR_PTR() otherwise. */ From patchwork Mon Jan 29 14:34:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535766 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 DC54FC47DB3 for ; Mon, 29 Jan 2024 14:35:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 719286B00A8; Mon, 29 Jan 2024 09:35:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A3326B00AA; Mon, 29 Jan 2024 09:35:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5436B6B00AB; Mon, 29 Jan 2024 09:35:39 -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 3F17B6B00A8 for ; Mon, 29 Jan 2024 09:35:39 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 08D0F140993 for ; Mon, 29 Jan 2024 14:35:39 +0000 (UTC) X-FDA: 81732597198.26.74B0563 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf14.hostedemail.com (Postfix) with ESMTP id 5D945100027 for ; Mon, 29 Jan 2024 14:35:37 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=L2PzvqZt; dmarc=none; spf=none (imf14.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538937; 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=pWiZ+uq6s6Jb8DG5zpX+nOBm/9LHv3+s4Lx1umDyLlU=; b=AbV6T05elPiI9P77gGIvEILbU31ZJa7Ayjv3jjJGnWyEafGNzRx3ewePU9RTXvxIYyBiCd q0ePd+qt3ajNH3Ep2jMUCLXmoPdbo2gHmvjilKWvbxhzTe43BR367o9otoArZleVVf9Yi0 7334LiTiccDBqdhTaBgsV+WnPlUFTak= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=L2PzvqZt; dmarc=none; spf=none (imf14.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538937; a=rsa-sha256; cv=none; b=1THLyfF6N2l+hIn4axvFHTAH0UsxaMqJ2HYuzLNAfn4513bDkR2Mhy9tHWK7o8etcAJ9/w 13o80Q1WP+nY+nOckpd0LIHC6ieNoDAnU4knVHG0Ro///eXBdqlfXafk8/UwnUgTBfUWQt A5tDmaddkTaL2vOedFhd9alHEohpDdo= 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=pWiZ+uq6s6Jb8DG5zpX+nOBm/9LHv3+s4Lx1umDyLlU=; b=L2PzvqZtdHLlDmsn1Il9cy+nDe 33Z/k4DnFusZdlkgk7o1WMaM+JjhkvPjuHjksPmkaszuM/qr0hY3b6K6jcdh435GnWDDEBoXm1DJz 3Z069uj1FWEicDamc9lxzxxkIvpZfax4bKr5J/CXRDsqVaxhgSaEPHrtcJue0yAeXDqJ3i+KQ3Z9O ihyotPV1PqEO6aWU/fHDNXNAf1dwKRm7TDan9E3DNZNPwtZrV0prrLZdm36MWkqFToeZgVaquorRk YOvKfYr9Q8Cspp9CyaXy6ts2+IjLpQqLYLzo0IYdVCXTiepTXSn8vgtpstmPD3YFT1pKoKnFUv6FV DV8DQaOw==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjW-0000000D6EG-0AtQ; Mon, 29 Jan 2024 14:35:34 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 08/20] xfs: remove xfile_stat Date: Mon, 29 Jan 2024 15:34:50 +0100 Message-Id: <20240129143502.189370-9-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: rspam09 X-Rspamd-Queue-Id: 5D945100027 X-Stat-Signature: nngtaw5h7sgjb9rmj78rgcfj6mjwba4s X-Rspam-User: X-HE-Tag: 1706538937-603781 X-HE-Meta: U2FsdGVkX19RxAmevF3rl69kRex5f7qz8RcqpAnEyEXWl1ZRq6SLvBNvOL/xhfX5R7G/C5hhGWxH/mnIpoxv0MXgVWVCowjpu0bkim/C3Yx6gvAXmunVqMX0xx/AOr6C3UeUF88DzCaXS8uQTkn+JJKod6P2+E0ThoV0wbkSqOU77ZbucV84d56YE3WPrTCEoSKiw0po+NLqCryfUWlJoAd96BLDIMEPBZrbchR4Gl+c8oBzRwhMzjD1TKnUKGDZ7iL3Xu3FM8ydZ0xN2XcBayi2YPTrDNbKIYN+So49GrL0xkiDJ1edbwiX9NHlxmxvaga1iXAm/euwMj2MyGw7bS3lhu050pB2Vm2rsRhwIOwZkqE3992pMJ7SauRhTghs+3Rjt9bYgqyGF12WucZ3gFtRrtOy30f/EmV4pgmg/ud2Lx+ITxhXNFNSgwibFJmcOKYEhWqSRw8c0LX7wSDR1LH/ZewzV5pory0BeLxQhQkgkTUxjZ15Y5CihgFM+0Jth9v6SOL09RoQGpZ/PZ9BJAfwqjPtpriodLAwH2dqAEmTiFFyKrVKbeB7nc7yu/EbauWUsUMXu/02LY8Ow3O1MEpaDVd1B2aZ3i024BkvOpRVRSlCSACLWaJ9MxyL9N/bbyzX4eVHaCZ/KZp9DLACjQp1TpHFCX9cJWrakT8p7yllVEJPqyemDeGYuf57YrRHXkv56emlzm6jGlDgZ57tms2mpD02tQyOnqwrP+XKZm2Ksk7Z6T4MAiUif+wDQf9NIzDTZr17DHO4PmvWONVqEzjirr7E+NaJI45uHJ0gaTNm2/Afk3lDMhYWRiajiDFqP0ss9iXdiMEBwQcDQ95GixSFjhvdutPTaPjLTZIJlJ93GT8QWvdNy5HWEoRdDOKgUQtI6i8o1++9aZP7wd6xpM++vhVuVZNzDGFDizONSn81HPHAblNfRmKutwv+MjDRSawWcrLZAjPRlbIY8Wz 0BhvfDVZ bBT59SY4R+OPcIdjnAhLnH72h+MYQQHRR9y+FrQDyUW51c5tRFgN1yvl8USFzUzlKIYC1DMuQSTJ8OCYFfq6amstU8w/rl6+BwTwYrwNJ5kBGHsrndfYfqMEQx9BSnwnj48JjUJRFToXtiT5D72Qg8Cu+f8ZQJkf1KVpPjyGsycwPcHfj2Ge/Q0M7yL9QuznwTXxurITMqgHDuwR999FJfC1TkugDOvhnnkA4M8OP+UT3EtNzDIgyZK2zyQ/igwJsQEauU7A8vvdiJXlNhWzRNwSznGLs5wfsLMT90QcNZB8pedHeBOn3hCnRHgKP0I124cappHw1FrxCVGnmv0aT3SG1ku0hz+q9L08zncTrK1xoUSLjJUlEW/DczcD9o/G4Tdqv0MfDlwlA4OyM3aN4H0uj0iYJq4h/6jPQHUFoW93D4GpkpnLniO4BqQ3jfHFJhmvXcpTCTvJycxWAEObWJsbTxZ9WzZaGdqieqqij0zHZFkEx4xb5L1u1S+ERNfb92VbQvCwWlt+taMI= 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: List-Subscribe: List-Unsubscribe: vfs_getattr is needed to query inode attributes for unknown underlying file systems. But shmemfs is well known for users of shmem_file_setup and shmem_read_mapping_page_gfp that rely on it not needing specific inode revalidation and having a normal mapping. Remove the detour through the getattr method and an extra wrapper, and just read the inode size and i_bytes directly in the scrub tracing code. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/trace.h | 34 ++++++++++------------------------ fs/xfs/scrub/xfile.c | 19 ------------------- fs/xfs/scrub/xfile.h | 7 ------- 3 files changed, 10 insertions(+), 50 deletions(-) diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index 6bbb4e8639dca6..260b8fe0a80296 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -861,18 +861,11 @@ TRACE_EVENT(xfile_destroy, __field(loff_t, size) ), TP_fast_assign( - struct xfile_stat statbuf; - int ret; - - ret = xfile_stat(xf, &statbuf); - if (!ret) { - __entry->bytes = statbuf.bytes; - __entry->size = statbuf.size; - } else { - __entry->bytes = -1; - __entry->size = -1; - } - __entry->ino = file_inode(xf->file)->i_ino; + struct inode *inode = file_inode(xf->file); + + __entry->ino = inode->i_ino; + __entry->bytes = inode->i_blocks << SECTOR_SHIFT; + __entry->size = i_size_read(inode); ), TP_printk("xfino 0x%lx mem_bytes 0x%llx isize 0x%llx", __entry->ino, @@ -891,19 +884,12 @@ DECLARE_EVENT_CLASS(xfile_class, __field(unsigned long long, bytecount) ), TP_fast_assign( - struct xfile_stat statbuf; - int ret; - - ret = xfile_stat(xf, &statbuf); - if (!ret) { - __entry->bytes_used = statbuf.bytes; - __entry->size = statbuf.size; - } else { - __entry->bytes_used = -1; - __entry->size = -1; - } - __entry->ino = file_inode(xf->file)->i_ino; + struct inode *inode = file_inode(xf->file); + + __entry->ino = inode->i_ino; + __entry->bytes_used = inode->i_blocks << SECTOR_SHIFT; __entry->pos = pos; + __entry->size = i_size_read(inode); __entry->bytecount = bytecount; ), TP_printk("xfino 0x%lx mem_bytes 0x%llx pos 0x%llx bytecount 0x%llx isize 0x%llx", diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 090c3ead43fdf1..87654cdd5ac6f9 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -291,25 +291,6 @@ xfile_seek_data( return ret; } -/* Query stat information for an xfile. */ -int -xfile_stat( - struct xfile *xf, - struct xfile_stat *statbuf) -{ - struct kstat ks; - int error; - - error = vfs_getattr_nosec(&xf->file->f_path, &ks, - STATX_SIZE | STATX_BLOCKS, AT_STATX_DONT_SYNC); - if (error) - return error; - - statbuf->size = ks.size; - statbuf->bytes = ks.blocks << SECTOR_SHIFT; - return 0; -} - /* * Grab the (locked) page for a memory object. The object cannot span a page * boundary. Returns 0 (and a locked page) if successful, -ENOTBLK if we diff --git a/fs/xfs/scrub/xfile.h b/fs/xfs/scrub/xfile.h index d56643b0f429e1..c602d11560d8ee 100644 --- a/fs/xfs/scrub/xfile.h +++ b/fs/xfs/scrub/xfile.h @@ -63,13 +63,6 @@ xfile_obj_store(struct xfile *xf, const void *buf, size_t count, loff_t pos) loff_t xfile_seek_data(struct xfile *xf, loff_t pos); -struct xfile_stat { - loff_t size; - unsigned long long bytes; -}; - -int xfile_stat(struct xfile *xf, struct xfile_stat *statbuf); - int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len, struct xfile_page *xbuf); int xfile_put_page(struct xfile *xf, struct xfile_page *xbuf); From patchwork Mon Jan 29 14:34:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535767 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 A348BC47DB3 for ; Mon, 29 Jan 2024 14:35:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C09C6B00AA; Mon, 29 Jan 2024 09:35:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 321C56B00AB; Mon, 29 Jan 2024 09:35:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 199D26B00AC; Mon, 29 Jan 2024 09:35:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 02F996B00AA for ; Mon, 29 Jan 2024 09:35:43 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C77F51C0940 for ; Mon, 29 Jan 2024 14:35:42 +0000 (UTC) X-FDA: 81732597324.17.FED5CE4 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf12.hostedemail.com (Postfix) with ESMTP id 1356E40010 for ; Mon, 29 Jan 2024 14:35:40 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=kj9jwzgH; spf=none (imf12.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538941; a=rsa-sha256; cv=none; b=duc48BXOm/Op9DO5UWlgvPutBvEXEA/26Y52fLWq5yOkMXWoX2BQkhGCBaz2lVB3hSU9pa 9jply33xyfDOQWp+DtTGK88ozEq71wy7KIdv12qC3pR3LdDAHadcawaAF6y5rIavnta5ff zVzL5RqGH+10/bPrr8ZQEt0H3T9afbI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=kj9jwzgH; spf=none (imf12.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538941; 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=UlrBswDRelEXcgNVOaWvSi/EUS+jJGBmCPE4n+9PxvU=; b=6Zbtrt87tazVCv1BKeBS1vTujyIUYgZ6iWgEwcxtuLogAAaNOHcAup8OIcIfSgvX7mYHu5 6RZTQ4kecl7ZtV7xvI9C5Cm6WK8q514UsgcsY0UL1rHCPLRhjmrEZT51U2I0AGWTUi09vT m8uPisUPw2eI+la450t0rGK43Ydywzc= 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=UlrBswDRelEXcgNVOaWvSi/EUS+jJGBmCPE4n+9PxvU=; b=kj9jwzgH1z5ubr1AKZwgByeVZE 1MJdXgQc+Z1jipsrPKvENHUkhLNswtsHRbMvdEjgBgdsyj6kFGcATJ+0Ut4CeZSiBq2moNq9RvjJ9 XHdgnlhYeuphXSTOOoWyigtHMgl+zpptq2gwMJsssrp07nlMbqVAPeVE08ULq8s8qvsS+5bMdkDst WK2283IsgCT01lZRMZMrCtVEQa1yIQU9RbVwSB4SedBRXyeGkpjHFvhQcst/oObBCqbM1jqeaO9Sm k/qwjh3L8CnnUgW16ac7jG1r/3EV7AjcxKPMzapb4uskp7l5Y9iCjcU8hGxY5lndaJdZdxIBBIapA LT0WHEPQ==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjZ-0000000D6Fi-2zlr; Mon, 29 Jan 2024 14:35:38 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 09/20] xfs: remove the xfile_pread/pwrite APIs Date: Mon, 29 Jan 2024 15:34:51 +0100 Message-Id: <20240129143502.189370-10-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: rspam08 X-Rspamd-Queue-Id: 1356E40010 X-Stat-Signature: jenoc3fq9z1eo49yr4oo3tq6guzgtzn7 X-Rspam-User: X-HE-Tag: 1706538940-948592 X-HE-Meta: U2FsdGVkX1/sppUykVG3jrnExhQHJ6ElwyiIAQlPRDs1UDTqcyVcSMZ9Aw9/mU6E4Td8+TJbth75SH9ozTPYwGxgvzZ7axlYn5/p1qlnvZuPyGfgGzi4LVML0Vn7RY6MW+1F37q2fqyF0m7llXAV+OO2hRZWRTbIaH2KlnF8V/UPomCIE6rccuRsJvcUVdG479zXff/8e78mqjNlQqC47TZmLZ5bd1S1Br2gDj1hXBsWSVlFfNZ821jJtkQ5Dg8bzGfa6Z9KICzw7jiNg35LEqoUJReC7AhNxOHOMKSKHkk8HTSbHFnvB+/D6KKjjUNtbf7M/ZpZsYbXZ00S+5Cy+EEgxfRGBpmUsC6jgwNfJb8P4+fxJrYZmKJt66Zcg4CYQ3c3oNiIOHT+WqSIFIge47w077lu0tYDz/KeaLQLtTV2VYQ/iW9DXNkNJ/1Tqx2DdawuFI906B/hVcx6dQTj8h4mGCAs2pimXLkxADCPJWGhcVS0oyEqLtf7EWi4zD8lzsEl2Bbswxg0dV2gX/N/XEatz114ITT9OfYTreakODJRbmQSpubv1/ztIKcnYUEJqd8B8wXB/5l4dU/y9aaxa2U4fZ6I709xEIOI32NRKMMHgtWEp60fTr1+gkEB7zIPl/Ddj7V6B/OBg7iAhgmLUzr6UUI+RgHfT+VJNnqI9KA1GYMaYiGffp99LuHl5YSVgy5rTVN5ixls5SVferkEOr6pyyGFB0rUPGBqdb8RZyd/5J4AT4XaqDy0xbRDriCCASlT+5GsL27oslZca0zK2ljJbI4U2oZN3gok8D95XtACnDEZUiab34MPT+HIijp+YIBj0LNJzyVSzsv38Qv4be4m/QV1vRn/NXwlwzUWXfoylo7MExJkl/nCUUpftXNNThoW9Mxy/QAHeS/h4tAIoWtTz5B8FbI7wl5QjjWn4J+fom54pt1ZCjVqXHosIpUG2YSQRWBDdjRHy/aNY4G knXGVuJJ 3Bg/TDUbf9CMdL7z2U1TAw388GcMKfTEn/dZQk1ucBlsQOTHmlX9ZASEJgljTvwVN9loYFjDGp6B6wHYu5WERTBXm8FxJXZZYkoOtxhOc8S6iJgvjGv85LYa7q/dj0x9eX0M5ZSINljA7jfqoc1T5y1C3E7TQHjLpbYoUFdD4OgL5Y9TyjItxny9nfXrIUUqrY/hWgyvxtZm91a6sWR22ZcXvy99sstujbCVssoY4xpN5nNKhVrA77G6xwt97Dd/wjS/7Ih1iHFA4OcByvdFgDYqkm+P6t9NFhuVaTnfduiuAzzLUieC5eOmdjpcD4wt6zIXvhQO7jphvHwjIxq8QcDT/txyEewkJVtaR48ai4ymO8mCb4GkNfykcz9HsnH2/0MmhBfjunmt2VaKCiM1dMtAHLKfYwupQZxVZ+LxUShG+UiyVZP1R1FwXwkf6MyfaXFPKqAPEbd5xc+RvXHpvW8YnsVkSDHD/OWylxSIWF2J0RLDz6y+f40ZpHEFqTwVayx1U8St8vno0mok= 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: List-Subscribe: List-Unsubscribe: All current and pending xfile users use the xfile_obj_load and xfile_obj_store API, so make those the actual implementation. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- .../xfs/xfs-online-fsck-design.rst | 23 +++----- fs/xfs/scrub/rtsummary.c | 6 +-- fs/xfs/scrub/trace.h | 4 +- fs/xfs/scrub/xfarray.c | 18 +++---- fs/xfs/scrub/xfile.c | 54 +++++++++---------- fs/xfs/scrub/xfile.h | 32 +---------- 6 files changed, 48 insertions(+), 89 deletions(-) diff --git a/Documentation/filesystems/xfs/xfs-online-fsck-design.rst b/Documentation/filesystems/xfs/xfs-online-fsck-design.rst index 352516feef6ffe..216c99ce511f7c 100644 --- a/Documentation/filesystems/xfs/xfs-online-fsck-design.rst +++ b/Documentation/filesystems/xfs/xfs-online-fsck-design.rst @@ -1915,19 +1915,13 @@ four of those five higher level data structures. The fifth use case is discussed in the :ref:`realtime summary ` case study. -The most general storage interface supported by the xfile enables the reading -and writing of arbitrary quantities of data at arbitrary offsets in the xfile. -This capability is provided by ``xfile_pread`` and ``xfile_pwrite`` functions, -which behave similarly to their userspace counterparts. XFS is very record-based, which suggests that the ability to load and store complete records is important. -To support these cases, a pair of ``xfile_obj_load`` and ``xfile_obj_store`` -functions are provided to read and persist objects into an xfile. -They are internally the same as pread and pwrite, except that they treat any -error as an out of memory error. -For online repair, squashing error conditions in this manner is an acceptable -behavior because the only reaction is to abort the operation back to userspace. -All five xfile usecases can be serviced by these four functions. +To support these cases, a pair of ``xfile_load`` and ``xfile_store`` +functions are provided to read and persist objects into an xfile that treat any +error as an out of memory error. For online repair, squashing error conditions +in this manner is an acceptable behavior because the only reaction is to abort +the operation back to userspace. However, no discussion of file access idioms is complete without answering the question, "But what about mmap?" @@ -1939,10 +1933,9 @@ tmpfs can only push a pagecache folio to the swap cache if the folio is neither pinned nor locked, which means the xfile must not pin too many folios. Short term direct access to xfile contents is done by locking the pagecache -folio and mapping it into kernel address space. -Programmatic access (e.g. pread and pwrite) uses this mechanism. -Folio locks are not supposed to be held for long periods of time, so long -term direct access to xfile contents is done by bumping the folio refcount, +folio and mapping it into kernel address space. Object load and store uses this +mechanism. Folio locks are not supposed to be held for long periods of time, so +long term direct access to xfile contents is done by bumping the folio refcount, mapping it into kernel address space, and dropping the folio lock. These long term users *must* be responsive to memory reclaim by hooking into the shrinker infrastructure to know when to release folios. diff --git a/fs/xfs/scrub/rtsummary.c b/fs/xfs/scrub/rtsummary.c index fabd0ed9dfa676..30b5a3952513f8 100644 --- a/fs/xfs/scrub/rtsummary.c +++ b/fs/xfs/scrub/rtsummary.c @@ -118,7 +118,7 @@ xfsum_load( xfs_rtsumoff_t sumoff, union xfs_suminfo_raw *rawinfo) { - return xfile_obj_load(sc->xfile, rawinfo, + return xfile_load(sc->xfile, rawinfo, sizeof(union xfs_suminfo_raw), sumoff << XFS_WORDLOG); } @@ -129,7 +129,7 @@ xfsum_store( xfs_rtsumoff_t sumoff, const union xfs_suminfo_raw rawinfo) { - return xfile_obj_store(sc->xfile, &rawinfo, + return xfile_store(sc->xfile, &rawinfo, sizeof(union xfs_suminfo_raw), sumoff << XFS_WORDLOG); } @@ -141,7 +141,7 @@ xfsum_copyout( union xfs_suminfo_raw *rawinfo, unsigned int nr_words) { - return xfile_obj_load(sc->xfile, rawinfo, nr_words << XFS_WORDLOG, + return xfile_load(sc->xfile, rawinfo, nr_words << XFS_WORDLOG, sumoff << XFS_WORDLOG); } diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index 260b8fe0a80296..0327cab606b070 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -903,8 +903,8 @@ DECLARE_EVENT_CLASS(xfile_class, DEFINE_EVENT(xfile_class, name, \ TP_PROTO(struct xfile *xf, loff_t pos, unsigned long long bytecount), \ TP_ARGS(xf, pos, bytecount)) -DEFINE_XFILE_EVENT(xfile_pread); -DEFINE_XFILE_EVENT(xfile_pwrite); +DEFINE_XFILE_EVENT(xfile_load); +DEFINE_XFILE_EVENT(xfile_store); DEFINE_XFILE_EVENT(xfile_seek_data); DEFINE_XFILE_EVENT(xfile_get_page); DEFINE_XFILE_EVENT(xfile_put_page); diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index f0f532c10a5acc..95ac14bceeadd6 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -136,7 +136,7 @@ xfarray_load( if (idx >= array->nr) return -ENODATA; - return xfile_obj_load(array->xfile, ptr, array->obj_size, + return xfile_load(array->xfile, ptr, array->obj_size, xfarray_pos(array, idx)); } @@ -152,7 +152,7 @@ xfarray_is_unset( if (array->unset_slots == 0) return false; - error = xfile_obj_load(array->xfile, temp, array->obj_size, pos); + error = xfile_load(array->xfile, temp, array->obj_size, pos); if (!error && xfarray_element_is_null(array, temp)) return true; @@ -184,7 +184,7 @@ xfarray_unset( return 0; memset(temp, 0, array->obj_size); - error = xfile_obj_store(array->xfile, temp, array->obj_size, pos); + error = xfile_store(array->xfile, temp, array->obj_size, pos); if (error) return error; @@ -209,7 +209,7 @@ xfarray_store( ASSERT(!xfarray_element_is_null(array, ptr)); - ret = xfile_obj_store(array->xfile, ptr, array->obj_size, + ret = xfile_store(array->xfile, ptr, array->obj_size, xfarray_pos(array, idx)); if (ret) return ret; @@ -245,12 +245,12 @@ xfarray_store_anywhere( for (pos = 0; pos < endpos && array->unset_slots > 0; pos += array->obj_size) { - error = xfile_obj_load(array->xfile, temp, array->obj_size, + error = xfile_load(array->xfile, temp, array->obj_size, pos); if (error || !xfarray_element_is_null(array, temp)) continue; - error = xfile_obj_store(array->xfile, ptr, array->obj_size, + error = xfile_store(array->xfile, ptr, array->obj_size, pos); if (error) return error; @@ -552,7 +552,7 @@ xfarray_isort( trace_xfarray_isort(si, lo, hi); xfarray_sort_bump_loads(si); - error = xfile_obj_load(si->array->xfile, scratch, len, lo_pos); + error = xfile_load(si->array->xfile, scratch, len, lo_pos); if (error) return error; @@ -560,7 +560,7 @@ xfarray_isort( sort(scratch, hi - lo + 1, si->array->obj_size, si->cmp_fn, NULL); xfarray_sort_bump_stores(si); - return xfile_obj_store(si->array->xfile, scratch, len, lo_pos); + return xfile_store(si->array->xfile, scratch, len, lo_pos); } /* Grab a page for sorting records. */ @@ -858,7 +858,7 @@ xfarray_sort_load_cached( if (xfarray_sort_terminated(si, &error)) return error; - return xfile_obj_load(si->array->xfile, ptr, + return xfile_load(si->array->xfile, ptr, si->array->obj_size, idx_pos); } diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 87654cdd5ac6f9..d65681372a7458 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -118,13 +118,11 @@ xfile_destroy( } /* - * Read a memory object directly from the xfile's page cache. Unlike regular - * pread, we return -E2BIG and -EFBIG for reads that are too large or at too - * high an offset, instead of truncating the read. Otherwise, we return - * bytes read or an error code, like regular pread. + * Load an object. Since we're treating this file as "memory", any error or + * short IO is treated as a failure to allocate memory. */ -ssize_t -xfile_pread( +int +xfile_load( struct xfile *xf, void *buf, size_t count, @@ -133,16 +131,15 @@ xfile_pread( struct inode *inode = file_inode(xf->file); struct address_space *mapping = inode->i_mapping; struct page *page = NULL; - ssize_t read = 0; unsigned int pflags; int error = 0; if (count > MAX_RW_COUNT) - return -E2BIG; + return -ENOMEM; if (inode->i_sb->s_maxbytes - pos < count) - return -EFBIG; + return -ENOMEM; - trace_xfile_pread(xf, pos, count); + trace_xfile_load(xf, pos, count); pflags = memalloc_nofs_save(); while (count > 0) { @@ -160,8 +157,10 @@ xfile_pread( __GFP_NOWARN); if (IS_ERR(page)) { error = PTR_ERR(page); - if (error != -ENOMEM) + if (error != -ENOMEM) { + error = -ENOMEM; break; + } memset(buf, 0, len); goto advance; @@ -185,23 +184,18 @@ xfile_pread( count -= len; pos += len; buf += len; - read += len; } memalloc_nofs_restore(pflags); - if (read > 0) - return read; return error; } /* - * Write a memory object directly to the xfile's page cache. Unlike regular - * pwrite, we return -E2BIG and -EFBIG for writes that are too large or at too - * high an offset, instead of truncating the write. Otherwise, we return - * bytes written or an error code, like regular pwrite. + * Store an object. Since we're treating this file as "memory", any error or + * short IO is treated as a failure to allocate memory. */ -ssize_t -xfile_pwrite( +int +xfile_store( struct xfile *xf, const void *buf, size_t count, @@ -211,16 +205,15 @@ xfile_pwrite( struct address_space *mapping = inode->i_mapping; const struct address_space_operations *aops = mapping->a_ops; struct page *page = NULL; - ssize_t written = 0; unsigned int pflags; int error = 0; if (count > MAX_RW_COUNT) - return -E2BIG; + return -ENOMEM; if (inode->i_sb->s_maxbytes - pos < count) - return -EFBIG; + return -ENOMEM; - trace_xfile_pwrite(xf, pos, count); + trace_xfile_store(xf, pos, count); pflags = memalloc_nofs_save(); while (count > 0) { @@ -239,8 +232,10 @@ xfile_pwrite( */ error = aops->write_begin(NULL, mapping, pos, len, &page, &fsdata); - if (error) + if (error) { + error = -ENOMEM; break; + } /* * xfile pages must never be mapped into userspace, so we skip @@ -259,13 +254,14 @@ xfile_pwrite( ret = aops->write_end(NULL, mapping, pos, len, len, page, fsdata); if (ret < 0) { - error = ret; + error = -ENOMEM; break; } - written += ret; - if (ret != len) + if (ret != len) { + error = -ENOMEM; break; + } count -= ret; pos += ret; @@ -273,8 +269,6 @@ xfile_pwrite( } memalloc_nofs_restore(pflags); - if (written > 0) - return written; return error; } diff --git a/fs/xfs/scrub/xfile.h b/fs/xfs/scrub/xfile.h index c602d11560d8ee..465b10f492b66d 100644 --- a/fs/xfs/scrub/xfile.h +++ b/fs/xfs/scrub/xfile.h @@ -29,38 +29,10 @@ struct xfile { int xfile_create(const char *description, loff_t isize, struct xfile **xfilep); void xfile_destroy(struct xfile *xf); -ssize_t xfile_pread(struct xfile *xf, void *buf, size_t count, loff_t pos); -ssize_t xfile_pwrite(struct xfile *xf, const void *buf, size_t count, +int xfile_load(struct xfile *xf, void *buf, size_t count, loff_t pos); +int xfile_store(struct xfile *xf, const void *buf, size_t count, loff_t pos); -/* - * Load an object. Since we're treating this file as "memory", any error or - * short IO is treated as a failure to allocate memory. - */ -static inline int -xfile_obj_load(struct xfile *xf, void *buf, size_t count, loff_t pos) -{ - ssize_t ret = xfile_pread(xf, buf, count, pos); - - if (ret < 0 || ret != count) - return -ENOMEM; - return 0; -} - -/* - * Store an object. Since we're treating this file as "memory", any error or - * short IO is treated as a failure to allocate memory. - */ -static inline int -xfile_obj_store(struct xfile *xf, const void *buf, size_t count, loff_t pos) -{ - ssize_t ret = xfile_pwrite(xf, buf, count, pos); - - if (ret < 0 || ret != count) - return -ENOMEM; - return 0; -} - loff_t xfile_seek_data(struct xfile *xf, loff_t pos); int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len, From patchwork Mon Jan 29 14:34:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535768 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 EEE4FC47DB3 for ; Mon, 29 Jan 2024 14:35:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 851806B00AC; Mon, 29 Jan 2024 09:35:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B4EC6B00AD; Mon, 29 Jan 2024 09:35:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 654EE6B00AE; Mon, 29 Jan 2024 09:35:46 -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 4D98E6B00AC for ; Mon, 29 Jan 2024 09:35:46 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 242BF14013E for ; Mon, 29 Jan 2024 14:35:46 +0000 (UTC) X-FDA: 81732597492.16.18E56A1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf17.hostedemail.com (Postfix) with ESMTP id 6B1AB4000E for ; Mon, 29 Jan 2024 14:35:44 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Nzpvnqy2; dmarc=none; spf=none (imf17.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538944; 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=5C9VP1SaExA9uyPFl5WPVHE4cTMuqE1mtuEvKQxBCh0=; b=VBMnYiHUTy7655pcnT9usPoaFW51FWY1eVzzfyzVUWCfXYLq7oGqm3S2A8lIGuBGdlq2LS 5Qd8aYMHfZLPaXzCdDAwhsMGbuxsBxBFE3aN/oVgxEIfi6Z0wAe4bv7G0gbYFukdU4UJQv ZCjKLceSEi0slQptJCVdEAZKd/lf4hE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Nzpvnqy2; dmarc=none; spf=none (imf17.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538944; a=rsa-sha256; cv=none; b=GPc+W5OUi4c8ZOTP9uI/uOxHjUcL4FQJfaOsS8PY6ban8fpAy1ErMbvUGozfXTKVhGEoTT x+Z/CBDieu+SqmNT8Ek/CdSBACAPp+DrgqB8bajI5utJdws20+Stc/r3FTbdllN4zimdrv 7esWIcUw2B1MXESWnFvylk8VhzFI/44= 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=5C9VP1SaExA9uyPFl5WPVHE4cTMuqE1mtuEvKQxBCh0=; b=Nzpvnqy25fBuewAn8a4fPzk8TC GpboyE4dwrfTM4LUihBf4GKSMM5SXJ3aU1ksr79KJPbn/xfAu5ODCCRb+cqcQmI1u3Hp2m1MO1ik9 MWBRQnZdHLJNiVNjLfr8pTwJKhKZwlMDtu3hIPJZEj/W/xDB/RHV6QUlrHo0PNhqd3FCxhRtEpLNE NcVY+9aBGRDx9WDU9meX66LEF7x7v+FbhqwxA4YrRQwts6qpO1n9fDuFUjGfV/H0nmm336P2CCyc0 Tr1iC8yW5cdnonXAubc2ZY7TlR9VcqBCMAJIVhFElv68l8C5ljn+4SxEB1oQXXnhOCvMKaMJYYRui C7kC1kEQ==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjd-0000000D6Hw-2zun; Mon, 29 Jan 2024 14:35:42 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 10/20] xfs: don't try to handle non-update pages in xfile_obj_load Date: Mon, 29 Jan 2024 15:34:52 +0100 Message-Id: <20240129143502.189370-11-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: 6B1AB4000E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: kho7zbsz7koeiad38quzdcmjcu9jm17g X-HE-Tag: 1706538944-41311 X-HE-Meta: U2FsdGVkX1/lhTOivCYrYMnG3cOMvkKmor77+04CkbLqZXJYhml4z3/W83Otz5yiPDFVxxx5Ef2xqxNauMnm1TiMXz2bXWUQe6IcNhJ2EPNs4koNxOdk4fcPs+hXVON8dBJfvRi/VifH0zYT2cUzDKZjTrXPszQpvY4AEDuXPW7IniB7KowFAYsLiEZJsL3sPTTyDiFv28ZrFWUuYRT9f++tBlx8fxY3KcmludBcqKSfuEooMBj0aVT3kwp6C+XqvRQb2D+mH9WxuZq2FlO9x+OAKY9ruDAzvMqOolGGsromCq6ks6X+nQud1bl9YfAUJlLMUWEZjn8MALH4PI/5CFfHbhemEgTFGhkbNXoZ24ANaefI0P0qL729HLrVuFMEvUHxG3XBPwd/TWUASfSo2FDuW9gTZpGmP6+IZbRvnueuvilpSGn3ZhSFbfhO3xyjVltIQ1kvtYtf4z30A4pXu4Xi0rhJN2HvCBlHnNDCfoEeNrmEEuDfPhkqlZVTMub7K9qeE1ARk9DvYNJjMRUCcETmU98yZj8TxoAr+LB+q3mr3kUowbvf4u0NLk+TMSpkL/A6KgBPw9Eh3gVkw9SqtleQhJzNIDoNB586fxJfKWcZ3rHN0uHrQ5g34vFcih2qyzw/x/6FCGgyrlb/Lt/zO/i9rKu/LGJF9JNdaHv7QgpqNBC20KRe+YZ9u+SoWV9B7/sCz1sMonzU175C0WF6heELhP/zQccuYH8rTbDVPTWDY/ibF2RgO7kNg0ZkXpbVaGZOhTJKeQjeIrhYzHwDNYdrx2oxOHEU1fMUgbdvxiagWdkJZ+H+cxGbOarOkYE1ebFOSvolEm1+xPQ6ThXq/N7PqEBIDlEWaZtQXjwLSuFZRrG4uQSiqFjFncxexwOOh2uHRzszqwyBcM3FZB2W4OnpNrTud3W8fE/3Xhrx2QRAixnl+T0uQg+4CrUvtk3I0OBlZkHbZn8fDb3z5o/ 1zOvRW2c BxclGaMfLW2Vs1Jw8wzpOJTVqS2YDgTIr6uV0/VrQrKy8fooqQ0jMk6mAsQkdEX/zgLQ02nG3RSGIycjjR7GGbf2MYIWcfVJ5f2HZbFDPI5ialjXmc557ASh8eF463QFLt9TAfQ1kUhpzVZw5QXxF8ns4mhDnEyf7ko77Vg2JWlfuMNs96lmTG7h/tSoq+1LngIhgRN6Uu7Sjhq77i74nsL/7fNGyZvBD1Mmbu9/jV5qReOoTw2Vf7LfUgA98ZLFB2Hys4CgIi3k0qrCkt+9MTIL9KyTOaJ5Jf9nqpj/xBg/FQ82Nu2xh89wrGi75Y+TRK9VgkgO+QriwI1NRLBNJqeBDPqlBXCQagNDRzbJOgQGiQc3wzjinRGpdLbbbrRIW0I7Bk0mseVzs825tPS7eCEh8FMZGc9N53l1YkPJnlb+S8gOCAJ5LiC8EEwgJy0wWS4iRhlT5/38SbSY3EWXSS6vcwt0q7yq6y9R5+VrOXQq1f1Vst3I/TJEHtdL6ynZ6dzRGbtZfIqMwfEM= 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: List-Subscribe: List-Unsubscribe: shmem_read_mapping_page_gfp always returns an uptodate page or an ERR_PTR. Remove the code that tries to handle a non-uptodate page. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index d65681372a7458..71c4102f3305fe 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -166,18 +166,14 @@ xfile_load( goto advance; } - if (PageUptodate(page)) { - /* - * xfile pages must never be mapped into userspace, so - * we skip the dcache flush. - */ - kaddr = kmap_local_page(page); - p = kaddr + offset_in_page(pos); - memcpy(buf, p, len); - kunmap_local(kaddr); - } else { - memset(buf, 0, len); - } + /* + * xfile pages must never be mapped into userspace, so + * we skip the dcache flush. + */ + kaddr = kmap_local_page(page); + p = kaddr + offset_in_page(pos); + memcpy(buf, p, len); + kunmap_local(kaddr); put_page(page); advance: From patchwork Mon Jan 29 14:34:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535769 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 9112BC47DB3 for ; Mon, 29 Jan 2024 14:35:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 25FD46B0075; Mon, 29 Jan 2024 09:35:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C03C6B00AE; Mon, 29 Jan 2024 09:35:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03AC96B00B1; Mon, 29 Jan 2024 09:35:49 -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 E01626B00AE for ; Mon, 29 Jan 2024 09:35:49 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8C7A1A0667 for ; Mon, 29 Jan 2024 14:35:49 +0000 (UTC) X-FDA: 81732597618.10.9B4A2F6 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf13.hostedemail.com (Postfix) with ESMTP id C71DC2001F for ; Mon, 29 Jan 2024 14:35:47 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=L3wYExFQ; dmarc=none; spf=none (imf13.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538947; 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=Qe83DfTex1z7zqi4GxksjarNQRXeRN9ZyszbsgkFHtk=; b=kkZ4P7bJWJuyBwZYoEjt8alccfjCY+2qPR4dGAqVCZy1/ybAD6W8f5eTgHtEQ5ytzNxw3p 9keEXHweQPP4IlQVqRtVG35RFEtdJKOOyac+AkjITa7ISnk/qklHLwaxPNBnQMhKfJOwKl BGA1JqiaxwZGvdETZFxFep1F6H7r04Q= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=L3wYExFQ; dmarc=none; spf=none (imf13.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538947; a=rsa-sha256; cv=none; b=YWKB+Rj1YKwfosymeUx2cSYwayqmH2oCgbd14iE4tNJZITRefY5X2N1LJAUHOFUVzGym3S CVXHAIc/vr7EFBpwYLODI8MKNDZlF5JsuzrXqLvJX1F4BkvecmY2x6xqf5KBlbTD9tIEaP HtBYONI3eYWHvDlJ+ZVDG3H7XhOkcXc= 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=Qe83DfTex1z7zqi4GxksjarNQRXeRN9ZyszbsgkFHtk=; b=L3wYExFQC0UvuaWRe1nYere+D3 T0e/ZF+LMHE1lHOttUK8WdQM2kpKei3OFZNmrMIMSa3S9Y2hVRvLta/6vsXwyVahp/L4VnqNYQDxU 6cUXOBLNN3pxSWmxRVOTXtv/Wj5LVjrmrdH71qt+RPJr0088CIR/EBbAiTFUcXRYQnt8R5x9Xe3+L JzQze5Mdqk7zFbrd5/bF74xd6Z8ERDHehQ5LbYP7Bq0bOMugqbt2nAVAjB72vjYVHq+pDENuWtZvs oD29U1cbmj6+mIKmn9LN+B1/2APGXvFBLeha0QKdPmJ2791TDKtERQ55WTjvHcWB2REM/2vZ8eQFn tu8LAvCw==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjh-0000000D6KF-0TQt; Mon, 29 Jan 2024 14:35:45 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 11/20] xfs: shmem_file_setup can't return NULL Date: Mon, 29 Jan 2024 15:34:53 +0100 Message-Id: <20240129143502.189370-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: rspam09 X-Rspamd-Queue-Id: C71DC2001F X-Stat-Signature: ha3tt9d5qjmoymkdem8hiupqg7ooiona X-Rspam-User: X-HE-Tag: 1706538947-247873 X-HE-Meta: U2FsdGVkX1/DHPl39tSltAS/i2au9B2VFhioehXAAIV85GyMTdaFgvXOO/enOwqO505FUM41xFCOxeM3IczqTiPCqCVblqn2MG4aL8FQDr7hpPjQXDo0R6jHxhdZ5hkHCJI4DfNlOqLDlsGa9HVskPBLO3BRJPHavAyAi4HASC9bWTiazDQsHyP2jUWSHaaDrwiC///5IU16wLlUQVE/wKKFlarBG9UIKrV9KO86CQ1zUP65qFO/+p4kQPB3CLEjj/Ik/7sfjqjWqn96Jnp0fsqiZlLreWUoPmiCwLk/CSTVN5d8oZnfOt8hXxrkeSzZoQydxAOE1804PABCX4+tiVPPvvfbLDp+dlMtecT4xC0ioeKjXBcz+VtIqx0TgwP0DN8WEVRbxXL99sKnHF9tldLTsCBgiOFpdaH6/wuYY3UuABq5mHgwRi+lbjWXUVYNBn7TGn5scFNINAdMTC79gmJwh5MtPO/mzj8vHndCvhDK8pKTdf90uwc/I2bbvPbjW2XcG57GSY57P1+13JC+QpqZa46NqssoCvAh5cnMA9s1mtleK9VFvRC7lapwSO6uhX7MEb+rIFRumq4o2chjhHoQM6POTe8wAShDK+PVF4lzW9St+iCOzsJmZpv2OwpfX7lY9ifM442kuSXUSLdniZl+9e9KCNVWoz74Z2KA4+2dHDGpHQGt3ElZ6/zuU7aV3wn3p8iPCp/SJ61xGQ3ngNvVZ9kxYtsJ6o2jQJVyNgddwcH2+xxD5Gwti/y0htV2go2HVL31oAS1rbWeqkhhJAy+DHWAQPJDZHo8/GipUzfVbl3Wvy6Zga6FkbMvC6RrDPt5CqoM/fah/Udf0MkdqYRSVQ2ZvUG+mN6V4GVB6vVcRDabKkqg7e8Qm15SwcjD6zAt6bSLj8yh107q695+Fji76GW650HRjsY6LlgHr2uzZqwRhe94Yv66d018kDMK3dggY1KGKwlMz/PW+R9 /UFnq3nD iDBZDilte+e+khMfj8xkJ0f7vFmcead5x02AHiImZoHcdvsu8eeZ1bpwaTNdWRxgx0mEvhdHwHSkAR7fxoFwuRpT8V9rfaVvz8qzMPWKgrX96KdJfBFwUuICm40tuPCXYlYZtVuSRMz0T9o1WshmKpFPcWfGV/PfOCHU8ygwIWzud2HmQjePaKM/4r0wXxSBTxNA4zaywfmp5ewJiXp2ibiUfbdzS7K7AzI7ahdYZzNrdeuU34BUUJbJg1eErjQ/+7ni+kPNk4oBFpnJX65No8XBD2v9jYpEI71fKT5E7XzDGmiUKQQNMV/rSdV8L4ChVVcPVABbdhvSWV8IOfN/1X+aPP8VEiaSze+mrdN5JVltALwQG9HEk6e5pXUVioiqHgesgBqpBKjRinATShrWHnCmwpLKjvpur7DjeJVhOvwz4mHSFo2A/AdrdS8btSSMInHFXnuTuq8o7s+nT9GymxxaledKNvI68bLmgn7tx+Cc06bf6vwbr5I0CeZmgm12oy0hkQm4h/ILtCkw= 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: List-Subscribe: List-Unsubscribe: shmem_file_setup always returns a struct file pointer or an ERR_PTR, so remove the code to check for a NULL return. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 71c4102f3305fe..7785afacf21809 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -62,15 +62,13 @@ xfile_create( { struct inode *inode; struct xfile *xf; - int error = -ENOMEM; + int error; xf = kmalloc(sizeof(struct xfile), XCHK_GFP_FLAGS); if (!xf) return -ENOMEM; xf->file = shmem_file_setup(description, isize, 0); - if (!xf->file) - goto out_xfile; if (IS_ERR(xf->file)) { error = PTR_ERR(xf->file); goto out_xfile; From patchwork Mon Jan 29 14:34:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535770 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 6EFC9C47422 for ; Mon, 29 Jan 2024 14:35:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE3776B00A2; Mon, 29 Jan 2024 09:35:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E43A16B00B1; Mon, 29 Jan 2024 09:35:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBE0B6B00A2; Mon, 29 Jan 2024 09:35:52 -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 AABE86B00B0 for ; Mon, 29 Jan 2024 09:35:52 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5C0691A0A36 for ; Mon, 29 Jan 2024 14:35:52 +0000 (UTC) X-FDA: 81732597744.04.9C53AE5 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf06.hostedemail.com (Postfix) with ESMTP id A5DC118001D for ; Mon, 29 Jan 2024 14:35:50 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XU4lx99Q; dmarc=none; spf=none (imf06.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538950; 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=WZPrkSzC6JP8KIWSSwxcdUJBQA5TQKYe+UX++Ksig+4=; b=0LrBiTKrd/EZYeaZTjaB+C1Bw95sTu9NQhvQqguc9FD4tkS50km01kK8opMMB/3dDi8SQ5 MSHzyjzS2JRkyhq78VnNsRcPuahqKM/7JjL+bhPSRL8o7Ev9VUzY0koIT9/TRtBqV7Feze uTjnGwEQh22kdsRM/H+THelwR4MDeFk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XU4lx99Q; dmarc=none; spf=none (imf06.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538950; a=rsa-sha256; cv=none; b=QAlivDFMrqLMFV6SuOFmlLOYJ8fxXtIDslyr44LxigoIGTi54h+LqrWzjtxO4bfhy22CfT oRhsUKcy1Su/GZLfrY8wMgoQu/4RHJehMe9ZAtfdBH2tD2vpbXfpbuwmSn2l3rxKbJckfy kZaF7cIiFE1qMFXZKbsw3dbJYO3WIAg= 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=WZPrkSzC6JP8KIWSSwxcdUJBQA5TQKYe+UX++Ksig+4=; b=XU4lx99QKPPKmDgve+lLL6ig3j BLlmqQ1Pp7IJC2RnK+90IsIg/JiwDBGW4sSQhoKXo2cLYwVMBJPTgBFsXc7x4rccgqhY0ZMuPbsTP G/jiTROM8vMNGQxyIQGOIlBR4VcHP/Zvd1LuIlTmprOqgmYZDOomYkWFKDUOTom9HaatTvLOMc4SY ivE/cFH/7Ld/uKB2gG4+zPILYWnKw5OecUJXYv3G7+/SlWGB48DHSnTmpNCnsWmepYdeqqfNq8ksY dlSCoUciXUs/je+p5B4zN/JkXDubOOr/FRZ6H43RJBtlipdiO/94EB5twwyh00wm+i9E7yZJfjbYz Y24Xi/xw==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjk-0000000D6L4-0ciP; Mon, 29 Jan 2024 14:35:48 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 12/20] xfs: don't modify file and inode flags for shmem files Date: Mon, 29 Jan 2024 15:34:54 +0100 Message-Id: <20240129143502.189370-13-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: rspam12 X-Rspamd-Queue-Id: A5DC118001D X-Stat-Signature: cjbkd89exnxi8zc33qnp33aadby7ga3n X-HE-Tag: 1706538950-719602 X-HE-Meta: U2FsdGVkX1+Sza0jDBq4PYSsukdKJsHc9vMGmwcrVlqGF5K3diiVS9ys4XXOJZ7VrZAiSHWLoryc046P/WiA9ABUPsDetu+zOK6Fcd3jP9vgwcZbrTdwUqkktZ6faqdigtpJHawevHzl/jWpuso73HXfI8WN3ByJDi3Lggy0yns/XTMZZ9R9Ezv1A8LSQpe8LocsbR+uXqjv86DLjJy24snLSXYxy3w6q42VlYEXwmBbq5qernupq2yReYrc8mL1OJuiWauNEbI2vxvKq3LjPIpt9O6JFqQwg0JeRwK2fC7sQDYKFy/Nb9/8+HdYN9rPxWKEbqCSYNEoX4sZYJGjfY7uzri49dbA1vld2PP+n4/+WGVNwu1InGLa7n5x3J67Lsz7pockXz/DuVV02RRoKTy8H0TKEbDFtKvXh+MZYkJOC4A/ognnNHZIb8KS01s5KEqJ7kBy/rSRDbudh8WAQGDF4sfoIFOXRGwmWpWoma7h2OImq3kjOpw39DO1YlAfz3C8uhnw5pR8JzAu7VnC/WrEDaceGfiVf5aRE7mGgmLZYaTR0pVgFGdsjjjH9LyEdMzgMdk8vfCqCp6uIZHqMRM1X1tGfiM9fCFcaGMEX4y91WJ+wi4y42fja01t3bhNDF17GfY6fHJ5hNRDRb1Eg6xcPurRUTyGjk1dKt686/dlp/6vxBEpGehqQMQfpPMf4A3P+EJvC3vQE9UpVSDeYFXBvNwEzFTNKHw58JyemYD026MozXw5viQP96QPWKPNR0wXbIAw21YI9xYz8rQF1pjMI17Vj+S/rSbXddJWnoMN5nel5dkvnL3RZq/0jzDefa9T4RzYILgHbu4B9k2fsYazZEqxrkPqLYm6Yr2VcLRQInz4UaRHUMEO6bI5eNFAdOWUi137EUH7JVxlaCMuEj017d1S+X/beWdDsaX2flqwAF06iH546Hoq8sDh/+5QND4Wnms4h6ruXc4A6AD aC9ipkMW BvLEenZmxdCFTtG1oaYPLX+sBqPHjj2ohNjNCYdnpEDo3pTDIR7SlRaKvoKRU1pUSVO+Fk7bqSkxNQ8W6BOO/RaQp7yX079iyTboKnshyo6FvKkjKSlq66T8hEAozl3FFRDpxEXvaE8ap9HLl4FV7Ao6uQyw21ceeB566eCtSikAAn9IJ2RyBWsHdDVNP9LsPeQ3QuhNTKlq8CjAOX2TLCzUxh81iSo2W1W87qQm+57By/k0ZgiaBpSH7dAvDzhmSjjEEBQszWKDf4gG3mIYS7emSNvB0yMLPVTssK2i8DMG+ToeYC6BiqxMSZNFHU0K40LzlW51zsIybPmBpTpmOzd/vIazw9/D5QW36hHR1wqlU4hFsttg20HoL6y6VtXb/qW6nzcg4ECWengcXhvNt84BB1il+vvZGHURTOXFMnmVgH8571n3qzWvj13EwcwOA79pY/8isTREqm5D8SdQseE5GYA== 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: List-Subscribe: List-Unsubscribe: shmem_file_setup is explicitly intended for a file that can be fully read and written by kernel users without restrictions. Don't poke into internals to change random flags in the file or inode. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 7785afacf21809..7e915385ef0011 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -68,28 +68,13 @@ xfile_create( if (!xf) return -ENOMEM; - xf->file = shmem_file_setup(description, isize, 0); + xf->file = shmem_kernel_file_setup(description, isize, 0); if (IS_ERR(xf->file)) { error = PTR_ERR(xf->file); goto out_xfile; } - /* - * We want a large sparse file that we can pread, pwrite, and seek. - * xfile users are responsible for keeping the xfile hidden away from - * all other callers, so we skip timestamp updates and security checks. - * Make the inode only accessible by root, just in case the xfile ever - * escapes. - */ - xf->file->f_mode |= FMODE_PREAD | FMODE_PWRITE | FMODE_NOCMTIME | - FMODE_LSEEK; - xf->file->f_flags |= O_RDWR | O_LARGEFILE | O_NOATIME; inode = file_inode(xf->file); - inode->i_flags |= S_PRIVATE | S_NOCMTIME | S_NOATIME; - inode->i_mode &= ~0177; - inode->i_uid = GLOBAL_ROOT_UID; - inode->i_gid = GLOBAL_ROOT_GID; - lockdep_set_class(&inode->i_rwsem, &xfile_i_mutex_key); trace_xfile_create(xf); From patchwork Mon Jan 29 14:34:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535771 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 B227AC47DB3 for ; Mon, 29 Jan 2024 14:35:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4381E6B00B1; Mon, 29 Jan 2024 09:35:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 370BD6B00B2; Mon, 29 Jan 2024 09:35:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C2D76B00B3; Mon, 29 Jan 2024 09:35:56 -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 00C556B00B1 for ; Mon, 29 Jan 2024 09:35:55 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BD4F0120A6E for ; Mon, 29 Jan 2024 14:35:55 +0000 (UTC) X-FDA: 81732597870.04.296264C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf19.hostedemail.com (Postfix) with ESMTP id 07D481A001D for ; Mon, 29 Jan 2024 14:35:53 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Ndx6oX0I; dmarc=none; spf=none (imf19.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538954; 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=UUGBMYNgAEuyMsH9DsEDC+bqyUdHBQHIt1xJzsh3ydM=; b=2J80lh1bWxHLof2UHNBBynFhdB2Ey9sRCAtWGvuHg/eavsn9SBjfPwe0AXvUEU3pmVXiB5 /jJ4viKPucS6thTm7W4D4WOJtBYglFeBIGIh+erryB7FX6vXaGW9DS7Ngus5apiXNTl7tE HqHYeaFHdnk0EMUDjL/BahFWnMVBzuA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Ndx6oX0I; dmarc=none; spf=none (imf19.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538954; a=rsa-sha256; cv=none; b=w1hiEKIMpJXf8BiSWlIaDDwIOar1BkVOBQUMppwRVlXrXzxkJQ5NVdB9/SHvNwqrR2WR/s VxLsDkYF7k+6cYOxArNr9Ew+syVgzrzl8jV0cOzxii1wC8qS7EV2GHZqk1pVyD29tuZXdW 2LlzgfQFfXvykGqb6j6y4fE2TueHQqI= 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=UUGBMYNgAEuyMsH9DsEDC+bqyUdHBQHIt1xJzsh3ydM=; b=Ndx6oX0IR1JD+I2qz/1pNNkhLa 1Rzbjm71jFKu/bjnfJYXhabmeWIaWIga7uoXTS9wR5HRnVP4lPTzCN+tRwXZ7CGUsrFvCHtSlh0nk sHU8jZcCtrRQO5Ljbbm7KOfQZltyrwKXCT/xo/CWlhLu9DLyRL0rfuA2fTFeV+JKUm7FEEBaV0972 lnWwfxK15CoEpvMUp9nuGPTxWNsWNbrcsYongV4qhHcTWmAc3fYccTitRt248escxK+suL8GqnB2C 9JVYMGS0ny5GVKHDbZxaiMgoCN0vyYFAMAngl8vV1VSeiBjTPSaRMtkR4ejo77dMZ72tMhWTceF8C LIhA55Mg==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjn-0000000D6MX-1iHd; Mon, 29 Jan 2024 14:35:51 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 13/20] xfs: don't allow highmem pages in xfile mappings Date: Mon, 29 Jan 2024 15:34:55 +0100 Message-Id: <20240129143502.189370-14-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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-Stat-Signature: f3ki5uiqc8ust65ius78b8ikwfr4a91a X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 07D481A001D X-HE-Tag: 1706538953-206814 X-HE-Meta: U2FsdGVkX18fQBUDIG4E1dbxOFSh01ZXDYJYLGLob0QxPC/qL5JX7N4h3pwNYKKTVvuintQer4s1MjEOrpYZjfHZu41WhXbMQdtvCbcGUjzNvWHVslfRFSCY27c0V541jcI7LRniXdZwmfXFlSruXXfqgBnVVaXpnJMeLX2g1+oMZTXpzK2OX64kFgoLy1LEKoV0/+GQO4OxhADDLSCBp9Slc54wcjFe+pDgyYe4hSeHSU6q62HezYdTX53zo0D9DfCqtMohK9oKLwVZOwebuxgtoNzQe09sV+U88WJst9msbL+2gNDpN/afXpEYGy1ZEbv+kdzEjKFsULCJrWn2PFvHoV/5HzCG0/5iJ4GVfQ13C7tr1HUoZxjEunIq9l+fCOsGHWaNpwOApiXq0LM1/KwEoHoUctZICWphACI0zpwbRVSbdcfII9yMdYYOhLY4Yb2NJH4adLyeZKjs2dKmqNwXIphiRTKj/ORxF0obWYa2qgAiRU+676CWHs1OTpu1olQRKkU/aIwD+LIQc4Es67sabJcLCbJiwUFbVEgmav4G6NZ3aVYcXoygHggSkqRWMb+IljA0QrC21O5rIjp3A6q76UFFD3QGNoI0N7++a/xFksipY0/e7koDZV3KKJSsv98HJJI3eSBKB6KW81WC/ylU4UsUtO0CHW71/5/23oQQ6t6ezJ8C0EqFZT8eis4aC+Ttfk6KV74pfaQwytnKziQ6ebDGETBNeO1ceRAyQhxxlp1JUPUEW5bHnNb/D/1sYjeRLe4OK/8W1WMEQr5l+7lROlD9oF/7t+ek++wK13rjn8RZ5Df2QUItd36gTm9aWAPlX1NO/T/5/EO4BieZIZ2/a4d7XtCqynoFWHHyh302NZSXjrRqVKqzOxtHTja4xtS5bc2RnEr9ogYfPwKhfgFpQKzcS4AVn95QekR+NjZjoGJIXlvTlNmr/h/cdFS2MwL4y2neQIq3fVC1Ofs //6H28Sz k7U1jfXu6DukoTtbU6xN32hZqkSd/NtSLpRuwudcqw46REO1RJq4m3cCWCKoHSDlLAltPqz/kkXrHT06oJHfLYBnk9okyr0z2RjLjsIvvswBXhlf2dkljra8r0UezWK/2LpmWlsq9SrOFZYCXRpZ3UyRcDFYJWJeVmwEvUfI69urNUSZQbxaIrb+RjC2NqrK1CAOiKsaJ6HWryZAVzYO9rGt+IObnLghfN1+lol5xrV8aLGJ1L0Y8uQNBgOWaR8flnbSvjY8oq1U5buxg83cawZTSUH8ohCJvDAteMjzJRhS7WFzB0ZapOqyPwu7X4ISA59gSYMAHcrxpT4dfCxQeiiXeSDz9M7lf7+84zTD62DpClvUfHvHhvv3KuwoVZ2p4SKAOQYVUrE9basadunwb7L0zeMIbfKl6+kfcsL/8EylyDzV8IYhI0RXUiqDMM9YD4np3dmIgGpE/dG/ApggdEPX4Tg== 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: List-Subscribe: List-Unsubscribe: XFS is generally used on 64-bit, non-highmem platforms and xfile mappings are accessed all the time. Reduce our pain by not allowing any highmem mappings in the xfile page cache and remove all the kmap calls for it. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfarray.c | 3 +-- fs/xfs/scrub/xfile.c | 21 +++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index 95ac14bceeadd6..d0f98a43b2ba0a 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -580,7 +580,7 @@ xfarray_sort_get_page( * xfile pages must never be mapped into userspace, so we skip the * dcache flush when mapping the page. */ - si->page_kaddr = kmap_local_page(si->xfpage.page); + si->page_kaddr = page_address(si->xfpage.page); return 0; } @@ -592,7 +592,6 @@ xfarray_sort_put_page( if (!si->page_kaddr) return 0; - kunmap_local(si->page_kaddr); si->page_kaddr = NULL; return xfile_put_page(si->array->xfile, &si->xfpage); diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 7e915385ef0011..a669ebbbc02d1d 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -77,6 +77,12 @@ xfile_create( inode = file_inode(xf->file); lockdep_set_class(&inode->i_rwsem, &xfile_i_mutex_key); + /* + * We don't want to bother with kmapping data during repair, so don't + * allow highmem pages to back this mapping. + */ + mapping_set_gfp_mask(inode->i_mapping, GFP_KERNEL); + trace_xfile_create(xf); *xfilep = xf; @@ -126,7 +132,6 @@ xfile_load( pflags = memalloc_nofs_save(); while (count > 0) { - void *p, *kaddr; unsigned int len; len = min_t(ssize_t, count, PAGE_SIZE - offset_in_page(pos)); @@ -153,10 +158,7 @@ xfile_load( * xfile pages must never be mapped into userspace, so * we skip the dcache flush. */ - kaddr = kmap_local_page(page); - p = kaddr + offset_in_page(pos); - memcpy(buf, p, len); - kunmap_local(kaddr); + memcpy(buf, page_address(page) + offset_in_page(pos), len); put_page(page); advance: @@ -221,14 +223,13 @@ xfile_store( * the dcache flush. If the page is not uptodate, zero it * before writing data. */ - kaddr = kmap_local_page(page); + kaddr = page_address(page); if (!PageUptodate(page)) { memset(kaddr, 0, PAGE_SIZE); SetPageUptodate(page); } p = kaddr + offset_in_page(pos); memcpy(p, buf, len); - kunmap_local(kaddr); ret = aops->write_end(NULL, mapping, pos, len, len, page, fsdata); @@ -314,11 +315,7 @@ xfile_get_page( * to the caller and make sure the backing store will hold on to them. */ if (!PageUptodate(page)) { - void *kaddr; - - kaddr = kmap_local_page(page); - memset(kaddr, 0, PAGE_SIZE); - kunmap_local(kaddr); + memset(page_address(page), 0, PAGE_SIZE); SetPageUptodate(page); } From patchwork Mon Jan 29 14:34:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535772 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 B630BC47DB3 for ; Mon, 29 Jan 2024 14:35:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4341A6B00B3; Mon, 29 Jan 2024 09:35:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 397446B00B4; Mon, 29 Jan 2024 09:35:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2109D6B00B5; Mon, 29 Jan 2024 09:35:59 -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 092AE6B00B3 for ; Mon, 29 Jan 2024 09:35:59 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D60B0A139D for ; Mon, 29 Jan 2024 14:35:58 +0000 (UTC) X-FDA: 81732597996.27.040D8EF Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf26.hostedemail.com (Postfix) with ESMTP id 257D814002B for ; Mon, 29 Jan 2024 14:35:56 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ESJmh4m+; dmarc=none; spf=none (imf26.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538957; 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=nAo5bw02V9iJ+IEFLiAcFuHre/6jVBRPkcUqDrM/TzU=; b=qS24uA6JbUmVwz7/7VOpgmSBWAiZoNfTFVHURek9V3WUoSS0Jc1v5yAzmjuksVlLz+wIeZ lZW1/Helqg5QF5zilYLjdf2szMgttNSUb4pHnAqD0gq33Tji4SVArMvIYfjwSwjFXk2z4X G3blLbEFh4CdTkMK2z4ylDQtkCiJUZg= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ESJmh4m+; dmarc=none; spf=none (imf26.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538957; a=rsa-sha256; cv=none; b=nX57BLDRtOrjwHqj+n788W5woYJ3DmelIwnCpPmKzfuPXTlmXFAfJgAC6D3FMCpwZvSiE2 6TKqwqCb8PZI2hc1/dXd4PIlt2M1rXCJkHnNXokpajQMLvCW8PJXnkRbfWqO3ZZoVZ3Ov3 spdSOHZ3fee0jDLwQy3IpVRU4PJfrQ8= 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=nAo5bw02V9iJ+IEFLiAcFuHre/6jVBRPkcUqDrM/TzU=; b=ESJmh4m+XvuhJ6apgjdWVYbSVY N4ryfai2FPtx4Wpip6S3CTa5kgs80PjCDDvGslPw2JEo398x1r/Y4iGceJjonN1kCr5Ep6cTW0uxZ PI37QgXu5KBJCR3af4rO/WQZkOM/PTQpGFZ5XgzqNih4TRD1aCm+fTlrZyeD5ZRZrE49eh7ok/1FA THQ18sSsBbR7zpH6Jx366zYIf7tNopG3SmINd4bwOqzmH6LmOEY6fZAe58223NfEhgvVPljL50WEX MgM5p+MKE1+5QInkOV8DDb8qpjwSQfFrCbDP3krjKfR82H7Dr7mbJxTvSbyJOWJZH1rON7KnHW673 qLrdYKvA==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjq-0000000D6Ns-2GN2; Mon, 29 Jan 2024 14:35:55 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 14/20] xfs: use shmem_get_folio in xfile_obj_store Date: Mon, 29 Jan 2024 15:34:56 +0100 Message-Id: <20240129143502.189370-15-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: 257D814002B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: r9uacn8t54yggeod4sf4qsy9ydyuo6fq X-HE-Tag: 1706538956-154066 X-HE-Meta: U2FsdGVkX1909JfJkqSWetZqxF4TrRl7I727CN4dOqif8E0p6LdAc7FQ3NoNv/aiL5QZZDtxnJGbU54ZxXjBpRvykwB7ljBS21QBkk765GlcecQy7CthF6zGCvSt28yMvew78yr9s4Y1cAIZNBY3+kBNth4yQ8CtMfaBxDJargQnx66Ga70mpa0QEmw1ftOf0Nnjkd/h0o6gUVTJG35NO6E1eXveVsK4BeQzVWQ+I8tklTSLe/Cx4iJmScOOXb5hsmC4Xrcl4dcsJ2HAhVfP5VfecFluS0ggpzpa8i3NNMXsG24Hum2efMimslRfXEy9fuGUeHu+0WcuXjFCDBeaOanTCqwKsn82XI2PKMfYfLYFDzHQqrl2Db0sCDsfbez+JX5cRJquepO4k3IiVmgxQQYTqJ2Lmds+9GIuFiVj1q9wE0X3NG5T6R0xMYLB1J4JcCmAFj3fyVXShTT1ff4kx1cQBGfRFaevRTT/z4mWXm69fIg0nTGZXYxmYRSRP6dByA2yljERsV0MEHaKtJiAmKBiXzgK8qUK5giYy2zuRHAVPZGDYwN1IqAV4oER+qjHFFKXqPnHQFoIi9T7swK30iZcpqlwDSTpm901tIo+5SErEBUzm57DVNfNNfJ1sxIR11I0rSWnf4FGsQxVjFMmvS4FOPBIvGxg0wwg3WGVsC6rx0z89Kgh/9WUUZZxoQVbuFUKQRxuIoJ/er3BMe3ByvS1i8tSpMvdNOBdn7ed2GR0HmRjrcGBqnSi73ZQFShvsQDP4Md2zotscn+QmkQGGg+kewyGRlagEBI76wTMyaByYPCIxVr6nFN9IulLrtjbhgDBQLxuyYasqaA3Ccz7B2CKxzd3VYBAlcxcUphadK7pSdRhXq0hBpSQzI69nYVReaDeWey6xAbGMfAcogWzApXE9Q4SN9ZSRQbV9r8dQd84X0QCG5aB5LnQ9QJWxvAinlp1mkeTP9buscqONRs YfQOsCkZ oTGLE+C7FjyB0k14Wmcvwk4Vnw5rSaSGdJ6FT9sPhkZ67G5r8UGi0vL4v7NKOhWTv31uRUx1fC+IW0s9GHFbfTl/IOejPrchd8/kuRUvLtoCXkuLF93ojTCa9jSdMJ6P6m528BqoitWZSyikUjGul1Z+h5YYUYLBxDQakDCFtnC8LBwn9eHxVwcmmpfXXS0ZqWxVyheelHg+G/sZ437Dv1KOr5MWtCzNbTDvXkWpphu+a/+jLZ9pGgi3QISdsgLtcti3wt/VpZrUbsct4nKhgliYoq2iG/JuXM265nPJLizIVsus6fsHuxwZU6DUPzIkhDp/k4ZcN6XMqRUMZATHyI7g2lRcIlKBXonqtsOBqJlptMv8xZ9Rx1a7iIu50YnBuamjLlZ8zd2GlX9oQJ2jmdbWCELb894ET634HtHYFYIuqKb+Y/xmcMYa/SNc/6Z0Z+F3B3xpRSRwtThW4YGRJtgb5YxIIA6pqv+9HMbSu1hHlriznqbshlSRVKQaAodRG58D2eK12a5CogPw= 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: List-Subscribe: List-Unsubscribe: Switch to using shmem_get_folio and manually dirtying the page instead of abusing aops->write_begin and aops->write_end in xfile_get_page. This simplifies the code by not doing indirect calls of not actually exported interfaces that don't really fit the use case very well, and happens to get us large folio support for free. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 73 ++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index a669ebbbc02d1d..2b4819902b4cc3 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -183,11 +183,7 @@ xfile_store( loff_t pos) { struct inode *inode = file_inode(xf->file); - struct address_space *mapping = inode->i_mapping; - const struct address_space_operations *aops = mapping->a_ops; - struct page *page = NULL; unsigned int pflags; - int error = 0; if (count > MAX_RW_COUNT) return -ENOMEM; @@ -196,60 +192,45 @@ xfile_store( trace_xfile_store(xf, pos, count); + /* + * Increase the file size first so that shmem_get_folio(..., SGP_CACHE), + * actually allocates a folio instead of erroring out. + */ + if (pos + count > i_size_read(inode)) + i_size_write(inode, pos + count); + pflags = memalloc_nofs_save(); while (count > 0) { - void *fsdata = NULL; - void *p, *kaddr; + struct folio *folio; unsigned int len; - int ret; + unsigned int offset; - len = min_t(ssize_t, count, PAGE_SIZE - offset_in_page(pos)); - - /* - * We call write_begin directly here to avoid all the freezer - * protection lock-taking that happens in the normal path. - * shmem doesn't support fs freeze, but lockdep doesn't know - * that and will trip over that. - */ - error = aops->write_begin(NULL, mapping, pos, len, &page, - &fsdata); - if (error) { - error = -ENOMEM; + if (shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, + SGP_CACHE) < 0) break; - } - - /* - * xfile pages must never be mapped into userspace, so we skip - * the dcache flush. If the page is not uptodate, zero it - * before writing data. - */ - kaddr = page_address(page); - if (!PageUptodate(page)) { - memset(kaddr, 0, PAGE_SIZE); - SetPageUptodate(page); - } - p = kaddr + offset_in_page(pos); - memcpy(p, buf, len); - - ret = aops->write_end(NULL, mapping, pos, len, len, page, - fsdata); - if (ret < 0) { - error = -ENOMEM; + if (filemap_check_wb_err(inode->i_mapping, 0)) { + folio_unlock(folio); + folio_put(folio); break; } - if (ret != len) { - error = -ENOMEM; - break; - } + offset = offset_in_folio(folio, pos); + len = min_t(ssize_t, count, folio_size(folio) - offset); + memcpy(folio_address(folio) + offset, buf, len); + + folio_mark_dirty(folio); + folio_unlock(folio); + folio_put(folio); - count -= ret; - pos += ret; - buf += ret; + count -= len; + pos += len; + buf += len; } memalloc_nofs_restore(pflags); - return error; + if (count) + return -ENOMEM; + return 0; } /* Find the next written area in the xfile data for a given offset. */ From patchwork Mon Jan 29 14:34:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535773 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 EF619C47DB3 for ; Mon, 29 Jan 2024 14:36:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 851F96B00B4; Mon, 29 Jan 2024 09:36:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 80B3E6B00B5; Mon, 29 Jan 2024 09:36:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A35A6B00B6; Mon, 29 Jan 2024 09:36:03 -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 5722B6B00B4 for ; Mon, 29 Jan 2024 09:36:03 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3172016047E for ; Mon, 29 Jan 2024 14:36:03 +0000 (UTC) X-FDA: 81732598206.12.F901141 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf04.hostedemail.com (Postfix) with ESMTP id 876B340017 for ; Mon, 29 Jan 2024 14:36:01 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=xd4dyVir; spf=none (imf04.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538961; 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=3bl9Vn2yOyKHb24tVNHqKgoHaJ5sWqc0dgEDrV96FhM=; b=t/qtjmxwIBXJ9M8biKUhvLmb37NBvMGgCrdZmb1VnJal8xWtKVl3HC+7Icw5CMgYBOLYNE P8nGA9lnJfgEhBcOFLLx/ErLAjc1e7Qnb3+T3KwV/uh8jdyD0FMz7fm6Iafn0lh+jLgpWU ra6CfG9vseLpKs4Ng0sys+DwjdkuEOU= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=xd4dyVir; spf=none (imf04.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538961; a=rsa-sha256; cv=none; b=Xd6p4oyKrXAO/8Sku4/M9QYCQ8IIYcOCTiV9QTpAh9FLD7OKsyo/WGPI7LequMqvLhYIQM cOheN0UcG4HZt3jZhodx73EIhnRDDFx8zZpQWSyDi4h2qYvH9nnLGYEb40jsG19mpr9NNf g7Jcg2sFIl/pR+0Q9mZ77Pd1BHH7JN0= 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=3bl9Vn2yOyKHb24tVNHqKgoHaJ5sWqc0dgEDrV96FhM=; b=xd4dyVir7JMUrm1jb9NZE9GgiO tdiEXqjRTLQoFC1KU3rmyQeK8lKBa/w7bbKGzeZuFsG4IApi8pnzm+nFnLvYUdLkPVgK6NWDxp5B+ YPABBsW/JNftl/Hd6sn9zwpZ6uSgC/Sq3Py+OnYLYEdVdW/OBryAYG3Oc5URqlBe0lTECzwna+bQY ejhdJuVVpcMZ93ewqWYBT+Dj97w1Oc9ihWNJ1RJPbaCLMrcWmjE8ZP7ynq98reE4jRWI4LPh0GWmh /KUpAOCpF5MJRMsnD261C+fQdiJvWD932ekEZmquQzujHqTLs59C4bFNCGVbGYDIs3yJcuLqTARpa fDwI9xng==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjt-0000000D6Os-3AWh; Mon, 29 Jan 2024 14:35:59 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 15/20] xfs: use shmem_get_folio in in xfile_load Date: Mon, 29 Jan 2024 15:34:57 +0100 Message-Id: <20240129143502.189370-16-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: 876B340017 X-Rspam-User: X-Stat-Signature: 3ief1okebyz9hpmd81shxcjh1gm98ite X-Rspamd-Server: rspam01 X-HE-Tag: 1706538961-642591 X-HE-Meta: U2FsdGVkX18hEzYq4PPJxfyzEA5MIPoJNpODKBY4qUL4FcTvRh496SB2WdZKCiyhjX3ZDd8bxhetCZr+fw8NKbIMBfGbkCFfE2PQQVCuwyYIINaT6jHOw+yvusdxEEY//VXuKCuLr9cyenzRPPZy+H/z5X3ygtxzv1mGV3NW0QxMQW6ZQQNYpwGRgg1+tEWmL28V65F8CNpcxfUs0QtQpAMLzFdBAwoF+PHL8INhtjMvPDMZ0m9fpNBlJk5NJCCWKjJb4cTSGJD2gmc7AJQOdLd/FlqC5N422tuZgebmojgFo8CaY4FFLsy4P9UCRhx84+ydLe2KzdGTSDWzZ1qJgVR1GD13z7aHSi7o8NIVuThSTZw75pMkU8mn1Iye3jFuthsxipE50J0kNB1DQhjQTbaO/j2xSFZx3TTsXA7ldLAcuMsTCnsnSQ/NgWoOwnl0vNPqmisdPHsZj+UQqcUX0Z0CPY+ozTUXWCi0hLHpQH3MhDTMgtx00rK9MHSQOBfWGJ7pBsnFQ7Zj6bw6Mjv5mr7GzPpPsbSjIRDyZBLck7eaVAUeHnOreBh+epJ1HMEr21Yp9M+s9yQNlTBlK/ewaloI1GXaLKzN09Zq2lTgwvgDHML5x2IXUYuYfdkEt5rHQDZhnbg9dpaa+i1y684XW8e2sH1ziLFww8LM8pZDmapt2OFybMj0/wO8pu4nmeREuCEG1T2JMhT+rvJAt69eueMbY1azRACbZk4/3kSlKY+wMNl8Lmn1zB096+CWRudI4Bm99WI2q0W5STz9fZw/K6b8RD47VF/yoir23fiMAELiawY9z6sP0VT4XCrlvQUQvgGPQgTLCJxRva/Kgj7D1XpcdLEnJVQNQhiOVaXx2xuDhrz8PFEoczskRLxUOQm/3HtVqUqMNomMGfjQr3/zBm4x4+AeOhTjd2hsF0Dv9NbGDfh6RJdTRi0oriVWoyuF1BbOTwNYbgog9VXLmuj 6DS8YNXI 4yZbbRlvPoqbyILvfBzaEcQM+q8c0lvx8kOxLUuqtefuQSZWL7qV6kQ2rv2+9mfvQhB7+zblglrxRwkvKf2Kd/HRnbrM+XvXSte1nOPzlcYUSCxbPU9VWReDEWlBVGjYsFD+VYLxINu58zkmDU3RtuB44cKynfk191g5hT94x3D/I5eQDrF4XhVV1KDTXEa+YftwsGFDxis5OoEN6TyW1BTZ1XmH5Cf6wtkHJxoiqbpPGKckZOW4XsuTWEOF+F1jC5kHDPk8mrrZa4QODwgaSibyxmCwLQRRTGJGxrdjLfG2whCbhRF/4CM4O/IAHBnhvLjiEwhfaZZLINJYUyxo9rQ5xJ9fdwTIU/2QMju0VJ9CPwBlc66mp7hf4dG97lP1DPmsbu/mIq4dz/XZhwhFsVWzKtkxuc29CeJQqXVeAu37MRqEnyQkIfgllVpQslQ+hX0LXzDzWPzSGC68iFv97ZB8WsUGGrcDqoDHl2yxjqRYme51d9LOaXdy6GN3tWA5kF7oNRw+cExZdeWzeXDL9bl/OTQXSSi2P1Jj1WWqz2Q0sG5U= 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: List-Subscribe: List-Unsubscribe: Switch to using shmem_get_folio in xfile_load instead of using shmem_read_mapping_page_gfp. This gets us support for large folios and also optimized reading from unallocated space, as shmem_get_folio with SGP_READ won't allocate a page for them just to zero the content. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 61 +++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 2b4819902b4cc3..c524fe9980fea2 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -34,13 +34,6 @@ * xfiles assume that the caller will handle all required concurrency * management; standard vfs locks (freezer and inode) are not taken. Reads * and writes are satisfied directly from the page cache. - * - * NOTE: The current shmemfs implementation has a quirk that in-kernel reads - * of a hole cause a page to be mapped into the file. If you are going to - * create a sparse xfile, please be careful about reading from uninitialized - * parts of the file. These pages are !Uptodate and will eventually be - * reclaimed if not written, but in the short term this boosts memory - * consumption. */ /* @@ -118,10 +111,7 @@ xfile_load( loff_t pos) { struct inode *inode = file_inode(xf->file); - struct address_space *mapping = inode->i_mapping; - struct page *page = NULL; unsigned int pflags; - int error = 0; if (count > MAX_RW_COUNT) return -ENOMEM; @@ -132,43 +122,44 @@ xfile_load( pflags = memalloc_nofs_save(); while (count > 0) { + struct folio *folio; unsigned int len; + unsigned int offset; - len = min_t(ssize_t, count, PAGE_SIZE - offset_in_page(pos)); - - /* - * In-kernel reads of a shmem file cause it to allocate a page - * if the mapping shows a hole. Therefore, if we hit ENOMEM - * we can continue by zeroing the caller's buffer. - */ - page = shmem_read_mapping_page_gfp(mapping, pos >> PAGE_SHIFT, - __GFP_NOWARN); - if (IS_ERR(page)) { - error = PTR_ERR(page); - if (error != -ENOMEM) { - error = -ENOMEM; + if (shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, + SGP_READ) < 0) + break; + if (!folio) { + /* + * No data stored at this offset, just zero the output + * buffer until the next page boundary. + */ + len = min_t(ssize_t, count, + PAGE_SIZE - offset_in_page(pos)); + memset(buf, 0, len); + } else { + if (filemap_check_wb_err(inode->i_mapping, 0)) { + folio_unlock(folio); + folio_put(folio); break; } - memset(buf, 0, len); - goto advance; - } - - /* - * xfile pages must never be mapped into userspace, so - * we skip the dcache flush. - */ - memcpy(buf, page_address(page) + offset_in_page(pos), len); - put_page(page); + offset = offset_in_folio(folio, pos); + len = min_t(ssize_t, count, folio_size(folio) - offset); + memcpy(buf, folio_address(folio) + offset, len); -advance: + folio_unlock(folio); + folio_put(folio); + } count -= len; pos += len; buf += len; } memalloc_nofs_restore(pflags); - return error; + if (count) + return -ENOMEM; + return 0; } /* From patchwork Mon Jan 29 14:34:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535774 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 40A51C47DB3 for ; Mon, 29 Jan 2024 14:36:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C98746B00B5; Mon, 29 Jan 2024 09:36:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C20966B00B6; Mon, 29 Jan 2024 09:36:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC1C76B00B7; Mon, 29 Jan 2024 09:36:07 -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 9A6856B00B5 for ; Mon, 29 Jan 2024 09:36:07 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 31ADB120A6D for ; Mon, 29 Jan 2024 14:36:07 +0000 (UTC) X-FDA: 81732598374.01.3257AA3 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP id 64981C000B for ; Mon, 29 Jan 2024 14:36:05 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Bw1EYdds; spf=none (imf28.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538965; 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=300P4uyDHmiPq/TQ4ACZID3NFloQxMDWfXSAQlSY+eU=; b=oBMQZ+iII1AGThrMcAS1KxB/KQ73kkuXZzAQpHYi7XOBT1wTRiPzuA+clI0bo0DWx3mmwR khWfKZ7pZKGFpnBWTWBQa7sy7SdY0uWZAALCabZf9gLvAJRyjIbary561aD0rDrEdB3drr NnBEmNqBZkLvUWMUS4AVGg0fgf5ls44= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Bw1EYdds; spf=none (imf28.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538965; a=rsa-sha256; cv=none; b=51XSABkcSPe8mZHO1xjkel8lfFUevIEhtG+5Rrr6jJ2+qKTeLn60arLUEEUsj6hH/WgaO2 Hw2MCzyrWA/VWWMr7/uLi8dnnq8i7GGCrpcOoEreZWns+ayquSZeYA840ODKzVUQyxTR4B ydE+r0NAJJH1xueEoMTHh5pVlXXBPfE= 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=300P4uyDHmiPq/TQ4ACZID3NFloQxMDWfXSAQlSY+eU=; b=Bw1EYddsW8/Mygrlz56D6ktsTH /m6UmApFgB8SnEq4aDqghmvIxzT+pIr0N18gYQFFT/NAXEi1ZgBtaOpVnZe8eBwMvTLmhm1R4mcHD 7rK+602m/uzTrrRR7rk3rqah1NXeT/Y8e/HHX0Hf/4FBBG7vpHoqVEm4nRNv9GAiVmwggUE8a0PJs QIcO8eFMf6KcNrVQxEOwJ5K3fHX2TUpGnS2z78zFBYFjzkSlM6A3nYgFH/ig8ECCxwLdxeP9k3ory zWK6JWf0ROZlBSV1EVwsBOIHfq2LGPY3caSJqiUyBKg3zhohaepJef8sqe6I3HPZrzKVQaQyx2+c/ 0na/UZPA==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjx-0000000D6Qk-4BXT; Mon, 29 Jan 2024 14:36:02 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, Kent Overstreet Subject: [PATCH 16/20] xfs: add file_{get,put}_folio Date: Mon, 29 Jan 2024 15:34:58 +0100 Message-Id: <20240129143502.189370-17-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: 64981C000B X-Rspam-User: X-Stat-Signature: 9gc8sm1if4w4x4ou13rzen9mqy3u4znc X-Rspamd-Server: rspam01 X-HE-Tag: 1706538965-812400 X-HE-Meta: U2FsdGVkX1+Zx/vsu5oxo8aJrkmFk/3HW1wifGOYuu5FqEgYGw30ExJeVY7VyfXW6NXjaLVoSKfeBgq5ElCl902lEh8A8zxwcbGPyQGVtvozriauO797PweVuYx6Y1pvuJ8EbFw3MPlWilJH6uc/JzQtfhcgiadD82ofYym32Z4c3TmvOWLnLYIqsFs3JHQlappBoveThW/YG7GXvUv2TTEWqxoAchTEJscZBbPRa32TdCxD8RCMgpw3P8zsWU1l46M3+gDO9EhXIi9sLLh1RQo0qQk2rjoPzLb49Ax6LtfuXcsL/V3cUKnoUd0yFQLWZCvvM5TVG+heLuZp9UQMIByqwKZAgRlfqMR2yVbYZH2I4wGjgljWr/QHr33lxvW2bFBVSuAOD90CkZ92VRz29288dEoSNzqGKKQM5lXDmyEzlFq/qJ5tsJhxrJCa8FTYqZWOwAdPS9HXdXGczDFsUWenbFc7N9RsR/9ToB5zWLYTtxYnYTUFKnp3Pu5EY9ZpJ4W4r7VShW4mmJiG8joRrdNHiODpWrGKd+eoroaIEfoPA2QLnxjZtdRsk0TiYArSJ3pjgr8LmszEVy2LoU5tlAqErMmEvnMPm9ZG6rBsZaoLubSHVlKIfMNSA5okz41uLDxrSYeIfbbtuoSdtI4jAy8pxvqF77WTOB4vX70iN0J6+fP+GVaK8DJjjrrWsNun54RRx0V7Qcxy8wkGF0oMaAHBWtGTAkd7ZH5XU3lVob/IiJVz8nwcD4v416urW+46H4RNZh7Aj60wsP+Yty24tbT4iTk9v8wP85U3NkYsBtMaUCaGOsn6BxkJdJni+XQb8t659PCd/5m1gOohIzf12fq1ij8K+Y9Yl2oNn6rrctoYUPiD9ZXkEVs4ewyiOz1D+iphcbYwgX6kMdWET2fyl57zFBkf4UP0hTxOKy74V2eSwOtQOIU/5MeLhwJfSfOeCnTA3AhVthX5OT3Te9A vRA1v30J iNskzWCbECmtFT478H5nhZ8298so+BYUtJz1iWfiYYkb6uN4xgCav/W/dS4auNvddXBg3umlIdGyEMGut92w8yV1bymLdOH8qZu+++vAYdeA/qR12PG16vqDlWW2SXZyyfCuY2/Qmu5o/uy8WEgOOJ97A75l+wvH2qsWjPkpTi5HQ0z/N65mvHecDpP3dwGR0+wsVHJVfCNuN8elc6nCCaXkapqAq213i49y3eyRblex55ZXPYcovkOecf+epW2N924FczlZV3fOluveDgyjZgrrLojwOqNIYjlao3A7ryFgvXMtA14L+VUT2xFm25tgH17L0K+xCUIbXpPoUY+HQZbY0VOV710caH/HJpkFswIlUKJBMNJstZMVcSBGwNVTQD4JC24RA8Tg03OYMXbA01vPArGAr7+tcVE9b6WNganuOPgoWT33kk94FU79H+R2tfthMgpoheEePpFdEQqU2IoEfuuHHkw8ka9K3DhRkDVKYmVxPac2L6qcUWXNOW3kgFRqI2GmsjVDPgL8= 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: List-Subscribe: List-Unsubscribe: From: "Darrick J. Wong" Add helper similar to file_{get,set}_page, but which deal with folios and don't allocate new folio unless explicitly asked to, which map to shmem_get_folio instead of calling into the aops. Signed-off-by: Darrick J. Wong Signed-off-by: Christoph Hellwig Reviewed-by: Kent Overstreet --- fs/xfs/scrub/trace.h | 2 ++ fs/xfs/scrub/xfile.c | 74 ++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/scrub/xfile.h | 7 +++++ 3 files changed, 83 insertions(+) diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index 0327cab606b070..c61fa7a95ef522 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -908,6 +908,8 @@ DEFINE_XFILE_EVENT(xfile_store); DEFINE_XFILE_EVENT(xfile_seek_data); DEFINE_XFILE_EVENT(xfile_get_page); DEFINE_XFILE_EVENT(xfile_put_page); +DEFINE_XFILE_EVENT(xfile_get_folio); +DEFINE_XFILE_EVENT(xfile_put_folio); TRACE_EVENT(xfarray_create, TP_PROTO(struct xfarray *xfa, unsigned long long required_capacity), diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index c524fe9980fea2..2d59407909de35 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -340,3 +340,77 @@ xfile_put_page( return -EIO; return 0; } + +/* + * Grab the (locked) folio for a memory object. The object cannot span a folio + * boundary. Returns the locked folio if successful, NULL if there was no + * folio or it didn't cover the range requested, or an ERR_PTR on failure. + */ +struct folio * +xfile_get_folio( + struct xfile *xf, + loff_t pos, + size_t len, + unsigned int flags) +{ + struct inode *inode = file_inode(xf->file); + struct folio *folio = NULL; + unsigned int pflags; + int error; + + if (inode->i_sb->s_maxbytes - pos < len) + return ERR_PTR(-ENOMEM); + + trace_xfile_get_folio(xf, pos, len); + + /* + * Increase the file size first so that shmem_get_folio(..., SGP_CACHE), + * actually allocates a folio instead of erroring out. + */ + if ((flags & XFILE_ALLOC) && pos + len > i_size_read(inode)) + i_size_write(inode, pos + len); + + pflags = memalloc_nofs_save(); + error = shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, + (flags & XFILE_ALLOC) ? SGP_CACHE : SGP_READ); + memalloc_nofs_restore(pflags); + if (error) + return ERR_PTR(error); + + if (!folio) + return NULL; + + if (len > folio_size(folio) - offset_in_folio(folio, pos)) { + folio_unlock(folio); + folio_put(folio); + return NULL; + } + + if (filemap_check_wb_err(inode->i_mapping, 0)) { + folio_unlock(folio); + folio_put(folio); + return ERR_PTR(-EIO); + } + + /* + * Mark the folio dirty so that it won't be reclaimed once we drop the + * (potentially last) reference in xfile_put_folio. + */ + if (flags & XFILE_ALLOC) + folio_set_dirty(folio); + return folio; +} + +/* + * Release the (locked) folio for a memory object. + */ +void +xfile_put_folio( + struct xfile *xf, + struct folio *folio) +{ + trace_xfile_put_folio(xf, folio_pos(folio), folio_size(folio)); + + folio_unlock(folio); + folio_put(folio); +} diff --git a/fs/xfs/scrub/xfile.h b/fs/xfs/scrub/xfile.h index 465b10f492b66d..afb75e9fbaf265 100644 --- a/fs/xfs/scrub/xfile.h +++ b/fs/xfs/scrub/xfile.h @@ -39,4 +39,11 @@ int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len, struct xfile_page *xbuf); int xfile_put_page(struct xfile *xf, struct xfile_page *xbuf); +#define XFILE_MAX_FOLIO_SIZE (PAGE_SIZE << MAX_PAGECACHE_ORDER) + +#define XFILE_ALLOC (1 << 0) /* allocate folio if not present */ +struct folio *xfile_get_folio(struct xfile *xf, loff_t offset, size_t len, + unsigned int flags); +void xfile_put_folio(struct xfile *xf, struct folio *folio); + #endif /* __XFS_SCRUB_XFILE_H__ */ From patchwork Mon Jan 29 14:34:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535775 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 271E4C47DB3 for ; Mon, 29 Jan 2024 14:36:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC2FC6B00B6; Mon, 29 Jan 2024 09:36:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A251F6B00B7; Mon, 29 Jan 2024 09:36:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89F136B00B8; Mon, 29 Jan 2024 09:36:10 -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 6F6636B00B6 for ; Mon, 29 Jan 2024 09:36:10 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 534B51C1385 for ; Mon, 29 Jan 2024 14:36:10 +0000 (UTC) X-FDA: 81732598500.29.3CE87F3 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf16.hostedemail.com (Postfix) with ESMTP id B841E18000B for ; Mon, 29 Jan 2024 14:36:08 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=idRwDPMa; spf=none (imf16.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538968; 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=3S6ntfnJ/Mttd+t3+rSdcxM6Jo8r6DNkjdxq43w+JDI=; b=Wm7xa7r96NKU+d31cp71y/dKgMjfuX7LN3YMyGLJ91O8R8c8iLkWrkiEa9FViEQcks0ywk +s7Bk/FaVyCihcod8xqh5DluNeLIf0zpJuzQKv36/Djn+Ec2lj/8eqsfFitjhy46D5jiPE 801ZdX1fNngBtKcJWkoJJsY5zDoNt2w= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=idRwDPMa; spf=none (imf16.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538968; a=rsa-sha256; cv=none; b=SreU8+oM4XbQnWWt++Pk7bbcal3fBfBCkANOAdrMb6Y24t/U4OyH4177XFGv0bzkBeI34u UUwiRv28Iu4B8NCzbTXHaK9Grt8OoI0P4XLoEaa5rp3dVWlZINvpEx3ybkgVuLwrv50lXN P8bOwHN63ci46U4iZXCYmc1Xtvxh668= 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=3S6ntfnJ/Mttd+t3+rSdcxM6Jo8r6DNkjdxq43w+JDI=; b=idRwDPMa/1mhc9knuQ1IMinnMU FQ3aK7oA+CoznHpL0Jce9W0VvBSgvpkoQjTRd9YgVzH8tznUPJPk5UJ+d3hs+TpZHUJ1Vi8MHRyAf xC5qTXDOeLWREkbhCSTf9TUNrFiS0Tepw3S0hyRiVKjJSCTktzcgC3rkCMQppM/HCwWgBmmj0fSq0 zxlHGNyDrXaDJoohXROVEUNgqsTvTAPKrSw42OmG6ufUK3I6BrWYHnxrOG6/BMvhfEfag/r3m6TtZ V97ZjDXOeh8GSqGXZPbrzELNV0MtxRB/wWaedYOU8DZN+tfhcI6cNR/68N9PmGBeFf3lewxk8m10i P80WKlQw==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSk2-0000000D6S6-0A7O; Mon, 29 Jan 2024 14:36:06 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 17/20] xfs: remove xfarray_sortinfo.page_kaddr Date: Mon, 29 Jan 2024 15:34:59 +0100 Message-Id: <20240129143502.189370-18-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: B841E18000B X-Rspam-User: X-Stat-Signature: g4smwtncmh4uhnmhuhabbr3i5x3xmfys X-Rspamd-Server: rspam01 X-HE-Tag: 1706538968-980041 X-HE-Meta: U2FsdGVkX19cYiF/D5nGSLRpFYMXkvsSy/uasCRERABWAuisg05rktoazZCsRPuUe4PFqdkhtz8UW0Gmn1JT0tnzgTOgOlEDIx8zWjhgFIBXA+7TTWGHSZCp6Re7D68nHNA8l3X7rSt4BYamsvU29ge9TD6I9+rJ0rT5WFC/6+IPR02e94aBRiqZVWNB4m8XIxX5DyfjBi637drmhezvFOb6U5VXrm5lrZyTrfT3Ij1EX+tVCOPiODpC3Q1NPfOdisng1xzSmmtI9vU/CJagzUZkG5bfYxXxS+IXD/S+qoPqTnPOzG0eHOYZFHNnp+7cHjJzS7BlfcvMC5UzmMB+qJdToDeK09aQx8XBVEeuInPwAfgtHARMHNOMdLjZQV6YEtpQFEe9Z+bIrpgzAAXIXx4meaxSPjjD7HqPb9J+RssykJ2dOkbxoX4MucAVgp7KN2R46FQUuW+2/UU4KhKkQ1ETUrLb9KNDHXAUI+3UXBR6Ry1CFQ9VdYWdkUztRJi/QsDE9p8GpIY75u4ckTkaHoW04ivm6W1IB9ga+6/lKcsGpay/ViT8ZsmagPQY4Z9P77s3pBofEztvqqzbK4F22IEU53W6a0exuR5CZ7e6Dm4oeZwQUk3+6MKE1clMVDC3Y1bRtC0Xr2kWecgC0n5IP3Pch/nUoLt0U70GluaX7cWq0A9YyyTdIT8RBB2t6PBDmvFSe4G+L1SA9I7x18qrNdKqRRXlHPBSgzYxvc5M5WurHLarwj+7EPmSHi515zQb0hQnxbje20OAylF3TtSY5pYNud1nabE9gCc7nw8/JyZOoy/1b4bHrRsJDR/y9jmJ62HUNl8IgyCfGvz8oErDEFOo/+WYiXVEAhYmInsxWOm+67X/oL4yXlEt6BnrfLHfq2LWUfnKGazp/GMwSA8jdREEwmSewNhx7jwyGGBvYXG2lCrrq04AtlmzNhEcVpbNXvm3rqBiylBIxoph/xH SuVaCFnJ pTs90FU54FgVy11FGQ5SMcVV2AmHnlWSX65wWS0mgCdRqzXoBfqBHOuYf/YzK/6/hb1o0llcxVTEnQRDigYNqD+/Ag1Cmj0eGBF0+gw/OvWopo90+Asf1XfyOKNxnZCklkJtnX1z6PO51dwBKuC64a9+2oFAvdUJCB94SPWqEPBoIzVSZ9e0GYQMZcjXisUBdohlm1xqIFzYHxQ1sv2qJiJQ9d31zpyHPoFFbnWVRmlWIEPk1iHzxkBC84FadiAvr+AIhsT0fB5h6XEcPBygBHEWovWiNSSB4Sor1rUrInQ4Pmu36yZEdLcEjQ6QiKq3ePOvxR8n8QYM8maXv1FNUA2yV1sjFdfaZ2a7xWF/gAw7jWMFrRKjXGGO90YhZpXazrmQxu9RqZcmdFS32l9sSAJAIcwUkcSxB9WoJLhUKYmjsn1bKXxMV9IE9BukVBQJsOSm6QeTqX9OW9nBlSTlFdCQLxvuIGaZ+909xt3suUC3EYp4+yDNq5QFK32By2u6d0QrI+nLJg3UWnuA= 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: List-Subscribe: List-Unsubscribe: Now that xfile pages don't need kmapping, there is no need to cache the kernel virtual address for them. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfarray.c | 22 ++++------------------ fs/xfs/scrub/xfarray.h | 1 - 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index d0f98a43b2ba0a..82b2a35a8e8630 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -570,18 +570,7 @@ xfarray_sort_get_page( loff_t pos, uint64_t len) { - int error; - - error = xfile_get_page(si->array->xfile, pos, len, &si->xfpage); - if (error) - return error; - - /* - * xfile pages must never be mapped into userspace, so we skip the - * dcache flush when mapping the page. - */ - si->page_kaddr = page_address(si->xfpage.page); - return 0; + return xfile_get_page(si->array->xfile, pos, len, &si->xfpage); } /* Release a page we grabbed for sorting records. */ @@ -589,11 +578,8 @@ static inline int xfarray_sort_put_page( struct xfarray_sortinfo *si) { - if (!si->page_kaddr) + if (!xfile_page_cached(&si->xfpage)) return 0; - - si->page_kaddr = NULL; - return xfile_put_page(si->array->xfile, &si->xfpage); } @@ -636,7 +622,7 @@ xfarray_pagesort( return error; xfarray_sort_bump_heapsorts(si); - startp = si->page_kaddr + offset_in_page(lo_pos); + startp = page_address(si->xfpage.page) + offset_in_page(lo_pos); sort(startp, hi - lo + 1, si->array->obj_size, si->cmp_fn, NULL); xfarray_sort_bump_stores(si); @@ -883,7 +869,7 @@ xfarray_sort_load_cached( return error; } - memcpy(ptr, si->page_kaddr + offset_in_page(idx_pos), + memcpy(ptr, page_address(si->xfpage.page) + offset_in_page(idx_pos), si->array->obj_size); return 0; } diff --git a/fs/xfs/scrub/xfarray.h b/fs/xfs/scrub/xfarray.h index 62b9c506fdd1b7..6f2862054e194d 100644 --- a/fs/xfs/scrub/xfarray.h +++ b/fs/xfs/scrub/xfarray.h @@ -107,7 +107,6 @@ struct xfarray_sortinfo { /* Cache a page here for faster access. */ struct xfile_page xfpage; - void *page_kaddr; #ifdef DEBUG /* Performance statistics. */ From patchwork Mon Jan 29 14:35:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535776 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 A0FFDC47DB3 for ; Mon, 29 Jan 2024 14:36:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 370176B00B7; Mon, 29 Jan 2024 09:36:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F9D86B00B8; Mon, 29 Jan 2024 09:36:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C1056B00B9; Mon, 29 Jan 2024 09:36:15 -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 0986E6B00B7 for ; Mon, 29 Jan 2024 09:36:15 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D5FA040A4B for ; Mon, 29 Jan 2024 14:36:14 +0000 (UTC) X-FDA: 81732598668.13.FBA0616 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf12.hostedemail.com (Postfix) with ESMTP id 3F16640007 for ; Mon, 29 Jan 2024 14:36:13 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="H/w7piGv"; spf=none (imf12.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538973; 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=YwCZytasSWWNAnywFhe0IpFtb/e1jDVoRPLD3Ievb94=; b=3XZERUJF2A7q4I0IFS+7Wl4hRAyBGwSJrWbcfUH70E21aEAj6INtav+XH1Z2ctiswgnBMC MmqxthPltxVHEpNWSjW/WD1fLYMcE+6g1j36uO0lPoRsxYHi3OqOhnIUIwFds1xWBiWq4l 0IbFzCfnBGXHr8Pa9IArvVmPRkFTZeY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538973; a=rsa-sha256; cv=none; b=UdyydW/JYUuWf2X3mHyhda3y6+tkcazdYVWCrNr9j6dNOoOUdu0O0A0vmVCuTjCSMLj+Lv +CBRw7hhmc2AUS4hVpr+4dxLGR0uTqSrEPTKtbv5o4ed6UJyCJ7Gx0gyERDpXr4PEOWZ/3 +b4hZJRb+NfpvOhyO4JhYKd0AQMmpEA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="H/w7piGv"; spf=none (imf12.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=YwCZytasSWWNAnywFhe0IpFtb/e1jDVoRPLD3Ievb94=; b=H/w7piGvmYseCZoWnQEN2+gOYS XZVy8VGbsjSpOcptgQ9Nw46YbyoaBxmNjyE84HM/zN50XLYgWgF/zrWsufaNowCMgFdk328RfMq3E 1slTlgqkWFcoH2xJz3xsu9NzaVqiZHHFOb0yoywx+9lDmFt/lenGK8Xa4lf36tfDxc/xdrfsfC8KJ +H6byuh/5Dby/A+jD8Qa/sKrmP+yulLhguSZDh7HVAGxkt2g1/j6xyljvjGFx9pT9RKP8yAv0JrGz xZQg8E5bKKjEmg2d4RW3fidBKf3ab4LPmc6xsHF7JlXcTr+lj4auWsaXaBEqDuPRPLxhcEkERyHRC /gWJedDg==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSk5-0000000D6TV-3DzW; Mon, 29 Jan 2024 14:36:10 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 18/20] xfs: fix a comment in xfarray.c Date: Mon, 29 Jan 2024 15:35:00 +0100 Message-Id: <20240129143502.189370-19-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: 3F16640007 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: xhhzhbwb1feai8wrbzxer1j3sj5mhmtd X-HE-Tag: 1706538973-655971 X-HE-Meta: U2FsdGVkX180/qlZi5f0JcS3qz7sk7SHOJXTHACDJ0v+GCDXbjFh37/gaU3xv3McHVpkAiTnLTqXt1vna7yo383r/Ac8fRKUM0T0cxHfK2HiWoJf1npwDGxhR4A1SbOw6u25wMjrMjhcD20WdbWAptlHJZdTjuHjl7KY+eblO2J2E3Usgdjtk8IEegyjFfDCq5Oi/R3axQxfqf4krpILfW1fwtBPR4lj9Z+XNKDpD+qlIKfZ7DmENUH7HKlu3mSaNkILiVTZ1Gq5fkcTTIH5Y9yRUynA5b0pC9n4BEuAjuM9iPi287h2W7S4tO++cV94Y49kxmWjTa2RmgRf30GdBKLAQF0KsDlkk+puQdDan6gFzeyyBCqNgtl1fCs+aXw61m230HEIxu78MQlWtsAV58ULx9X5or4Y5lNaQtsfKPMXbUjCQlbKk9lMwEy8RL4T3dtnho/ay/pRfxK/raF6m1wCtf5x+CXIhx5NkIF8xcYsmnyy6X1yvX08a/QoOTzybXowhuivtG4v/viH2x2d39aPK4t3Ud1Mfa6cj4W74w/7SX3ujxwHyQCQY9Wgzq3rFVyFYnIoSOAVwTdiTTwjd6C6arKq54FCf/0sUXlRhDgM67E+3jcxPotxVMTtUKPKzs9lZ4118DWFJZ0UAV1SSi9RfEo+mkK27Ezfe+Csm2XFP5JUpcbFWO4DbHIUvCjbn6wSg5nNWv8sVcVzdC/IL/VXywhM6q6pe4BmRm5wfFHUgocjestbZuZPxP9hBsbDkDoMdLHSPjAC88PvlY8PG88MMMFMDxEk1ysW8LysMJqhMidqmYRzygrEls4kbA2A4fMUFN+4C0ZSvavpfi8+AzpnT4iwYnRc/nqxKa/SMw+U9SanjrDMUJ+9rj064X1fOs6vNHCyQGXTYvujxMZYzlCnAhVsI+2Ca+Qri3a2tY0rWOao1aAbSeMPx/LqAYhQM0uGwKBUK20RO9sZdTO ECRI1uFI 19ktU/1VorG5ru6n37XE3bp1ZXBhLBPUoYtaDfDZmGyjqqBbJO8f0NEkQvvI8/LHCy1tjNlIGnSUmYDBGHOoLSl2rDIzkgsaBWfY+EOL2/84BBmj5yIbtilfIZ1V+iPB4FH5XW+PKVEkIG3JfBJeXNeWsjQcN+sUIKOW4QlsQtyrJtCufAz2+QwgknKZc/tR/Ldyj6+raIt5s2pD9K70D62B/ZVhzeu2O05iCZS3st7if48a6VwI7LANJxbbwCsEe5/2D4yBGj/BnfZ/+sTjWEpskaOq0DJbPUGOPE4x7fTSWYCamt9QLHgOHHy9elH54oJ0zV7eyrGZa6kpl7vqga5+mHQ/64f+QaSFzL9bh6eS3c1nkZ5MDAYGCxJiPvv06/fjEgrusOBa0iUGpK2oeSIitPJoXj5DLxKkPKsqchj88jARJjmRVOdeYp2rZp22qjX7hkkADmJpF/hnnQeNLO9joZbdrSEtVu0fBI+U5mPsIRwozg2zWvc48Dg== 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: List-Subscribe: List-Unsubscribe: xfiles are shmem files, not memfds. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfarray.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index 82b2a35a8e8630..379e1db22269c7 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -16,7 +16,7 @@ * Large Arrays of Fixed-Size Records * ================================== * - * This memory array uses an xfile (which itself is a memfd "file") to store + * This memory array uses an xfile (which itself is a shmem file) to store * large numbers of fixed-size records in memory that can be paged out. This * puts less stress on the memory reclaim algorithms during an online repair * because we don't have to pin so much memory. However, array access is less From patchwork Mon Jan 29 14:35:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535777 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 AEEABC47422 for ; Mon, 29 Jan 2024 14:36:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E50F6B00B8; Mon, 29 Jan 2024 09:36:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 36EE56B00B9; Mon, 29 Jan 2024 09:36:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E9646B00BA; Mon, 29 Jan 2024 09:36:19 -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 017596B00B8 for ; Mon, 29 Jan 2024 09:36:18 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A96E11C1381 for ; Mon, 29 Jan 2024 14:36:18 +0000 (UTC) X-FDA: 81732598836.08.549009C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf16.hostedemail.com (Postfix) with ESMTP id B394C180007 for ; Mon, 29 Jan 2024 14:36:16 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=mQXQwbS8; spf=none (imf16.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538976; 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=Qt5yyeGgZH/arpMlGGWn1M3p+M4NNVvZAq3nYJjy+lU=; b=ov7bRt5GM2qXH0eCKyg7e+Xf/HiJH8SNbNvINSpGie1SfziWi6Vjjgu3tVlkJM/gcbixMX 5hkeJo9WSKWzfTngDTNbar5k8W5vmoOeBt/TqVMdjwamWboEngAwCMHo7qENySs7esCJTP cogRQlsq9Cu/YS+TDHHFx51J7uEITgk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538976; a=rsa-sha256; cv=none; b=FlPqOQjfLoVUt230UNjbq1OhdiriiSbUBfdLu1uq+fd07vUyBKfjMdoOGwttrP0Zha6xuw Bht+ASlycP2noDCB3lIlIX0y+NOn3JRz2B4utRgTVsIcxLbef3u515Ugxnc5eMmQqLTlH4 2PWltpM3R0a/qYxOq1fM5bGa/IgYoSc= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=mQXQwbS8; spf=none (imf16.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=Qt5yyeGgZH/arpMlGGWn1M3p+M4NNVvZAq3nYJjy+lU=; b=mQXQwbS80ouB+FyyQsETaKNMyu dHVz+4B/1m5+ULvorUJcL/+PRs8Q/Y4tvelPKQvaGTNN0v42RjuYY8CSKVYv4fS8gyKnUN0SzOezL tLniUagDwIG8yfyv6mVGVchxiy98FkZPOiaZijQq+OGZYBlhdzy4YVN5gMw0XCwWtN0qxa8tb7lsR 77v7vNs3L74LQGw1dR/PiKTkTDdvZnGYXEOPhjGMZySoo483FEH3iRlGipZ1XKKWUXxDwAC+Efi9y Ab8lWx8nqVQtWXMj19dOhdw9u9fYWhQDtvgySEsB1KQnOGgX5FAt0TQuaZpYTGydO4J135RAyOBXE dywc+Ffw==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSk9-0000000D6Uf-0oRX; Mon, 29 Jan 2024 14:36:14 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, Kent Overstreet Subject: [PATCH 19/20] xfs: convert xfarray_pagesort to deal with large folios Date: Mon, 29 Jan 2024 15:35:01 +0100 Message-Id: <20240129143502.189370-20-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: B394C180007 X-Rspam-User: X-Stat-Signature: 6yg7jdeqqk4jw5tr7xiat9ictkmkoh91 X-Rspamd-Server: rspam03 X-HE-Tag: 1706538976-392355 X-HE-Meta: U2FsdGVkX1/n013PNhlkEFYas6FHXzB3FjoN0iddyqO0kROin0wUAB17Hh03A1nYqxeDxb4+k9MVVe1DWItLiKCuCYLQ9DI0aXDzZnzWlBQJ6jCciexetPYuVHm3taVH0BAWzVcxIieNzqKTfcrwtp3RQ9URqQBzmCy9mYqENckk4joFFZ9GY6rD0sli4PmqyG/W36g7n3W5g4Foad3K2iSWLscixVbV7fHp1SdiYVfcs8JUEJjBbUEzXD4JlFF/a2Kv7r6NSKeLOQQUIJQzNYqT2qaLbz0RGhjJJzQg3xo6Lbi3VfmdKFJtk5F8QhHKDTO4IbvrBr0DTHzsic4nqVPSXUpThdmzuW1FMftbcsk3mBSrmR3BcqEl9q9EtWo7AF0OilO5pQOWYpiXYi+RWzMzeg8UWpuzmFBiMj4BfM7ICHzPdx5fhp5M6f3G9qzvTgeT/v6v6A6cRw+VK6PT76hTdCyUAtxEdEDvTwBME4u6G47YgpxsAiQ5qzdFCC13t+BbNCXzf2K2MI1FgWrS5Ck05BMB6oTl40RQjrMTn35FPKkjl32YvA4xpDRzPcF8wJKlamtDd4wSj2c0roRqsJuHhLNRk21m6BrM03fd1SfwYlQOiohVR1vcnlEEwZ3s861D3KsNW1wdImgH/mtR85Ean+ydPH7a3ELMILkFnAniK8J+Z3dMdw5/jANuRKP4SuUvZ4tyJYy8Jy50p6SQuVePJ/UUgWA6rUGl+RcYg5DZgJNk2MUW4tc27buRIjnfGYsl7Sa6MyUP75IYiIHZuTv4LqbPLV3rQL3c62XXPlpf8JcuOIbhYP9EYo7Ww27lHAsnbNkBtVjDdYPSNqCc1W8V4eN10GCwaRcMFfLe8go84/RJqKUYUmnPwG099YFNx0u7jd20vrxwlFBxs/XIl2mW2KpDIurAZchroy+lTR4sSq6hPY7c5j3hhXuoH+O+YZGd/FGt+nUdM/0w89C Vj8RwaGy qTDIVL3jZ4mXhXo5WnTNbAqQ3m6uWwkGK/b3uexzPtyCYpHra6edvSahjRg9gI69LrS0w+6ZrMhCWZmXQN6E6T4HYSQGNBZzrFZEn17vXY8kCszWSIETTt+PNoXDQbRY2jAV6F7LpnNJlvkNououyv7yb9Kh6e8TDHmLFZu6kKLZ2dme5c4wtuScj6bOQx0MqM7iLYc9QxvWP7X9TPGx4iPff0gfNY1pf6zIknSrP1L0nMiixQXJMZ3JC58L9P7JjfpgsyKBGgKThIdIXDNVeIMcbdpDEI94AZh8LiZS8Pf8BzXIRdubnZ/LUEQqMv4n5JsPFrQ661hlaEeHpEhpqNi+2ivz0KCSirr1H2wvtWDEDpr1qDycYMt+E77MFdM+SZcaA+z+K2LSrxLvBx+pf3LbGTRimtuwwazUM3HQeZv4cqKRS4u1XmEWDWHFjg2f3NNPNWl6MqwtZXxrletWIHdkVolikGgouyKE0JsUxx+3oFdpuXlct9HXZ3AO7fjanx/P51DXG4Vnj6ho= 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: List-Subscribe: List-Unsubscribe: From: "Darrick J. Wong" Convert xfarray_pagesort to handle large folios by introducing a new xfile_get_folio routine that can return a folio of arbitrary size, and using heapsort on the full folio. This also corrects an off-by-one bug in the calculation of len in xfarray_pagesort that was papered over by xfarray_want_pagesort. Signed-off-by: Darrick J. Wong Signed-off-by: Christoph Hellwig Reviewed-by: Kent Overstreet --- fs/xfs/scrub/trace.h | 43 ++++++++- fs/xfs/scrub/xfarray.c | 201 +++++++++++++++++++---------------------- fs/xfs/scrub/xfarray.h | 10 +- 3 files changed, 143 insertions(+), 111 deletions(-) diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index c61fa7a95ef522..3a1a827828dcb9 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -956,7 +956,7 @@ TRACE_EVENT(xfarray_isort, __entry->hi - __entry->lo) ); -TRACE_EVENT(xfarray_pagesort, +TRACE_EVENT(xfarray_foliosort, TP_PROTO(struct xfarray_sortinfo *si, uint64_t lo, uint64_t hi), TP_ARGS(si, lo, hi), TP_STRUCT__entry( @@ -1027,6 +1027,47 @@ TRACE_EVENT(xfarray_sort, __entry->bytes) ); +TRACE_EVENT(xfarray_sort_scan, + TP_PROTO(struct xfarray_sortinfo *si, unsigned long long idx), + TP_ARGS(si, idx), + TP_STRUCT__entry( + __field(unsigned long, ino) + __field(unsigned long long, nr) + __field(size_t, obj_size) + __field(unsigned long long, idx) + __field(unsigned long long, folio_pos) + __field(unsigned long, folio_bytes) + __field(unsigned long long, first_idx) + __field(unsigned long long, last_idx) + ), + TP_fast_assign( + __entry->nr = si->array->nr; + __entry->obj_size = si->array->obj_size; + __entry->ino = file_inode(si->array->xfile->file)->i_ino; + __entry->idx = idx; + if (si->folio) { + __entry->folio_pos = folio_pos(si->folio); + __entry->folio_bytes = folio_size(si->folio); + __entry->first_idx = si->first_folio_idx; + __entry->last_idx = si->last_folio_idx; + } else { + __entry->folio_pos = 0; + __entry->folio_bytes = 0; + __entry->first_idx = 0; + __entry->last_idx = 0; + } + ), + TP_printk("xfino 0x%lx nr %llu objsz %zu idx %llu folio_pos 0x%llx folio_bytes 0x%lx first_idx %llu last_idx %llu", + __entry->ino, + __entry->nr, + __entry->obj_size, + __entry->idx, + __entry->folio_pos, + __entry->folio_bytes, + __entry->first_idx, + __entry->last_idx) +); + TRACE_EVENT(xfarray_sort_stats, TP_PROTO(struct xfarray_sortinfo *si, int error), TP_ARGS(si, error), diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index 379e1db22269c7..17c982a4821d47 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -563,70 +563,42 @@ xfarray_isort( return xfile_store(si->array->xfile, scratch, len, lo_pos); } -/* Grab a page for sorting records. */ -static inline int -xfarray_sort_get_page( - struct xfarray_sortinfo *si, - loff_t pos, - uint64_t len) -{ - return xfile_get_page(si->array->xfile, pos, len, &si->xfpage); -} - -/* Release a page we grabbed for sorting records. */ -static inline int -xfarray_sort_put_page( - struct xfarray_sortinfo *si) -{ - if (!xfile_page_cached(&si->xfpage)) - return 0; - return xfile_put_page(si->array->xfile, &si->xfpage); -} - -/* Decide if these records are eligible for in-page sorting. */ -static inline bool -xfarray_want_pagesort( - struct xfarray_sortinfo *si, - xfarray_idx_t lo, - xfarray_idx_t hi) -{ - pgoff_t lo_page; - pgoff_t hi_page; - loff_t end_pos; - - /* We can only map one page at a time. */ - lo_page = xfarray_pos(si->array, lo) >> PAGE_SHIFT; - end_pos = xfarray_pos(si->array, hi) + si->array->obj_size - 1; - hi_page = end_pos >> PAGE_SHIFT; - - return lo_page == hi_page; -} - -/* Sort a bunch of records that all live in the same memory page. */ +/* + * Sort the records from lo to hi (inclusive) if they are all backed by the + * same memory folio. Returns 1 if it sorted, 0 if it did not, or a negative + * errno. + */ STATIC int -xfarray_pagesort( +xfarray_foliosort( struct xfarray_sortinfo *si, xfarray_idx_t lo, xfarray_idx_t hi) { + struct folio *folio; void *startp; loff_t lo_pos = xfarray_pos(si->array, lo); - uint64_t len = xfarray_pos(si->array, hi - lo); - int error = 0; + uint64_t len = xfarray_pos(si->array, hi - lo + 1); - trace_xfarray_pagesort(si, lo, hi); + /* No single folio could back this many records. */ + if (len > XFILE_MAX_FOLIO_SIZE) + return 0; xfarray_sort_bump_loads(si); - error = xfarray_sort_get_page(si, lo_pos, len); - if (error) - return error; + folio = xfile_get_folio(si->array->xfile, lo_pos, len, XFILE_ALLOC); + if (IS_ERR(folio)) + return PTR_ERR(folio); + if (!folio) + return 0; + + trace_xfarray_foliosort(si, lo, hi); xfarray_sort_bump_heapsorts(si); - startp = page_address(si->xfpage.page) + offset_in_page(lo_pos); + startp = folio_address(folio) + offset_in_folio(folio, lo_pos); sort(startp, hi - lo + 1, si->array->obj_size, si->cmp_fn, NULL); xfarray_sort_bump_stores(si); - return xfarray_sort_put_page(si); + xfile_put_folio(si->array->xfile, folio); + return 1; } /* Return a pointer to the xfarray pivot record within the sortinfo struct. */ @@ -814,63 +786,78 @@ xfarray_qsort_push( return 0; } +static inline void +xfarray_sort_scan_done( + struct xfarray_sortinfo *si) +{ + if (si->folio) + xfile_put_folio(si->array->xfile, si->folio); + si->folio = NULL; +} + /* - * Load an element from the array into the first scratchpad and cache the page, - * if possible. + * Cache the folio backing the start of the given array element. If the array + * element is contained entirely within the folio, return a pointer to the + * cached folio. Otherwise, load the element into the scratchpad and return a + * pointer to the scratchpad. */ static inline int -xfarray_sort_load_cached( +xfarray_sort_scan( struct xfarray_sortinfo *si, xfarray_idx_t idx, - void *ptr) + void **ptrp) { loff_t idx_pos = xfarray_pos(si->array, idx); - pgoff_t startpage; - pgoff_t endpage; int error = 0; - /* - * If this load would split a page, release the cached page, if any, - * and perform a traditional read. - */ - startpage = idx_pos >> PAGE_SHIFT; - endpage = (idx_pos + si->array->obj_size - 1) >> PAGE_SHIFT; - if (startpage != endpage) { - error = xfarray_sort_put_page(si); - if (error) - return error; + if (xfarray_sort_terminated(si, &error)) + return error; - if (xfarray_sort_terminated(si, &error)) - return error; + trace_xfarray_sort_scan(si, idx); - return xfile_load(si->array->xfile, ptr, - si->array->obj_size, idx_pos); - } + /* If the cached folio doesn't cover this index, release it. */ + if (si->folio && + (idx < si->first_folio_idx || idx > si->last_folio_idx)) + xfarray_sort_scan_done(si); - /* If the cached page is not the one we want, release it. */ - if (xfile_page_cached(&si->xfpage) && - xfile_page_index(&si->xfpage) != startpage) { - error = xfarray_sort_put_page(si); - if (error) - return error; + /* Grab the first folio that backs this array element. */ + if (!si->folio) { + loff_t next_pos; + + si->folio = xfile_get_folio(si->array->xfile, idx_pos, + si->array->obj_size, XFILE_ALLOC); + if (IS_ERR(si->folio)) + return PTR_ERR(si->folio); + + si->first_folio_idx = xfarray_idx(si->array, + folio_pos(si->folio) + si->array->obj_size - 1); + + next_pos = folio_pos(si->folio) + folio_size(si->folio); + si->last_folio_idx = xfarray_idx(si->array, next_pos - 1); + if (xfarray_pos(si->array, si->last_folio_idx + 1) > next_pos) + si->last_folio_idx--; + + trace_xfarray_sort_scan(si, idx); } /* - * If we don't have a cached page (and we know the load is contained - * in a single page) then grab it. + * If this folio still doesn't cover the desired element, it must cross + * a folio boundary. Read into the scratchpad and we're done. */ - if (!xfile_page_cached(&si->xfpage)) { - if (xfarray_sort_terminated(si, &error)) - return error; + if (idx < si->first_folio_idx || idx > si->last_folio_idx) { + void *temp = xfarray_scratch(si->array); - error = xfarray_sort_get_page(si, startpage << PAGE_SHIFT, - PAGE_SIZE); + error = xfile_load(si->array->xfile, temp, si->array->obj_size, + idx_pos); if (error) return error; + + *ptrp = temp; + return 0; } - memcpy(ptr, page_address(si->xfpage.page) + offset_in_page(idx_pos), - si->array->obj_size); + /* Otherwise return a pointer to the array element in the folio. */ + *ptrp = folio_address(si->folio) + offset_in_folio(si->folio, idx_pos); return 0; } @@ -937,6 +924,8 @@ xfarray_sort( pivot = xfarray_sortinfo_pivot(si); while (si->stack_depth >= 0) { + int ret; + lo = si_lo[si->stack_depth]; hi = si_hi[si->stack_depth]; @@ -949,13 +938,13 @@ xfarray_sort( } /* - * If directly mapping the page and sorting can solve our + * If directly mapping the folio and sorting can solve our * problems, we're done. */ - if (xfarray_want_pagesort(si, lo, hi)) { - error = xfarray_pagesort(si, lo, hi); - if (error) - goto out_free; + ret = xfarray_foliosort(si, lo, hi); + if (ret < 0) + goto out_free; + if (ret == 1) { si->stack_depth--; continue; } @@ -980,25 +969,24 @@ xfarray_sort( * than the pivot is on the right side of the range. */ while (lo < hi) { + void *p; + /* * Decrement hi until it finds an a[hi] less than the * pivot value. */ - error = xfarray_sort_load_cached(si, hi, scratch); + error = xfarray_sort_scan(si, hi, &p); if (error) goto out_free; - while (xfarray_sort_cmp(si, scratch, pivot) >= 0 && - lo < hi) { + while (xfarray_sort_cmp(si, p, pivot) >= 0 && lo < hi) { hi--; - error = xfarray_sort_load_cached(si, hi, - scratch); + error = xfarray_sort_scan(si, hi, &p); if (error) goto out_free; } - error = xfarray_sort_put_page(si); - if (error) - goto out_free; - + if (p != scratch) + memcpy(scratch, p, si->array->obj_size); + xfarray_sort_scan_done(si); if (xfarray_sort_terminated(si, &error)) goto out_free; @@ -1013,21 +1001,18 @@ xfarray_sort( * Increment lo until it finds an a[lo] greater than * the pivot value. */ - error = xfarray_sort_load_cached(si, lo, scratch); + error = xfarray_sort_scan(si, lo, &p); if (error) goto out_free; - while (xfarray_sort_cmp(si, scratch, pivot) <= 0 && - lo < hi) { + while (xfarray_sort_cmp(si, p, pivot) <= 0 && lo < hi) { lo++; - error = xfarray_sort_load_cached(si, lo, - scratch); + error = xfarray_sort_scan(si, lo, &p); if (error) goto out_free; } - error = xfarray_sort_put_page(si); - if (error) - goto out_free; - + if (p != scratch) + memcpy(scratch, p, si->array->obj_size); + xfarray_sort_scan_done(si); if (xfarray_sort_terminated(si, &error)) goto out_free; diff --git a/fs/xfs/scrub/xfarray.h b/fs/xfs/scrub/xfarray.h index 6f2862054e194d..ec643cc9fc1432 100644 --- a/fs/xfs/scrub/xfarray.h +++ b/fs/xfs/scrub/xfarray.h @@ -105,8 +105,14 @@ struct xfarray_sortinfo { /* XFARRAY_SORT_* flags; see below. */ unsigned int flags; - /* Cache a page here for faster access. */ - struct xfile_page xfpage; + /* Cache a folio here for faster scanning for pivots */ + struct folio *folio; + + /* First array index in folio that is completely readable */ + xfarray_idx_t first_folio_idx; + + /* Last array index in folio that is completely readable */ + xfarray_idx_t last_folio_idx; #ifdef DEBUG /* Performance statistics. */ From patchwork Mon Jan 29 14:35:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13535778 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 6BC26C47DDB for ; Mon, 29 Jan 2024 14:36:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E47866B00B9; Mon, 29 Jan 2024 09:36:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF6156B00BA; Mon, 29 Jan 2024 09:36:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6FCC6B00BB; Mon, 29 Jan 2024 09:36:21 -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 AA25D6B00B9 for ; Mon, 29 Jan 2024 09:36:21 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 83A351605FD for ; Mon, 29 Jan 2024 14:36:21 +0000 (UTC) X-FDA: 81732598962.11.341ECE4 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf02.hostedemail.com (Postfix) with ESMTP id E0F9780011 for ; Mon, 29 Jan 2024 14:36:19 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="f/msv54T"; dmarc=none; spf=none (imf02.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538979; 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=pgbpVNuRwaUD4tXc6IbA9e+Wt8cVjDsLgupaiw+W5Tk=; b=bbJnD2UGE3bPX0cfIA9tl3YmzV5UbDE3g1YZ0reg8gsAkInUXhCnlJ8Bg3WsUXxHTJG36f cLNjFT6d77ZhAJirn5BY/segV4SChczP8VEcISnQxl/tirgTFFDXO4XeARLdQtlj1NVy9N sEvcs/dESyC5LspmhPs+YzgoCf/SsJ0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="f/msv54T"; dmarc=none; spf=none (imf02.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538979; a=rsa-sha256; cv=none; b=cXTX1Rksnstnb4G+pH/usf2ikAjtjqZWWyHQm2EORdbeUd1Aoqk+kmDk3sgUWGhP+I1Mq1 O5XDTcHz/AEnAOOI+eb6GXb60Vzc7hrtqovI8H+s8vtn6qsetAzOGlIJjOAGi/Nf6+KF/f C+4iZK0JndM61SLgwPJrE6wiappTwuU= 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=pgbpVNuRwaUD4tXc6IbA9e+Wt8cVjDsLgupaiw+W5Tk=; b=f/msv54T7pjUtg5ttISpqiOyou O5+HtPFpcNRPhalltlzcDHCstXsZ6NlIMUDlCGZnBaGFmx8ctKoNntKinn0YZ5C5pGaoFBrv/mqJc gg0EjgJM6QoJ2c7VPWgLvazA20fPUD2IVzPqLV/5lCo+2qCy3ekNcNeb2u33VsD5huK7RqgGbXI4e eUoeEq1rsmpVqBMXaq2h+4tFxKZWVP2RF3KDqM9trwBf5XkI4NO0wNSz2KJgnwzPh7E4M9X1nDg9k 2v+Urq6/swKchmxfGSFaw8cNnu6lF2IgEKyrbuOXH2R5lxdcGjWrEXtbVw7oxPhyrHWyrmseaCYAJ lg6CKllw==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSkD-0000000D6Wd-0FuY; Mon, 29 Jan 2024 14:36:17 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 20/20] xfs: remove xfile_{get,put}_page Date: Mon, 29 Jan 2024 15:35:02 +0100 Message-Id: <20240129143502.189370-21-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: rspam09 X-Rspamd-Queue-Id: E0F9780011 X-Stat-Signature: 9egqwqyf678zc41qrcsp519pwjiok7ku X-Rspam-User: X-HE-Tag: 1706538979-875573 X-HE-Meta: U2FsdGVkX1/dAIbBGObmlwH861uHVED5VkVIyA+oKKY9NZuRhuK32TCHE3rO6b3FsWbOOyINfz6wUafA0I1CuKLYVPQd1m6+9s4T9DBz1FJUfmBel33U/wQKbWJ1/Rzz5+RPEVwff57wmnkjlXfHhYYE/zcO2ihzcqalWyJFmUO4HZ1K2bHw7mOe/RrFTNm3GG2naBn5uqfnSlgg1eeV18S3BTHR+cm0t04ppAmYegANcJfpfrgHfRciZglW53rj7zpwdqv2AIP5FcTGZECpQknuMTE82MppXncXjvPYwZM4K2IyfI44kv/GTPaHTFvx0TtBVw5EBhjpiyJSSakL8f9dqub98hCIQyEPxLYmMgLFEG9j7d0gsOHiXFQ3A0vmEWtHyAEZvZrGC/hMA+v4gVJlljeSicHjch5LtemsFqDv2AXkekxhdcxMBVnt6AXg2NQBwhsM5+2R/zZm5cQezM+MEPDJCMhaJGcT7K/6V5JRedJ071twZpdR/hIFiYueY2cPaETZGXwgZkt4tcqO7FiEpW/+P/OXfozCMDY+UtC2Z7Nh70tiGgF+hA1MzmVqjcEdbT+DtQsiItfTr0nWOl/ZHiu+2Lhs3rkboFT1ZRsl8KhjiuLpR3QVfFf+5ZR/vE/jugg0dorZ1tc3wLKIXNo8tHJRdtduvSRSKNLWK1PejU4CTjfNnmQ+jUGf91xfcNnS2ucK5X5a3stgh7j0WZ7JDvdwLAeAX5axhAQBPJ8aG7EfspzIaCW82A+P+VVb5dcWELlcmjoOR3g4kzEErVmPC+WB7Z8RFhVvguMayXkDrdVEKPSNs/Z2mUu4wDu0PIbqQCZeLYe7uhjoR5QrgJOW8+tLghsWzviAcU7iVnyQmIiDj9hSkeiKEwdsnowob25PN3I++DQt6KE6z5VWM/mlzFi25Db25cDcVrvcczc+su5QLE1VOUmm0fSXNxkJZT9DvZNGjRl0Q+HR4lk irEyVLgp jTYc7Gthbjz34kr9Y23idDkJ8OEl5hQkprL8yOjZafg72AdnpzRm1q3ka3WemXjNS/ch0HfO+Hh4T28qf33kgLPpKR6vY3BMQqmLOrApJ74otB9eQtQvR+bKzR60mgYPiNbRSJTdi6nzqAz97e30tP+fLGIO7I5u+anWZh7SiBzafh6SGIg/kZRlgKHVk2fqRPmP86RfEDQioTw3Gs12bQbTa64QYX5/UCx9LI/lExAB6At4VMKGe/PfpQWO/uERyYIJsKNOZaZJY3ELqCxstXrun4kSByhQwOD4ImQcGMuzfKqepspFHrps6AvtLgZimedsYZaqUclvGdG64uGHUtyuDGRLzzX52oWCbUS7XG81wrX+mD8pyb3kwCGdFNODfCEB41FZo4Q7qtTQKaOcOO1dW55//ZCLH1iWbmYuRSkVoqGLJZnu+XEiVV4O8MILBDV413g4Wp7cTD8rIas5MqpULZvI22OeVzJbQQ9y14sxCXkUYjmeZfC9wFFhHjWl9bCf0qSp/C1vJvXU= 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: List-Subscribe: List-Unsubscribe: From: "Darrick J. Wong" These functions aren't used anymore, so get rid of them. Signed-off-by: Darrick J. Wong Signed-off-by: Christoph Hellwig --- .../xfs/xfs-online-fsck-design.rst | 2 +- fs/xfs/scrub/trace.h | 2 - fs/xfs/scrub/xfile.c | 104 ------------------ fs/xfs/scrub/xfile.h | 20 ---- 4 files changed, 1 insertion(+), 127 deletions(-) diff --git a/Documentation/filesystems/xfs/xfs-online-fsck-design.rst b/Documentation/filesystems/xfs/xfs-online-fsck-design.rst index 216c99ce511f7c..d03480266e9b18 100644 --- a/Documentation/filesystems/xfs/xfs-online-fsck-design.rst +++ b/Documentation/filesystems/xfs/xfs-online-fsck-design.rst @@ -1940,7 +1940,7 @@ mapping it into kernel address space, and dropping the folio lock. These long term users *must* be responsive to memory reclaim by hooking into the shrinker infrastructure to know when to release folios. -The ``xfile_get_page`` and ``xfile_put_page`` functions are provided to +The ``xfile_get_folio`` and ``xfile_put_folio`` functions are provided to retrieve the (locked) folio that backs part of an xfile and to release it. The only code to use these folio lease functions are the xfarray :ref:`sorting` algorithms and the :ref:`in-memory diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index 3a1a827828dcb9..ae6b2385a8cbe5 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -906,8 +906,6 @@ DEFINE_EVENT(xfile_class, name, \ DEFINE_XFILE_EVENT(xfile_load); DEFINE_XFILE_EVENT(xfile_store); DEFINE_XFILE_EVENT(xfile_seek_data); -DEFINE_XFILE_EVENT(xfile_get_page); -DEFINE_XFILE_EVENT(xfile_put_page); DEFINE_XFILE_EVENT(xfile_get_folio); DEFINE_XFILE_EVENT(xfile_put_folio); diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 2d59407909de35..4716869147e3c0 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -237,110 +237,6 @@ xfile_seek_data( return ret; } -/* - * Grab the (locked) page for a memory object. The object cannot span a page - * boundary. Returns 0 (and a locked page) if successful, -ENOTBLK if we - * cannot grab the page, or the usual negative errno. - */ -int -xfile_get_page( - struct xfile *xf, - loff_t pos, - unsigned int len, - struct xfile_page *xfpage) -{ - struct inode *inode = file_inode(xf->file); - struct address_space *mapping = inode->i_mapping; - const struct address_space_operations *aops = mapping->a_ops; - struct page *page = NULL; - void *fsdata = NULL; - loff_t key = round_down(pos, PAGE_SIZE); - unsigned int pflags; - int error; - - if (inode->i_sb->s_maxbytes - pos < len) - return -ENOMEM; - if (len > PAGE_SIZE - offset_in_page(pos)) - return -ENOTBLK; - - trace_xfile_get_page(xf, pos, len); - - pflags = memalloc_nofs_save(); - - /* - * We call write_begin directly here to avoid all the freezer - * protection lock-taking that happens in the normal path. shmem - * doesn't support fs freeze, but lockdep doesn't know that and will - * trip over that. - */ - error = aops->write_begin(NULL, mapping, key, PAGE_SIZE, &page, - &fsdata); - if (error) - goto out_pflags; - - /* We got the page, so make sure we push out EOF. */ - if (i_size_read(inode) < pos + len) - i_size_write(inode, pos + len); - - /* - * If the page isn't up to date, fill it with zeroes before we hand it - * to the caller and make sure the backing store will hold on to them. - */ - if (!PageUptodate(page)) { - memset(page_address(page), 0, PAGE_SIZE); - SetPageUptodate(page); - } - - /* - * Mark each page dirty so that the contents are written to some - * backing store when we drop this buffer, and take an extra reference - * to prevent the xfile page from being swapped or removed from the - * page cache by reclaim if the caller unlocks the page. - */ - set_page_dirty(page); - get_page(page); - - xfpage->page = page; - xfpage->fsdata = fsdata; - xfpage->pos = key; -out_pflags: - memalloc_nofs_restore(pflags); - return error; -} - -/* - * Release the (locked) page for a memory object. Returns 0 or a negative - * errno. - */ -int -xfile_put_page( - struct xfile *xf, - struct xfile_page *xfpage) -{ - struct inode *inode = file_inode(xf->file); - struct address_space *mapping = inode->i_mapping; - const struct address_space_operations *aops = mapping->a_ops; - unsigned int pflags; - int ret; - - trace_xfile_put_page(xf, xfpage->pos, PAGE_SIZE); - - /* Give back the reference that we took in xfile_get_page. */ - put_page(xfpage->page); - - pflags = memalloc_nofs_save(); - ret = aops->write_end(NULL, mapping, xfpage->pos, PAGE_SIZE, PAGE_SIZE, - xfpage->page, xfpage->fsdata); - memalloc_nofs_restore(pflags); - memset(xfpage, 0, sizeof(struct xfile_page)); - - if (ret < 0) - return ret; - if (ret != PAGE_SIZE) - return -EIO; - return 0; -} - /* * Grab the (locked) folio for a memory object. The object cannot span a folio * boundary. Returns the locked folio if successful, NULL if there was no diff --git a/fs/xfs/scrub/xfile.h b/fs/xfs/scrub/xfile.h index afb75e9fbaf265..76d78dba7e3478 100644 --- a/fs/xfs/scrub/xfile.h +++ b/fs/xfs/scrub/xfile.h @@ -6,22 +6,6 @@ #ifndef __XFS_SCRUB_XFILE_H__ #define __XFS_SCRUB_XFILE_H__ -struct xfile_page { - struct page *page; - void *fsdata; - loff_t pos; -}; - -static inline bool xfile_page_cached(const struct xfile_page *xfpage) -{ - return xfpage->page != NULL; -} - -static inline pgoff_t xfile_page_index(const struct xfile_page *xfpage) -{ - return xfpage->page->index; -} - struct xfile { struct file *file; }; @@ -35,10 +19,6 @@ int xfile_store(struct xfile *xf, const void *buf, size_t count, loff_t xfile_seek_data(struct xfile *xf, loff_t pos); -int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len, - struct xfile_page *xbuf); -int xfile_put_page(struct xfile *xf, struct xfile_page *xbuf); - #define XFILE_MAX_FOLIO_SIZE (PAGE_SIZE << MAX_PAGECACHE_ORDER) #define XFILE_ALLOC (1 << 0) /* allocate folio if not present */