From patchwork Mon Feb 19 06:27:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562203 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 6FDEEC48260 for ; Mon, 19 Feb 2024 06:27:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2CE18D0007; Mon, 19 Feb 2024 01:27:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA7278D0006; Mon, 19 Feb 2024 01:27:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D94068D0005; Mon, 19 Feb 2024 01:27:36 -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 C1FF98D0001 for ; Mon, 19 Feb 2024 01:27:36 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 93CAF80187 for ; Mon, 19 Feb 2024 06:27:36 +0000 (UTC) X-FDA: 81807572112.10.79CF6E1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf05.hostedemail.com (Postfix) with ESMTP id 8B709100003 for ; Mon, 19 Feb 2024 06:27:33 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=o0EtrNd8; dmarc=none; spf=none (imf05.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324055; 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=kloREP1AkpVMcy61zrarIkn4ZRA9JTEgIjAj3zMPU5gnV7zYYSj4LNxiQ5s2/yZBBXfmwr 2sw7Yrc0obXcfohmk1eS3p+wS5A0WPzkmkufhN24kujttUU4Jvs1/LLNIF1akXHzOojFfw vtk87XhU/4AzIZTbGvUvm3A4SGrXdtY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=o0EtrNd8; dmarc=none; spf=none (imf05.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324055; a=rsa-sha256; cv=none; b=X3/Q0p7MnPgFnTNyz3aX4sK/1b6MZ0Vk3iMisnEq9/Bc5+ObRGg44j62qRKH4+PKfXZHvn WDcB/ebAGavx5GC4Ao9qQdjkzs1sJuP0bfhJYYrfvwYVPlqfxcIfah4K7Ijxa9AZh2TOok vEja40ybzcqTRU+2ls5wyGmWNCt3a5U= 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=o0EtrNd8SJNNdeLSG2ZNs0BML1 OtsQZjSd8igrS57WzP6+ylJmDfLZoIRil/TiGd523WMu51mUeJnnUr2YDp8MS8grJZi/8K3WHBX1O Rhc8T0BGQDv6kdWEuCMQexZ2r0sDkavWcYLhDdHLdQmriWocYxMyI1+bvkK40ahrs4ezHEc/balS/ fEa6djNPr4HxUqWvrQDP5fmjCZoMjeGhVzrWPFs7N6Gg2UVWKgjo9YK2822oqTizGQIE9hyyuQS9D Rb/xszANs5QziVLR9/uEVezp124zDmWqx2024qddTKXvW/3ZAkDZPGbOFydxTiGtYTIjZjdZgVNcW Sz4oarcw==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx7f-00000009F5F-2FJX; Mon, 19 Feb 2024 06:27:27 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 01/22] mm: move mapping_set_update out of Date: Mon, 19 Feb 2024 07:27:09 +0100 Message-Id: <20240219062730.3031391-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: 8B709100003 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: kufompz1f7kfrn3wweo1oqku65wga5g5 X-HE-Tag: 1708324053-634085 X-HE-Meta: U2FsdGVkX19CUxaJI9/DhF4jtRfFmFyWVm4xi21NtKPe88EpVHtON34Yi/qwvmaYgyCy4z5mBFL+yoFQZxav9x7SpzamYDzfBsMFDDYVe772H9rDho31h+RzFP3BPKANJvbe7RqZCGggOBeKL3yX8T8Q3Ka16W5gy153nA7sK8sivYvSm6uSShuR/RCltut+LsEPuvBd60j8tZn0/MZFavu2SyLRY3y9xIhk9bgxvZgrY241FaQFFBzwePrFBQY3EqJCDiLIZ/HBScHT3yqi2s20qMsVNCgVkTV13JVJvJoCMByI8bPUg8O9l2LWgiDN3/Gk9C0WlDzyzQaKxKdk3+GI/aOw4vBmlmEjWrm3CL+SOaTmwe/NXo6HLXioSEM+jwIbgRXe3BHoAeZTOcyCMUMUCPCsWK9AeOm5n6WJlvaiuN8aK3cXiyZyt6Cv0/9A7y3G3UBNVRZRLZSl8Oks+Xck3FTE72e+iO9iAccoRA6vtqt/tMYS1cyWxl6IWQ22EtznAhSvpQ7Yt4bQWLY6FsJPV25de41eXixjp/Bb231GPWqcmSIczHG2Q7xv/3Mfztu9K78UGWQfgFm1wDis2IN2Rl048LpuEWYpjwiDp3y59OfpVbZjIBQBArdKuSXG9LJW0kElleqiO8QUWIcKVGGEirAmJpx9YUMNi6NUtC4IjSBBSiJCVBbIbaccU77dyyLKxteXYThrsExHRc7kSgRCzKFI9hpTkDHPzxjDdvflf0PkuYyykvLULqqgTfj3awcWZ5DWAB7joEsPSpd3Om9SUCyARoMn11iNmzVQg9i2/d/+v3zJtODMmCziW4c0Ep6Y/8dmQg061ZMN+rwriz/u83PVUvEIv+QUw/OaZHp0za81FGf73EkJpry0JSawVWNx9iqt08gq9nNtoyd9lDOsEJfbwXqPpGPMN8pnQkAuJzu5Jbbq14ASh/gVa0Bsketz/bbyoyWjIoHG+uu 8efbkNtp kyCxO26NleSTqQjkrP4c8Kf+pWyV/RtilhbUzo09rhrz5HYrAVh9UDh3xNMwk00lSk4I/Z5MhZw+OizGuVX1609cpdgNMJlRKwRLGXxkf4GrJbVIpD5BQ2iKl1uU/IEBPyWQsPkUTIFNVw191Yy3Al92GECt7S5DZIx8EfJ+4zCFjXWD1s6QCgNdA7ws+zhXIhZT9OEVhamYiZsIVSLCZIPtpWg== 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 Feb 19 06:27:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562204 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 F21A6C48BC3 for ; Mon, 19 Feb 2024 06:27:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD5688D0006; Mon, 19 Feb 2024 01:27:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BEB008D0001; Mon, 19 Feb 2024 01:27:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C37B8D0006; Mon, 19 Feb 2024 01:27:37 -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 84DD58D0001 for ; Mon, 19 Feb 2024 01:27:37 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 54909C022C for ; Mon, 19 Feb 2024 06:27:37 +0000 (UTC) X-FDA: 81807572154.08.CC19CBF Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf17.hostedemail.com (Postfix) with ESMTP id DF1F94000B for ; Mon, 19 Feb 2024 06:27:35 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XNYJh366; spf=none (imf17.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324055; a=rsa-sha256; cv=none; b=pnM+fLqGkm2pyhplLyzkrSEMhk5zFqudQ+rNFIXb26mf43ss+muU18Zcr/JQVXLxqdgViM nL43JdWk643P0OFJIeyKkeeaMTVxWJhQyHIDhyKeIClyK81MqjvACtTm0B3Y2GfUQwiraI 8zZH+kEYOVrOlH5bMtdX0sg/yi+6vkw= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XNYJh366; spf=none (imf17.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324055; 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=clOp26eC8FKH7Dvv6yg9RYRM6akZaOkBAUeiLBbKRv8=; b=zqDCiaaEO9MPDHf/SH3oLpa7mBmZIvgzHPU7QKvDfiMv6qdct5v4TOwM5dm11ZEx4hBNZo yByg2Trt3uycL44mGux/twWA3ZyIMndNXKLixfSCOoHHDL3XmeasJbjeDAqdJYE9YGKLpG wfXZBvll6jscNvPzi/RePvud4Lbzsr8= 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=clOp26eC8FKH7Dvv6yg9RYRM6akZaOkBAUeiLBbKRv8=; b=XNYJh366mgdDIBrZQeDtw84FK1 fHJ00w2tBnxewggSV+MWGfHkf8hwUDGq1lSvdehhAjs488kbF2Ipy9CMdoqbrh1YoTIbbxxPVZgVm yP/Iw1OY64VD6VsqpbL4R1iukf00mL9aUMqiETx0uVqAchTdYndLHXKyUrFKkctgqVG2LNJQQ3LMv CIajI590GSXkr9/EmWh2xbBGshqpqyroAZTaHxxqrDvyOwMds43DrHbKcL6/2qejRNObFRG+PZdQN dHGla2X/BGRjiIc3nidep3Md1mPIY/mmYqDk2ZY/ZukyvBHpzYZ5foD7IdM6irYSaIVqj3RPs/fgY moYT1u6w==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx7h-00000009F6F-3PHD; Mon, 19 Feb 2024 06:27:30 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 02/22] shmem: move shmem_mapping out of line Date: Mon, 19 Feb 2024 07:27:10 +0100 Message-Id: <20240219062730.3031391-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: DF1F94000B X-Stat-Signature: q6wm548hguthzfrcyhntnci7ptirytn6 X-Rspam-User: X-HE-Tag: 1708324055-87625 X-HE-Meta: U2FsdGVkX1+qxo00NTPsfcrGobXQm3WSC5W5g5PofA3Ldp8LPFZAE+L7SBh+ia9e68vajblZQogbbRDDJ67thuTN/gjBEQhxjbM4BLvOyD5npc4EzY2Gr9DG0lUNSS3BQ5vi/wpnXwELocoGNYMlUlvVerslhvjhmS97CgOpRYNT6goCrS2kee4XfzzYBtAIgHi9OnuU5v4uipEbT0bueka/Fef9D9sEz1TVpQznQlHYV3h1UA4iwPL6eUJDPCrRIlCiH7wyIL3ADmE0GG8SzQOUz15AFs+Rf+kcDgLiRbD8yxI6uiCwZvlBWwPaJErpx9VYxGB6cZC6Feg94Bu/OxG9zxw9stw+TECeYC/0Qpiq/MLSAlqhxE75TrIOX43Xp+2pKvYBhFLuf4YIO5ZZvevuIzgZWajfBpS1rcXBtqYQ7Q1kxr5wS4XZbwb/VgpsacTunxwuMWEzFDiuNRHX8HAW6wEAXOfcuFwc6fTdgFOi+JGjig/jsdFlPbPuTIiXqPpC/bvCKf6Zbg/SdMgRz+QIELfK7jNRNhnLcl5BL/1LPrYl8ymD38H0cRy7P+54HpSPSqn9IImn3AugTuADU/RmnBXj/HpfV1peS3Rms1VcJodPiNHaMPV77xQOP30QrSyFi2pz+26vqnBT1BWwAZGtX0zqN4P3uSlLOOq1xT+AIiS1YsC42ylDMZodLIKYdtasVBBX4PiPayyv0T9ZuBUsdLvQszVjNA/Ca1AvibglYkAKWuZZHh5l3HczFGDsIZAs0nxNORqkxQaNkYtCW4za/McG71lC+cisqPch3XwOb9+J7oh/Y+ilumz5IZqkqyiEmwBYZM3OfD7v/OAhSvpB/0iCiGxhFnN1h8uJOYHeSzi2W8gyNpLKEOyp4FVYlis5Ro1vLnBe8JejWYqaQCJTrrd05RwItF3g8EuG64SOW25EVJBOP6bZvtMe554wngAWNxuIKvuNPyLiUn8 A0Rk/W6h xRD62/0iaynsApLjo1FeOn1lRjmEaAPNEP0MuV/PRBwbPqxM+eA1TOvzbfDUF9J6TvkPHx7/grA5xHbBZrvWkly9zL5+uC3TFjXw6l3Dl0O+9sfNLyIYC3pxc1tMjwwJlEISqK9l/F3eiHjm4HIVTBDODFh1JKppyDDAo81+6EnRYsQmoEnKs3bU8H6so9hW84TKGnRE4rRo09+4Whl+NKEszHg== 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. This effectively reverts commit 30e6a51dbb05 ("mm/shmem.c: make shmem_mapping() inline"). which added a bogus shmem_aops non-GPL export for no reason whatsoever as there as no shmem_mapping call outside of core MM code at that point. 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 Feb 19 06:27:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562205 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 A6DE0C48260 for ; Mon, 19 Feb 2024 06:27:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 336518D0001; Mon, 19 Feb 2024 01:27:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E6538D0008; Mon, 19 Feb 2024 01:27:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 160258D0001; Mon, 19 Feb 2024 01:27:38 -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 E7E828D0008 for ; Mon, 19 Feb 2024 01:27:37 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C11AD160209 for ; Mon, 19 Feb 2024 06:27:37 +0000 (UTC) X-FDA: 81807572154.05.8023F66 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf22.hostedemail.com (Postfix) with ESMTP id D2DD4C0005 for ; Mon, 19 Feb 2024 06:27:35 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=xUYvP8bm; spf=none (imf22.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324055; 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=Kdn2rQS1XHLIIhxM2KsUjLLiRnVQ9dpIBIt3xOSu6X8+VFrQ0sdnaxKVfE1vg3tu8DEca/ fazvj90kkj7suGU9hJ/81qtXsx3gzlSdB7Yq0eLCtWHSYUjQHy10AMkS4bDzrmH8z7Gv40 XTdkKdrooWFpahHkdBuhZ8s3ugi1wtU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324055; a=rsa-sha256; cv=none; b=pnaRFRUPH4mxvH6Q6EFRDyTwRwwQPtif3RykN38etTcWp5YvD1RIjEr6J/XT92LyC6o2a+ Wtef0EKcWZW1kxKxl9bM0exfB0XDOgcqKDmEFagLcvPFfr6RbYX0bP9j4pQY4xYL+ROZ+D xRljsh6peF/p+1pjqTusp3kHoKA4qU4= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=xUYvP8bm; spf=none (imf22.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=xUYvP8bmy68OOaUGaiZ2KblmiK Q6infFV0+/plG4Pe9Q8zhlzEhPB323U+1SH228ltswSLMJzahDZdFotcxBQ4ym6dwwzEJNam+gqwy zXfe5poLm5sH4xqTHQTKZVBv4SGz1vof7MZXE8TNwvm0t8O5fFb2ht8JwUQm1W17+Ig8taf62QK4C L3NyW0Cjp+qxKNJGT+ehURX4TvSxLgAFGmxdfRwJyIMdDReWN0GwbRIVt+bqCFsXalyTNDMT/qoiW vuyQHh5P0dr/PE6oJzAFNqHJl5cT5ayNbEXTiiBpZEOKEWEw/WdTiLmExogVgLgX3s0wMEvYh2237 TJqD93dA==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx7k-00000009F6h-0Pst; Mon, 19 Feb 2024 06:27:32 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 03/22] shmem: set a_ops earlier in shmem_symlink Date: Mon, 19 Feb 2024 07:27:11 +0100 Message-Id: <20240219062730.3031391-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: D2DD4C0005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: m9fhrwjoz78pgahkt53gdhophng95kwc X-HE-Tag: 1708324055-330045 X-HE-Meta: U2FsdGVkX1+mqODDnXV83m6L6urGYAUEQtP6kT+BqMVYobKrYkvPj6imIFESEktWCwc9ocut25ArBuH78RA15cMr3A2yFy5URlWgI5E6t7prByLneXgLEW2xoqZcem2vQXihZ+Esjxy072PIP8I6rObdlPs5zv3nPGuTLUnqgAaQoNZLQFzB5oFRKwpAzjWbzPrRJ5gdOztZN/RrjG1BL7Ptfluv5QTD6IAWfq/axxVSUoxQH9xBmi134Jys3USE57SdZot1k9K+1OToMUjMOdD6uAsA2Xg3D+5sE5YzZ78+i20y/Iihqg6qUf8iGEFEzTHfsnkaZLSFhsnfsVRIJ6/AFZfPBU/HldGRNC8uXIQfTTAVRh7Hgld0Z3osFw02FVpmsSWEzF8+parEtS/xxI3x3J5zooaqID2rrzRXX98bQhKQdu2M1mIC3BkxnjAESl2r/Sf3yOrd5ISaPOkBI2a9vanonmsjmXS5YxnCx93DkGKBzLPH70bMrqO/tirfp/Z8D9Y2IAdDxLy8bumJcWJbpV8zqVoDDF8eQFrNqvkvSC+y6qmfyS4hBo1Yj+atcJLo2xbG5np+CSa8wOjvprFsCqZD2WGv8Y5S834ywzzsP2SNDHio0Dk2GXnNJn57MgzYq6cgB5BUEkc49iC2JvjMdivr6lqfuFjEORpn+Yq/pSLV7UZVf5aInhd/c/2t/DK5TCLS46ljxj/ttWFE3bRuF4PmngsXZYG/aLEZALNb7ilydRgTs4xHkgnBiLL4yY+rxrTyCSoE2zlc78I0H0uuv6qDQtCwPcx23AbUXqSFKK3s2YwfU/DCr0yYZIQXrA0QgpZwUOXR3Fa/0AsUhbO2hUgJPiym9gtXfDmUWXpg/jPyoVvkFRUf8SwfFwylFXLIiMxYrVt4R+SBhby3zNSN8u8rp5wenjqoGYkI7uEK0I4ScYJ38StphZB6VhQ6UImIezPgXGR/j+HA+Gs p68uu1hf SGwhlGp3YAtdwlYa0JUB3e4Dn+CRvE6c4kKIBcDIUnP4PrC/7X7OGYlS8iqdArtOnLHXuuQ/2feXw6DWAsWvfQKLIhZ+/f5EbnC/NlZmhWOvEYvzXyLfboulESzUax8b5pqie3YK91ZziGAR5U6G9dvQuZqybKwqJ0LO/IpC0IwgRCqxWn8/8cG/d7uG0cN7xzpNE4XhtiteFcDmKEbuWo6GewTCNU3pTR8B2oR7cvhsnnTklBtqcbRIyl1xhcxjy/mgzfH+I3PRqZGTjZ7FC7wGGDnBk1tVLAgFYN/qmkJKHBwL0PIDRJiMRfPh2OVqkrlryBH2J5MzcSHN+4jW7XAHNFQl2UbkBV1+91w2wppYy/EMbwhs+GAJcfaU4/hdRi0tAm3ZlAcPpCYjOIZ7wHCILgzAloZxayNF82NPZduWL+wlwNf5wJvbgkHGQH9o26QEU1C/LRjfIfBmi/9yBXZv6cvfJAaW6iXLJwZrK67a3+Wuk2iN7VJ9P9Nuq0XxIgpH6JvUKVkG3Ykk= 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 Feb 19 06:27:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562206 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 8BF7FC48BC3 for ; Mon, 19 Feb 2024 06:27:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B74F18D0009; Mon, 19 Feb 2024 01:27:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AFEE98D0008; Mon, 19 Feb 2024 01:27:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B6128D0009; Mon, 19 Feb 2024 01:27:39 -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 716F98D0008 for ; Mon, 19 Feb 2024 01:27:39 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4A33F120253 for ; Mon, 19 Feb 2024 06:27:39 +0000 (UTC) X-FDA: 81807572238.30.70D010C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP id 8848D160006 for ; Mon, 19 Feb 2024 06:27:37 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=uMHAlgvF; dmarc=none; spf=none (imf08.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324057; a=rsa-sha256; cv=none; b=aiyLMNfMs1nitIAbyNyk47b5Kz3PoZU/obZheq/MdsY/BusySCzR3+KlkOFmcWJ7za6kcF vowSP7FXJXKGt2+VdGmALAwnCZeJSTRA8jGMmK9vs48PJ0GwOjFhrKBA0nm0iATRsYkfYT 2foDSdmdYVStTkCH+C2DiqXAQEMaN88= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=uMHAlgvF; dmarc=none; spf=none (imf08.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324057; 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=yS6Rs1rRF6puIBTV55BzTps20/FA/U7qM7DP5dZMttmeqJ/fcnGdIM1sO7FRkCJEw5ufkr DbsneI67koNRYLPODw8O6nsbH3txZShCnF5CED/y19C7PcQpw4htgvpTssHhtWa5P5ejUn zIiOOjIUVmG8d0CFqNfGLchv59eh56s= 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=uMHAlgvFkjgJFvg8rWoBpfry0I B/cRAS3o+MWlhEdAz7eBRD1bgWGbyVxrJtL2M1GJeGs5h7HrweyCLyAuRBVJGrlqvbkADqgAcr/cO qwFQFNnXTB9zPkAz+9ZKXk9VWtwGS6yBs7Cow7qllaMFDgz4yi3Z0PETha4gird3YMUMeohSWtliW P8dGvtwAnW54RQ09zW6zT/Z+6/DLK05M9ZZaLWdgE5cmkHz5LDK+SSwuNKvio07YB3dSJFeW2fcZJ NCuWhCtb95mm/DsCXI+mbC0tWpglIVRIwxOL2OidobsnTtsQjr30tXwFZi7ZmfaLAxeeETHK7+VQr YzbJmnuA==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx7m-00000009F6v-27MR; Mon, 19 Feb 2024 06:27:35 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 04/22] shmem: move the shmem_mapping assert into shmem_get_folio_gfp Date: Mon, 19 Feb 2024 07:27:12 +0100 Message-Id: <20240219062730.3031391-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: 8848D160006 X-Stat-Signature: 663149t87hr9c4ispyanbu6yaj8c3q4j X-HE-Tag: 1708324057-844398 X-HE-Meta: U2FsdGVkX1+wrba0WL7sMu4Wdj2/GHrfhDszWJUcu0hj90TqI94qLq9qXSTRlVz3X0WtsGMN23tYq5507cX6QvUyFmJ+QgKtorsm2DSi0NSV+jIh1H+SAl2OnLYG5Ueji7MrqFNtzo72/164XvcGeB8iErsDwe/7g6OTvJMCu8BVv5GwfsBCMQorLI7Mp598j8nWW/G80TTHDH0iVI1R0VWyda4PyCOkPnUPQIeAkEAHWem4T7VxIEq7tsRiOp0TqBRZ05E/+qsJNwcoAuusljk4mQoiaZO6ZUyb+mV5MnyXUe9diyy7adBXuEjVYyvMAZM3wmQ5lgbCUjFtQWe9bTG22wiqvh9VK0rEM7clsAryPX4gh/+O01TyPeMk9Vn6Lssguxi/5ZzrRTYWhzl4/XgPANr25mwJIWI3dx+ojQVapQkNdT3SnMRT0BiAdmXWhhYzT0S4SS4+smqIHdvMfUHxL19Sm6vsVqrN1qd+6V3zLod5pWenQqgFQ9XQaI80k6MluS7IL2UfbkIB1NCtSsGHsxOyKbMFJ6h6soHJF85ZYzZt0kPu4Tq47pcu+KCk3ePacGpuvzK4mvb5by80YRckxgc9HcC3PFzzli39vRacXurfCab/TBuwddSfk++uodXFbLO6FOBL1f9BeXkz7BKRxNnM/7W899qea1Fxk/4SoYNMLp9Zy1MFnvkAr0/j8vMPT0oaMJgWavCgNNUzEy8WS/58zAJk85f3GJOIzsTSLJYXyCWrhR27p0ls5OozURSslY2ev8aUe+2oz/iRD2dFkwUa48K5Mts/tvHorJiiDZv3I9Qu1xWP9v+9um9DGaRAxmoixSmDIwFLAk4IZigRO26sHDDl6r89uuxdfVZzW6pQDa6lnAIBGGFSoKGb7UjiuOkGx2VkYrW0wrIRHXDpy3eZgTn3yNXqcnQnGOB27bgEskSJkmMESdUTKz7PeAPLrNLF9cF9g/s5sZ/ SiouSAxn 9sHNhg7kDEO47Izg5orboh90kPJnso40tAWDXBpu43Ba/F3zVLZwNMLnAsVRikNPGN0V9tlfnby7H5VaPzR3G5MyKgbl1uQjKrYUULnHdoudG2QkJ0tw+GBL/ctokKU99DgJ02VXtwit8us+UbVAt5luUh6y3mHgPCbnPUNGABcfriw6Tnj/H6z3Y26FkIc5V5keTq3y09CSToznbaQKzu2ksWeTAY4DTtaKqJUk2cZw6vuYd3QzyoWm8f3QtTch40jUyKu8KIpqaxKOGNgl2HM/FY/wfubqqghFNHXZCVkqZc9mQZTvL112o4LnCUZp55i6ymFabtmJZXRGZKDhPh8qjPuMMHKj0MxsuaCWhhUWgr2m9WFUYjQcpM/jlaSSc8tbc62P0c3tZdOVPYnH3Bw4o0djrB3xC1QglOA4YRebIuCeDZd/YeHpplMNeY0k7gYqj0JPvyOCT8ab8eOe0WBNhWTS4icmClyHpeYq+T7tqKPLaSJNf+ty8TywBr03dlt/3FvagLq5nkJUutc67303XoEK3NskzI0cq3sYeeNgexG4nuQuZQjNDGXNhBtqSoe9Y/FeeTl+5Feo= 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 Feb 19 06:27:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562207 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 8F319C5475B for ; Mon, 19 Feb 2024 06:27:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A63628D000A; Mon, 19 Feb 2024 01:27:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9ECD28D0008; Mon, 19 Feb 2024 01:27:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A3C38D000A; Mon, 19 Feb 2024 01:27:42 -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 610518D0008 for ; Mon, 19 Feb 2024 01:27:42 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 085104023D for ; Mon, 19 Feb 2024 06:27:42 +0000 (UTC) X-FDA: 81807572364.14.2B39EB8 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id 525E74000C for ; Mon, 19 Feb 2024 06:27:40 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=wCSCFJdh; dmarc=none; spf=none (imf07.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324060; 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=PKxPHKzpQ4kwpuIEhYrsnVzQ37Gdt6u06KSfR24TJS0=; b=vnkPM6TV34H4AycsJjIJHlb8CYnRFluE0WY5wnm5mrdxcCD79UYYoNExXymnlCMrn38g3W 1tzVTkB+n2WnpSLln8eG2c9g6ugJeVqc/Rk33+r1IGXh0geWrAARLC50S3nMlTvOPf6hEP uN+tpYHX1AwriUKjWYBdU9ivscHS2JU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=wCSCFJdh; dmarc=none; spf=none (imf07.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324060; a=rsa-sha256; cv=none; b=thKdt+oIDSxgXSs14g6IoYUzWodVJPFA4jQX2mBOl+Yw0MS1bH+SsE9kA2byPUhD+OpQK1 NA3Ul42KqlfRkolWTsYy65cfgb3bp8XYe5lSLzjXdMRNYK9OumUMP1M/llZVtKBf7WwOoh itoa2WWoqXbIgZYr0LI+YbeApD+7Wl0= 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=PKxPHKzpQ4kwpuIEhYrsnVzQ37Gdt6u06KSfR24TJS0=; b=wCSCFJdhZ+pJGYDDB2gcwfsxyv DtHYc5mwCOcHLH6FBHeIpogSXZLO5pgQmclOZKqEof3kUHtHsfClwuGjkwXSSMADZ6vm1mDQ6LEGn ux1rXGEaynPi8UjoiYBcMmvRodaNcrtkLAwrv3omOM1tCDyB8aT5Y3h+LqEQSus9JZCjqBctqUrv2 2+UGwLkTs7qEbBVZ4GrW+JdNQTzjJdpDMgDK3QDDasrwxOhNgSLNGRJM3xVfQKi3n6rxkhYf5CDv2 6b1YubOqwKG2nX3KbvEWgkKQOIo3wbx6BE8TXo0XOj5buU17oLKM+MgtV/+r+QozoaoHw0NfhoQbf wygPpU9w==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx7p-00000009F79-0oF6; Mon, 19 Feb 2024 06:27:37 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 05/22] shmem: export shmem_get_folio Date: Mon, 19 Feb 2024 07:27:13 +0100 Message-Id: <20240219062730.3031391-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: 525E74000C X-Stat-Signature: uqa7hiksz3cd7z3fimmoyb9jn8p7ad7k X-Rspam-User: X-HE-Tag: 1708324060-377066 X-HE-Meta: U2FsdGVkX1/xSpoc8bCy/V2nENxnkOb/KyS5hZyQ6P5fWEaxfq515HGBlbViTSqZnYnad06nLXI+29aoO5uuMqOh5rChR4/OQuZQw7ZbBiJYGMUdTuOHiPn4/MSMHd5L9aU9hqKyS4qQdF/pAULg2jc+hXv0nx9E9zd27stPPcJUlx3QYXEpp7Le/OBJaW559FTaLIxVpgjjbfNG9KZPli2IfqjBNMpRsS2vhgIamx0PJ4JR1KXQwRpAKK21TebD0GY/X8I5B0sbTVJJ7rN4MRM84H4nLFG47Z6MNQr6Jm00AaaR+KcGxLRm1y6ZKosUdpk1UdtUEJlyX097CpzcRs7CaF0d00wTOVLcAtxit6oEyf3NYJc4ziWtEuywIYX7JoF2QnBT8P6cfUONB+BCuz8r9uFlz/qvjVfAnQyt5oRh7eFABijio26Ds9JL2erKoO2HFoPBF6CooZpizkVlSNHfUJ0qtbMu9yRIcUVyKR6MxTO7wKeyRyQZMN+BOdI4BZJ739A2aCV/kKDkFNjLYu/1xajw9bVZRYGmhMPthKr4MJigKz3IhSsvWlYoJ9WSShMaHqCmhaQ283xv933Jdkh/OrBaS/7VbOJ9ZjxTmFkEVLi2/GPn9Gffyur2qzUoJY/MnssHUVb5rJ1FTLGVhkG5GtmrH64H6KVYxKZBz+BvcSj1vdi1p/URcCiXiOcBYGLr/DqRzA9QnFZFAnytFSc7VHaTDo7IOpTRsRx2o6imAk8GQs2HPkWcg9zW0FD6efnKYuwql+axdJYEGgqBQ4azUatq6n9RcN5gmwshjiQWVlsjplVWSt0y8bA5Da9nDb5NyNNDBmV/5fTpksVuOVCqVlUvHzLdVZnNUmVwCSVxYRh/6PyPH8r60EZxsWuvPDOjmfMcsqVWd9wxmqB/WxsP67T59XWsM4ueYzD0qxQz9ovt1hiQOyB3xBg4whT3/1lEhS2Ii/PwgTpcyNS zS4Thm0+ NG/boB/X0PDTel1aMan+4nzW6VNBm7/YUKBnAeU6wmltW0nQhQzXniX9enzdly4up7+h/Ps5EsG7rkpC/nsYcKzZOi1ijr3q4PO+EycZue54/S8xBqU6KswlqzMiZrJ5cyGoZYigckzZq4ByXH0DalmpGPChGRNkphUD0I9ifrhYtIWbFnj9fDBPeOZorHMD6xXPo/sml3oPfrkx/CWfOuDK01ilB2EoqQ+ovEpdmtOGr/BYD8vbFk+rKszLdqQJUsOgkHLH07ubnTI5CUYg2ALRhSBYoQg9OgcIYtyC3zmJ6+BoNl1J5pRJgV9VJi3Yc3Ps+IRO/sqELTLfGiT2v5jNVJOHaJxLI8j06Hy1oFSTMAgq0NM+NdZ36Y3xySdFaZmdJvWYxReNSBv9qYo+qamd43W4DJe3GGoDy0lmDia/+MWlVC18n6BcB7dAPccPfZyOdicbCdvAiNJqcTBLPogZwJmmlfYRnWIaNks57/LyDgR5nVjqGb+ANO9X3iKUgxUZgNguFdb7PLdCh3rn1Le+moqChlZsVog8l1MT92dbHoU5gO3rXXJ8naM2iHX4HDOlkWc3/OcBWn4Y= 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 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index ad533b2f0721a7..aeb1fd19ea3f72 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2137,12 +2137,32 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, return error; } +/** + * shmem_get_folio - find, and lock a shmem folio. + * @inode: inode to search + * @index: the page index. + * @foliop: pointer to the folio if found + * @sgp: SGP_* flags to control behavior + * + * Looks up the page cache entry at @inode & @index. If a folio is + * present, it is returned locked with an increased refcount. + * + * When no folio is found, the behavior depends on @sgp: + * - for SGP_READ, *foliop is %NULL and 0 is returned + * - for SGP_NOALLOC, *foliop is %NULL and -ENOENT is returned + * - for all other flags a new folio is allocated, inserted into the + * page cache and returned locked in @foliop. + * + * Context: May sleep. + * Return: 0 if successful, else a negative error code. + */ 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 Feb 19 06:27:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562208 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 A3D9FC48BC3 for ; Mon, 19 Feb 2024 06:27:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E33038D000B; Mon, 19 Feb 2024 01:27:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC0878D0008; Mon, 19 Feb 2024 01:27:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A61908D000B; Mon, 19 Feb 2024 01:27:44 -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 82B5C8D0008 for ; Mon, 19 Feb 2024 01:27:44 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 558871A01FE for ; Mon, 19 Feb 2024 06:27:44 +0000 (UTC) X-FDA: 81807572448.03.042C498 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf09.hostedemail.com (Postfix) with ESMTP id AABE914000A for ; Mon, 19 Feb 2024 06:27:42 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=sqglayHM; dmarc=none; spf=none (imf09.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324062; 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=zrbE42e/OVazoBf8Nd73psWLWVAH63CkeaWayWbz09E=; b=MX0fMv6UEj7+42/pkAmyzgPSUR91Bg76fN4qSpnTDPzuYc387R3Z/kasoXzBrwq8vrUdCL 26ahhwDLFFfZPrtu7Datd3lxVoJoT+k5X3eexh13a5i3HhixAEQBd/rQG8NrNVv3qI4KX3 HCjb9dP4sNrFEze30NGvjoY1cvKl5+Q= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=sqglayHM; dmarc=none; spf=none (imf09.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324062; a=rsa-sha256; cv=none; b=kVOT6mx3pP/QvIw2GadY5F1tQVX44AjNQHjQd6B5EN+oTBetm+9g8L2UZXbxj38cuBOu4E Q5G5WFBVqhwjMQEQ1b/3B/t6dLk8HK3Mi8HyT4tPj6Q+kVr7cWbQYCqlZaTiHe/KlgW+Qy zjw3/Vrcf7dEvE8M4y4GSo7RGNiHMg4= 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=zrbE42e/OVazoBf8Nd73psWLWVAH63CkeaWayWbz09E=; b=sqglayHMnjeZktr2yE3GlcoLVD kmxvXFZHAbq73iU6WBOl4bqM6ih8JGhmWEcQWxcvM/vHyUHdHHsZPaVygaLDlQtHc3TbtX3c4Cc1O LN3EJAlnNDfFZ0WmacAHKayvz9aSwkNaG8S3MtacZVSsKqt4U7Hqcf4G+yKBjUGkLWhu7MJVLv2hx l7U5aMCGsmI6puL0/jEAYGjUhFmvE3QwixSp71lBRTRPzg/QiLDrpTvFoxZ/btPKF8avE86j8zFMl WL5t52+2LcOgfNutDItqffIz5j647Ku/8IHIB9kTgkexb3WfQEfhkd/kRsvWy7hP4031NU0h3lCd0 jXEu9wow==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx7r-00000009F8U-2tmE; Mon, 19 Feb 2024 06:27:40 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 06/22] shmem: export shmem_kernel_file_setup Date: Mon, 19 Feb 2024 07:27:14 +0100 Message-Id: <20240219062730.3031391-7-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: AABE914000A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: jpr9ps6kttyoayjpt3ufs9nu3c338aph X-HE-Tag: 1708324062-332405 X-HE-Meta: U2FsdGVkX18jzld7IT/ZWnLC9Y3jrAPT2Ja9eQTv8tTwSumsGIDsHZnxxdn2pBkxRW0AMAtQ57fQXVZk1KHCmq82y+92aZSCy7wlUMyIuPALWnHBkKO4f/vMgVV+qLplx0zDnvSgBFMuFPVv/muxRSZRV+fCK9Z0/vsXSYC8Ektify4FxoHw+/hQV3ax11FgyERF101njsQ89kKqkzmvzABAR6KyygMnfuezkRadFZKMJFjCQn40dBLgbaEdpDQMamYqphyc6sHYu3dFFQpEN2RN697SioipCfRiM995OEgC+svVqF6szpn96ipjIP7lHNVz7FvbBriUt80swwXZefaCVTP1h/gU+y0ol5MF2cTKUmGuTJexTnoR7UcKh3VaPN2YzLamrkQOpwF5KRvnLNxjXzjqWbWwVM1mBcfmoUlKiBrnpNdf7d7F82ma1t3YuV9S5P2r42vl33UYP5E6roj1I+fYhxeiB3abRIHpZngnLL3zOBYsxuQDMQXIotZajj8z/0VXLf64t8+02WDbQSIZO6lvkIN1ghWYzcYmvzG+paOoFjo+VsmFI3BxPid0vNhE3jKYVAZXokyuDiRt2ToFmEcAWXZqlNfXZ0k3c+j1qhRguQEQh0l3G5bpbGex5vnTfhFHygUMpiwEATZ+mdBw3nNgl7NsfzHupMsW6g/bt+TP15q5W1FbZdhJZ9CR+9GoXv0n0LMSPKEV9myBOANBo/ATqKvo9NDC25EP62oxsi46thSlmvQPjO3iPxP+gQNJcxip3ifMe7sLxvU1OYymuVn+FEjRr5YYx8YSrAKuQhn1xZpuvH/Ja/hVBGWWUwpUPuI0ZJrJMM7EVOIm0+krhZy1g/RRJ5JQqz2yjrWL+xIMDEu4J6VZYM5/yzjhwRjVdF1fVAbz522LZjDRRO6FC9exqwKGTi+PDbUaPhKQXdNGChQRMEbJPln+/4jqwjAMJuL/GrlT+DMbOkW 1ZweaFeH 2vyUz289VWDkg0O6v7AFe2vQcbo3GwFtvhRPkcf8JWVkQbvaGlb+nN3ceYS1sNiM/ONXgI8NQxrHLbItKeE98f/M0qRuRoZccvkJT8CyAzLJeH960Pva1F08GfIw3XIf+MsVnpcrn3JXyyQjGCqXqIj2/D4VojKKfRwd/tFIu0TLRRFdY/JxsnXP0F4zPo/490iMlCyt8OhBW5meyYdBBqvmBBGn12Yohi53ILK8arP4xX7cBZpTIutCVsiLUQyvm6dQsPgJ6iIr0ZyHIe7SVZseml9TPofdJn1Y90bY5O6gsCeQu3DoOASuQWr0KlXJ2SzAs19tMFF43O5uaClvBEgyIzs7awIqgDfiI18aHi6BLEHme4uz4RgsF/ASK2zK+pRgAhRJWLFiy6Bd3I/8E3LKKhDOev/7D41iVEjTlYv6HYQcz2DBPqTh9D+MPsQ4ZCI6bANwGUmKxeFisMyQLdjCPZoB8Qd6gsLKczz9QLSt67CkKtP4mxb8QpooCuu+J0wEIgsDuMPQKnMXQQaKqJnqTCW87RADIzPcsdyxQ4PIck4fX4uFfoDy9gvK3jsJ9jZIGY5nDzknVaaw= 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 aeb1fd19ea3f72..95e70e9ea060f3 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4861,6 +4861,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 Feb 19 06:27:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562209 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 05BD7C48260 for ; Mon, 19 Feb 2024 06:27:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A3B48D000C; Mon, 19 Feb 2024 01:27:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 753A48D0008; Mon, 19 Feb 2024 01:27:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57F368D000C; Mon, 19 Feb 2024 01:27:47 -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 32E748D0008 for ; Mon, 19 Feb 2024 01:27:47 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0F6951601F3 for ; Mon, 19 Feb 2024 06:27:47 +0000 (UTC) X-FDA: 81807572574.24.A5E55FB Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf26.hostedemail.com (Postfix) with ESMTP id 92BC314000E for ; Mon, 19 Feb 2024 06:27:45 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="RoEVH2/H"; dmarc=none; spf=none (imf26.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324065; 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=tv4iW6mVqD6GYccLIm15nNo+UB3SFoik06dWZEM41Vo=; b=TOOHJw1CozttkRXHSGqt0c3F0gCcbYly95ort5GQZ8sCCaf1wyUsvphAn/fuwBiHx3RXO4 XQ9LU+8FSGzDB50W1nvl3Ntw0uUS8vPMXFsBBYPiHvlw9oOFSQIVlVg1K3zwyPWn5C2h38 Wi0wjvBXMtIiIbHSBvZbIz9kobpgz7E= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="RoEVH2/H"; dmarc=none; spf=none (imf26.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324065; a=rsa-sha256; cv=none; b=EKGQASzTrwdtCn1nkLdhY+SHV1m9OF8vfF0Ge9harvJ3T/oNV2Tc0itF5v+nemutkJ4J1P i5wu3LaGIXLIpz/QGIZJzU4iDcU24oQBTA+flQQUqFjYcQFAea58gS77yrS5PXENPkCBX7 zYLQOSoB+bbaO6esYBsE1xz8yk8/G2Q= 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=tv4iW6mVqD6GYccLIm15nNo+UB3SFoik06dWZEM41Vo=; b=RoEVH2/HhV1lqYtnFtwme3tKDG +x/uoXjToMK4Ur/e9iFCojRvxK8jioQY+Vqlo5P9rjfUE85L3kLULYYSG11Qi0fI/Ld+VlguPVOqy AziW06IRsuCLmzHZVh0Tl5VBzbMqyGRpAHYMTISXI+9Lnu1kERqCJyegVbleHI3sWGJySEFCI0sX7 +zioSoojHuUAHLHXuthz4BGqIV9V0ZrVAVJn2lbSltqeVh38xLTqujY7/mD2IriDsMJOnvNZYm/6/ C8vJ+UfVL3gmDbBkpsN5/WRCx1xD/+VLFzg4gaMJwNUdvcu5LaublV7E4dzDnGBoiThMi6KU9Dk7D BBsXE+7g==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx7u-00000009F9h-0dAC; Mon, 19 Feb 2024 06:27:42 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox Subject: [PATCH 07/22] shmem: document how to "persist" data when using shmem_*file_setup Date: Mon, 19 Feb 2024 07:27:15 +0100 Message-Id: <20240219062730.3031391-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: 92BC314000E X-Stat-Signature: ns4fedqp751icsoexxc8oujpdsrjsz1a X-Rspam-User: X-HE-Tag: 1708324065-974600 X-HE-Meta: U2FsdGVkX18FvvtnkAQ6jpdtK8JS7yQUtPZsw+SUI6krbOqFXdheiBP2gnns397ErVtjj+bD4kvv62frrJaNe5ns9MXFvX2z4TLw6SUShLMgwrZ0CXFupuNfx5dYF6tBwoJJlsxSXTT3EbZs6kjdrzxxXRP5zGAQLCvRpspzz1UfpY6XgOfXiY/6a5oyObaXDF76eL+0PhUWlQJJY0T49KRP+a4YAwiAeIZ4OilbLztjRU8zoRyhqyDcM5FMvYwsdi8EWktSdk6Hv0NuXAGaKKy0Wmt2XoZxGJU6yBjW5YwE/pBWpw+YC5ZaDQsjoGe7OtN2oZ2OTqM4463RPzhsvhZIzRwGXrPuyWACXAtkDjwsj0YG5apwpcLzg8wJr0R6mrTa6XSxiS4cYA3rrLdKwXSCm9B2QAsjDArPndqcJYeXwDzzTyQbyJYBTqfqJDVK9yF9T57BWuKi1P5sQdn4myEWUqK6pw+7as5m0ColVE2RZhFkfrEzYG5yTLcctS9jZ1JOKCid0+Df1Og6AvDJKy5K9s3UpCwIHyDhJbX2agmCn51ySQOTkA2/EGe6YvfGg455Ff4wWXit+hxsJEP9pekaY5RMiICpOLLgUdsZKfyplqjIEJkyK6bD0kff6D5l/89GgIMvVm/Z+fZftwrbT9+GWhkf3swU/2qNI2AbEpV82HmaFqGvTWHTiozcSVhzQSk1MJQf2HLuZxXjRTQR5kyZHRIkiYeuMoIXV6K1jlao8Yp9B5eWzV2GDJA2uD0UBrvo2oumpqkLo3rea7KCJ5RKnNh/SHVEmrKhLsuZB15q0z13heqWCKsfi0BAv0D2nkR8OoG+HHEGk+W1cCJ/qfvEwbxh+7gmyncE0RHV5VWPILC/4FsNmB+XDk+SZi1pfxWUs6fwuN7GqLA87EC6IuCpj0OK31UGM6Yqd65qnFZB54mR05aFcVSFDdf6y/QsR20tkm5FcFPDKbT280C OhjuMpb/ 1/JE2ktNQxDqtAV7BxsI7OLRKdJKEJTI+th1tSzl6yKmToCVgtooEk1JF16QNLSXUFEIt610GHf0zevS5m3u6Rp2zUkKZWur0yBZEtw7vtgzJd67QmzGBgsioTJ257ndjTpHr2Gog+ZMn8ej2PzOggaybESxePDbD/+xb7COJGeENcw9xXVk8Pb5y7P3NpN6IFCIMNMkRUC35847FjGRKKfqdPA== 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: Matthew Wilcox (Oracle) Reviewed-by: Darrick J. Wong --- mm/shmem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index 95e70e9ea060f3..fb76da93d369cf 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2147,6 +2147,10 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, * Looks up the page cache entry at @inode & @index. If a folio is * present, it is returned locked 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. + * There is no need to reserve space before calling folio_mark_dirty(). + * * When no folio is found, the behavior depends on @sgp: * - for SGP_READ, *foliop is %NULL and 0 is returned * - for SGP_NOALLOC, *foliop is %NULL and -ENOENT is returned From patchwork Mon Feb 19 06:27:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562210 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 29D26C48BC3 for ; Mon, 19 Feb 2024 06:27:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A8178D000D; Mon, 19 Feb 2024 01:27:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 530E78D0008; Mon, 19 Feb 2024 01:27:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 384AF8D000D; Mon, 19 Feb 2024 01:27:49 -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 0B70F8D0008 for ; Mon, 19 Feb 2024 01:27:49 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DBC6F1A01FE for ; Mon, 19 Feb 2024 06:27:48 +0000 (UTC) X-FDA: 81807572616.23.A4D73EE Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf04.hostedemail.com (Postfix) with ESMTP id 481BC4000B for ; Mon, 19 Feb 2024 06:27:47 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=JbpnhUX6; spf=none (imf04.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324067; 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=ftDKzMVuY3mh1JqnX/Rx8Xv83eufPBpMko9jspRah50=; b=dM1G0Lt+z+Q0xyZJUyFApfbwRsbpLEFvBxIqS+ZIPDgmRYVnvBMNb9UenrhKwP7iK3okNZ uqDRKrgPUdVf/9woOnIAbkxJnASMCcsrvRE7wdKq6I/4fomN4T2fGkEXfXWz7T4qbBvqrf +aMrtRlWtmzOiK6534hvYI0KxaOw7zo= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=JbpnhUX6; spf=none (imf04.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324067; a=rsa-sha256; cv=none; b=OkMq6/nc0AS8/2AsVLDtx7/27lGT4N7GjIgwOwIr3NDdQYwSPbnG8nj7N3255TGjSCtGYf JILsjcwE0h88UdXJPnGuSCIhwGAW5M/I/eQahCmsuoQQ7PPrvRenvYZ2hx5Vf57C7JtUbK 8jz/NT4JJFAY6WXpRhrJ/FqHH2mApXA= 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=ftDKzMVuY3mh1JqnX/Rx8Xv83eufPBpMko9jspRah50=; b=JbpnhUX69LwoqeuzXRfVNOyxr3 VLnvzgUo9Ypk0zo8238UgQ6vfICjH4vDNnQCpwQRefMvGp0uDAXGaWAHAbZC+1WEuO2a6k2fanKSd jL8+gYpKnqRlDZC5HwiGiFa3uuieJZfufrOk7SkLxxoUVAO7ELa4Y+XbY6pD5ixXJZCFD1XvZ3zAW eE47JO9lmXug91a4BwMnepqo8+BX4SIzHTNLBzIoK7bq9vylGBHYN4rOINFERo0JxIWeGdo0gd8MW 0C6GHu8TPjJd8k6U4r5Hz3Vm473yuSTPZOn9cLCnYbE0VDYyfkea/9qu6uoLdNoaLlahxrRtBLMbB 9c7rvJgg==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx7w-00000009FB3-3GK2; Mon, 19 Feb 2024 06:27:45 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 08/22] xfs: use VM_NORESERVE in xfile_create Date: Mon, 19 Feb 2024 07:27:16 +0100 Message-Id: <20240219062730.3031391-9-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: 481BC4000B X-Rspam-User: X-Stat-Signature: xaqqode5fi78nf6wrd3smmdmor79a6rs X-Rspamd-Server: rspam01 X-HE-Tag: 1708324067-868379 X-HE-Meta: U2FsdGVkX19hRTD3wel0augSu6lWqpZdgDpp/nk+SQoDlazL4dsIfVc8Vl6PDRIWzS6z0JFjWTldWXnkGI1OoENC0a067wRrQNw9dGcKUblylv8MgWOVrSpzsf9tUdxhd7kSpCOFkM1J9qI1oyvUFakMUq+mA/o4A8Z5/n6TuNOhLdRvL/vhrae9WVWPxyAOaKcqp1I146KLZtSdkjqZN3a4CMT6FTYdk9H9ZI1sTn8ygkLffYZ0JCOSnHg1AEINEBV++tcPQY1Mgit3b/jQH13yBYnYA564qRObb9UyJlctuPNfkVARPx+g/6LC8JJZJl6S+v4cGIItdgSsbBuKHd0bQr5pFeVv8+i6uhWvl4CCAbs8VqAZzYU8CXmRG6cPp47zY35hECeBMDyCJr+pdYu/FhNkq5QTB6MCXq3L/cSsI302zrhgPwH2449s3u6LfU23rMdP6Y7fK62Gob51hbjkz0GognitUljHMndd883XLZN1dYeawjQ8ZrjKl0eIVFL+uk6h2YVw3ywmA2+Zzx/mDhIkLvqRdYTwHOP3JTEwI45IeBDx7fNpRYfYLGWbYELwUNXc1M+lPx1DafSsQ88/s88P1r67A+lS6WpRNgho7vYuxXEzySvPijVUsVFygrzA/c2ahLzoAzQSJOLtgBW3ork14CqfStIiN/nqQ+hJryZd+FeFAtIN/yoR4AE9D/d0alU1hjluLIDpNjvnXFLNYFk8sH5y882mWUovCKWHNei2gKCVzk9uGMpT4QGP66pcxSr1ZCBIZKp1R+wg5Ui4sd0rERNYX+30jsOD8KROeSiNMNFjXgppVFjbHlyySe3E0WOTo+pDYpcnTyEZWq6KFywi8DOLREzy1dbvzPGuXMo3z8NU43p76EC+TeGa0FTKZyJtwYahjh40cCJyoETOczBWwBwXXZzNzWvriSowwwRv/Zfn4fMx/l3bPTa96yQewZx/GN18189XiO9 yF+K5KkR rJYBrSVXctD8arK+YK7cjhd1RYKVmSqz1vgP869yb18Fnb7ovVfliBHWgGhK/XbHni4BAKfxrCy/LWxo2tDAfhqJScEo84FU0i4zlUl4dXYkuzip4a27flOrlvEgY9w4rmd8+8iTfyCTZCIwQiSf4us6P8hKkcBRe49Ook+L9ibkDTLb4BmnjmVtIhIEd08xMDJkvRNf2xrKkj5Iu0eIvx71aaDWurk4vzLQ5abVaInuCYjO/LaiJrBUw/P9vzsVyrh5+96IQ5cnOU0bJBXHnVR2EJKGcGeyWT7P6uMme3K6u4g95maavjWj0UGq0ZsV/z7xRIu+sONdmZemRwxuvJBYBHkPAkRFqkYqnkvP8fgLA24QtnPk+TBaq5AllhGlQHGgYI3QkSKxDg1MZZWD0p4DwGoksn1eeZLIGEYrAUpraVe4gG3qCkmK6lK26SbW4anpp2b6s1BVnkxAKCljTkCuDBvcDIRBr7KWxwD/rSSAzo8cB0gCpiT6gktlu0udRanc4 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: xfile_create creates a (potentially large) sparse file. Pass VM_NORESERVE to shmem_file_setup to not account for the entire file size at file creation time. Reported-by: Hugh Dickins Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner --- fs/xfs/scrub/xfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 090c3ead43fdf1..1cf4b239bdbbd7 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -68,7 +68,7 @@ xfile_create( if (!xf) return -ENOMEM; - xf->file = shmem_file_setup(description, isize, 0); + xf->file = shmem_file_setup(description, isize, VM_NORESERVE); if (!xf->file) goto out_xfile; if (IS_ERR(xf->file)) { From patchwork Mon Feb 19 06:27:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562211 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 7F424C48260 for ; Mon, 19 Feb 2024 06:27:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFF348D000E; Mon, 19 Feb 2024 01:27:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A87AE8D0008; Mon, 19 Feb 2024 01:27:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 903628D000E; Mon, 19 Feb 2024 01:27:51 -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 75C388D0008 for ; Mon, 19 Feb 2024 01:27:51 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 466B880215 for ; Mon, 19 Feb 2024 06:27:51 +0000 (UTC) X-FDA: 81807572742.06.26C7301 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id CF0AF140005 for ; Mon, 19 Feb 2024 06:27:49 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=iRcbIgMy; dmarc=none; spf=none (imf23.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324069; a=rsa-sha256; cv=none; b=2Mi04c8KLIA4WdiiRSbwK/Hh75Oww+n1NbC6wM8/VPkolHSi9Go0yRBQP6SAN61Ay60RJC +jsG9CQx5ccr1bAhHnBO0qWXkhIFjwkk5mAQFboXcSqk3spG5JmooKD3UqKVBR8UpWDziR qNWvfkWpPeEdKZdNRGKzblPoNdOy0oY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=iRcbIgMy; dmarc=none; spf=none (imf23.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324069; 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=3YY6BZIZmUaROG7bkAzG3HaXF5m4f+ODCrHAQtZlXeU=; b=00lfQy1Next+hmmaOyWnDHJxmFrJTe1F6Y+CHNyFyqYDm3t02w+NsgX6A0GPmm1UMdY9d1 MMu5+kUTU2/KvgblAHh8Wv8V2eELEBxSFQzyDdtsuZ5fYue04o7dCoEZIos/JzAMHeF334 6RvGN/WKDwqjxiieioFH7PDjown4pZo= 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=3YY6BZIZmUaROG7bkAzG3HaXF5m4f+ODCrHAQtZlXeU=; b=iRcbIgMysd7NXSEW4lQTxPVtTE HmczKWoxUJ9Ldr3AsfZ/GAM/QOrFpLOefjvtEAKezelNC0HEqOGeMz+JOuOPZaE1tdpCgm64jAYNI y3EZD2omyyyXZG6qujajC74kjD55zr3wr59ZD5FZCh1FJGaSHiyGgPl1c48cY3df04lIvc4iUPPyp h3KHwzam2e83of93/Sld1zUVeOWE2mdflOBg7kiq1Qj50iWEoz+ZnczJIiLM3KVf64LmuPmOrhAx0 6ddQUNymeDoaEDs+bW9x0GA3bB9ZKr1e655jG8UsncTGJ2UPwG4GP0ix2ndLPKifOZZE3ERvFLOdz PVCYq56w==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx7z-00000009FCK-0n3c; Mon, 19 Feb 2024 06:27:47 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 09/22] xfs: shmem_file_setup can't return NULL Date: Mon, 19 Feb 2024 07:27:17 +0100 Message-Id: <20240219062730.3031391-10-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: CF0AF140005 X-Stat-Signature: drpwfba1b6yjrjmzpanhnhsthxmuwio5 X-HE-Tag: 1708324069-121950 X-HE-Meta: U2FsdGVkX18O8ycbjT8nLF+eyVMNZAfr2LveqNeviLYpnOcO4awqQB8XHXcVbBOEKz899rjH1iPJWo+7vpsnLl1zXLvmYkEhgFcNSDLocRGA9bUYqozLRPetFqg3SS51vUYNICFNbYfYQfEtEfB8SK2GS0LBOiV1R4lioKynQ0O4WsBL8HKfXq6KAjNkT0woQ1GSuZDiQcTRwuvopJZtT02xTVsFZnP1T1r5w6bLD0Z5Npb5VrZF5P06l2BJaREo2DfmIg3ZXITucq8A4CTEaYQsyTLPVSmCuDEVkoA500Ea2+uZ3GbOiPMMC4R+xrMAw+Ns4Ue/cYvYb6ieG1E3s33jQU7LCVuUsxSB7NtkRdybyc8NisjY4jTIxMRRAr8U63r7iWuum/2CBGkzcjxt3hYS8kMGSojkIFTDNqsA+Uh0yu+pBLBbus9JNylas2pm80qgwgw9SeF78+Ld7cnN3u2ZBImK2OUsj2Op4dV+n+QDey5F4StFhUhNReXjuHgIGEtuZJc6yql0AhktGNs+Xmpqs3gD+wjUbpwuC6LPPfo4quDtW+EEiE5u0rpqTeBTaaK7El4oV4DL3Qyw76hedRkBbcJvCoebJx/rbexEuj1XhEYocR7OP1rqDXQYH30yWz59a23Z7CjEmMmNc1Zn3/TorEKulSdmpRaWbfJvvkb02pU7pcIPakQrRMzaBh3/orbhCl/7hHV0/A0y2AMCFM458lp6349k/eg4Q/qSm5WZuuVUBh5fukX/bg+xdI6ys645M67goR69K4aKComMKfj73pkkFHnCtNEdMd+Hd0ulDv/JJR8krAOU9PGXib0e4A0h6LJqR4jNTIwAX48Bhsc3oYnkpq89scZREok1aF0vCYTc8smV58symIbTXe5CfJrrIkpKGg+zqHeR8FNGkRpsp6cJAlATDmP1ak1zHxlwu1Lt91NHz8USCgoY0562rivrRkcVTDu0nch7X9G gilRcu7s b5n3hGpxt/SERTIN497bybMW+zG3gi538cnPOz8fYesJZu+kUWXC8ZQAXvuu+SXY8tS/05wwBf3lk/mAr0csfYhyitZCT00KnsHUZJWGQCzy2afqTLCaaoDVAz02Uzs2fVyQcnr3XqHTUAdQIhtgLKIhnxrVhHTImwLVNVy6y9l1a5H2tG8gufzfOCkfpGGak4NiPDCMM5mOKkM+KcXF1wJT7vg== 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 1cf4b239bdbbd7..e649558351bc5a 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, VM_NORESERVE); - if (!xf->file) - goto out_xfile; if (IS_ERR(xf->file)) { error = PTR_ERR(xf->file); goto out_xfile; From patchwork Mon Feb 19 06:27:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562212 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 3D0ECC48260 for ; Mon, 19 Feb 2024 06:27:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04CEF8D000F; Mon, 19 Feb 2024 01:27:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF5E58D0008; Mon, 19 Feb 2024 01:27:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6F528D000F; Mon, 19 Feb 2024 01:27:54 -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 C114A8D0008 for ; Mon, 19 Feb 2024 01:27:54 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8F4AC801D1 for ; Mon, 19 Feb 2024 06:27:54 +0000 (UTC) X-FDA: 81807572868.23.2753B01 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf06.hostedemail.com (Postfix) with ESMTP id E9AC8180019 for ; Mon, 19 Feb 2024 06:27:52 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=RHqOkPT4; dmarc=none; spf=none (imf06.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324073; 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=jHJLbhzbQM88bSKvGjvpGu8mOibQcB/FZYvTZsZJGfs=; b=MbubGmPWD7zBI8FOPQHfkIL8Pp5C+Jqjx3Sok+oVNOk2/HpF7VkQKmZTYgKVeUapG0nTVS zipDTkMjT7B32pv+kDDt0CEYRnEBuJ5qV4/kl5zgD93h4cvDSYSwZ0cY6o4d3EYWs7hYys MaYzjgIImlFhza99kHrnU9gq+ySngj8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=RHqOkPT4; dmarc=none; spf=none (imf06.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324073; a=rsa-sha256; cv=none; b=ntvji7B2hHZEZEyBdxNBKsduW152w5gTcPpwlhCdbJLCX4n593Ibejn2T6fIJIWQKc+ITX NwNanD6FpV1kbAXAPfFTFR+LMuOHm4ytiYZdJsEP3oOLtFqiKnZAy02CfEQdUx/AA/ffR1 LCV9DP6CzQnulKLF3XBUOyXoCwFFqoU= 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=jHJLbhzbQM88bSKvGjvpGu8mOibQcB/FZYvTZsZJGfs=; b=RHqOkPT4qmpCVEsIyABsD0OQnz tYDZ2iIzJAvY3uXOUGcqEJxyneuEiIwQ7a73AGoj2RzlVYEG8jIlzMea4llly1Ot50UAznCAEcpXm N2cIxiMUGZmm8TxWeNQNuQjPsEsdcbOv97BOJCOH3CgvzgiuriP1DO3jjwB0Sp+4IoTJsm1NyD5kg nlY5McIxIcC7+bfMAKR41Ax6GY+i/5v0+NAZy2bc8ANkVZkUlXHEiFNEBv/Xwcu8T84lupd7itQJ6 EIB4NUJoq008JfzwtfEnB9mSsr9ETzMjR7+3DovntfAOEB6TEyAPHrkfweL+NEihY4lSfwRVyzAlL EikAmf9g==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx81-00000009FDA-3143; Mon, 19 Feb 2024 06:27:50 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 10/22] xfs: use shmem_kernel_file_setup in xfile_create Date: Mon, 19 Feb 2024 07:27:18 +0100 Message-Id: <20240219062730.3031391-11-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: E9AC8180019 X-Stat-Signature: zrs1pkhgfmwapu46pbepefi3j1awakbo X-Rspam-User: X-HE-Tag: 1708324072-397934 X-HE-Meta: U2FsdGVkX19D4KTj5fjSIuBPDJans4mnaJTneNbqhmmczXP/Mw6YpjoRlQL0yXgrCrfTKtOddpfnLsRzp7/3N3GvLaFIuvsLzidCHMVEN2lYjNx7zaaL34Vtx4Mp7ARc3rrDrY3DTJgz9vC7Mpo0cwlvf2eyVWWq24YbJ/+oGjMe0OPZsQlghxPaFCJBkE+YlERuxyqKIvAn/7y8Ysi22NvknCsiYQwgwxMO6KQ8rDrm3xV2YEWlCgZE1g8uAzzCeUBJwfC9Sv4KaYFlIAFF6a0AjMXmriu8uycOSwa4OOXRpImX7U1eeQ2IHzeuSRXDIBDvPTs2P2Ke3ZU2Nt6bF6mpDSD/6/jgBOvz3qDX528lg0mMQleTKbx6tecJJSmehBpoDMunGvpethok6OGv9rvWngagtWH25vwFbMYYbuod3L0F+6u8NN69J+VPlXp/iMb3FGiWrhKgpz/PwN0cJcT4npOXZmHNid4zq1Gvv4bSQv/aofCZTG8M/Suj2mxcavb8t/gR2ulV1cqduYrmBRtvfszXQxvu7vhOqApH9C6CvlRcpSaNp1bXLtJHwL1gTDttRpx1uy3b+UPcMSjjqAogOToSVCMJu1B5++xDmKzpFYbJmvPkdhcaUlGgdRCNf7wdlzjq0u6udc97sQ8OH5ERzmhDF9LNCWozPVJrDkiqyOk1QpgC+REu2brRIU9Pa/CzuVsp/MbqBW2db2XGBwQSct6QZ1mLaXv9wtROh6xf2r5meY1K3aK9nzsj7olkfXUCI55ML0+i4ExHtMAGCKTvZSbBAWhVMdpt15/utSi90W6k2oi85jjCy1dVzXnbnKA7tC4xl7ZG6NtgLQXpvlgS4NowOJlqiUMTr03fMz9Irn5tklmn42HwMMiViBiYFVAmuFhzVtmKOAxbYFlTr8vJ2jelXvwky/BYjKG2tnmc/28ylC7d1QoMOTgVIPGCc23zhY7XR6IuTH9Xj8u 4x9ky1bm PNepNvfymKsGm5Jw1J4Q2jM+A+rc0+gAUSDOV/m988jJcS7XGz1LET+FkWMxGANEbPnDx8E8sjluBrgUm9MlhWHxu3gZGUDJL8iapN7v/h2b3xKVj6rs/qEaN0Q5ZzJwU6/Syh4C82LUel0ItW2Yf7MgVL8tJ4yIpgxmD+Eg/XP60l+g9x3yphC0LKsRr2mh7kJfo7jooqek+wqnbh5Or0h4YYQ+Hr1sHD10xCHhohrkakMtf0Xa61S/kH32Xvw014ugUXT3SB8Oge1jA7iqtebytKDrCXHejYHUwUwrK06zSDYFfTDzR9UM8c78QazKUeW6KTPPA3/g7UlIIOGEoF+82flYJ7uzKK3uhFCyF9d+3+1yNuhTGRubYOfU1EfJvMy5EVgA4ABVarIkRIfReQ4bbFtqNP9MN38mxZAPIwl2x94BcHLevMEWlR/ZAxJmmE7nRAtS2/lk4l2U= 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_kernel_file_setup is equivalent to shmem_file_setup except that it already sets the S_PRIVATE flag. Use it instead of open coding the logic. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index e649558351bc5a..99a2b48f5662e6 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -68,7 +68,7 @@ xfile_create( if (!xf) return -ENOMEM; - xf->file = shmem_file_setup(description, isize, VM_NORESERVE); + xf->file = shmem_kernel_file_setup(description, isize, VM_NORESERVE); if (IS_ERR(xf->file)) { error = PTR_ERR(xf->file); goto out_xfile; @@ -85,7 +85,7 @@ xfile_create( 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_flags |= S_NOCMTIME | S_NOATIME; inode->i_mode &= ~0177; inode->i_uid = GLOBAL_ROOT_UID; inode->i_gid = GLOBAL_ROOT_GID; From patchwork Mon Feb 19 06:27:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562213 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 DD44DC48260 for ; Mon, 19 Feb 2024 06:28:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B26948D0010; Mon, 19 Feb 2024 01:27:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD6998D0008; Mon, 19 Feb 2024 01:27:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92ADA8D0010; Mon, 19 Feb 2024 01:27:56 -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 7848E8D0008 for ; Mon, 19 Feb 2024 01:27:56 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4ACF4140212 for ; Mon, 19 Feb 2024 06:27:56 +0000 (UTC) X-FDA: 81807572952.20.5F77317 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf15.hostedemail.com (Postfix) with ESMTP id ACEE8A0012 for ; Mon, 19 Feb 2024 06:27:54 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=2gyvYLq8; spf=none (imf15.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324074; 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=o1hweSz38RYb00ePEUoeWH5QKSAPHiuuZqJTaYjg4ME=; b=QOy9xswXgTNssnS0LVm7X2d69cy7WlMNN+iTk6pSUm80Ci3WYfMI7HytlS4NaVHvHiC+jp eI9TF7Jq3wcHquJRuGvqrFVH3vUaN1gc0OKvO7Xcl+G95zRoAigi2NWXq5QzBCPJ/PJksy 3Xo36UlIXL3DrTajW6YVodO+CATpq8I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324074; a=rsa-sha256; cv=none; b=SfvlKcftgs7/UHzskBlxFxzg3m7dPmJaB/4M3DLCfrgQ7ewqeeAW/aImUsREChJ04uTnLQ WhfE3G98r7unWJBhkosHhW1lTUfVlavLsb6W80ANZS1d24JcxdkNycijxympCvRgVEFcTj 6L2tSKv89J/vMYntDnVI9Y+Q1r6yP/Y= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=2gyvYLq8; spf=none (imf15.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=o1hweSz38RYb00ePEUoeWH5QKSAPHiuuZqJTaYjg4ME=; b=2gyvYLq8mbKaJ7NKdsAaeSwbT9 1eROmAQ10UrNavhRg+70C7Ejm1uLfG2JeO5CL0/YDzeT50nvn0DGkqiKm8/WalQ7mSKc5s70ZQVqT 3gJwWsycYuHsYJ9wwi5CVdLOeZ9O/tDKLxdydy1JH05zOr33icc3XmuMvW3wh/TAnNFXW9RUj6/vW EGShW5N+4lVXTXO9bL9VUUGGtJVGuQWXY7FTzhJV2sR1vnOnwudWgV4fSuXceLqNQbG6QudzcvOuZ Rkw6qye0/RmLQltWYT3liXBelPjRnAAdF8bwvIe7opDoJuic+F3mWZFuP78CtMLEAdXUblO8M6bqL pTGq2woA==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx84-00000009FEF-0rbU; Mon, 19 Feb 2024 06:27:52 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 11/22] xfs: don't modify file and inode flags for shmem files Date: Mon, 19 Feb 2024 07:27:19 +0100 Message-Id: <20240219062730.3031391-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Stat-Signature: qymwwer6g6a9jfemjwjcc4jcjxcrqcp6 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: ACEE8A0012 X-Rspam-User: X-HE-Tag: 1708324074-754330 X-HE-Meta: U2FsdGVkX1/tb4f2EYCv0O96gDEdKieq8anqLxjawkeZysAhQJRXjXQeU2vTmRI29vsXRsF8glkO1pidqoMDTINsuENDheuhD0F7EQm5SkBLbxCS70s4SL1SEZQF6VpjsJiSmOTwwtP2r9FFjW7TQeQTSaxXQvoH48MOy+53DqwkILBWGgQjcPLfeqjWCORtEiM41HlY5crKG74EBduQU8Ewkj14z19/GHh+jmqoW6V4HbXkoQ8C76aDDO3oQIm1XbrEuuzkua7ORVnl6wH5mLdD/Hrp30aLop48WnTlXEYe7f1EVPGPzxl7TDqxCoy6UFCGtORIgFOa8HnfwtQEBsEa5ZNee8BCmhZRsEagrPFHKVVQ0TSvjer/jHvxvBJ/5nIIDoOFpew0hKFCYg9CGJV9dPks2g2ZFBidN3tWOqgFErnfli51NPCo0PWaI5EF/ml5TnhF5KpVlG9nkiQRhbS7baXPoYmGh74/myUV9y/WsB9NPIhcTJPShSHfl0DfJWgd7Nmic/iHQwuH1EcC6imdv4EoW2Ek6KBwcTujtuzNVQSaokFEXrrCc/CUUz8+NKOEo8xW5aUwiGJSu5guDtU96DftKQVZtQppUyO11gZjPIOP9dd0aPtFRQBElWqbCuQqza1FIeETjn0sy1N2Zqgh6UeSasp1MHuST3OmXqq5/I+5qWMtxUDrC1QoOTmJv+Zo8XvIas9lJ4jx0K9dXYLysztg/l8ItuZ+ZKvnEmgbu0X8omcMtIQI6JwzDRzzr6rTJ123YMTEIH7JoycM9TlQCGLBrJVPEvZEIiohViVQAEqqAoVajkW/FXHJg9/ZkEl0/v/GAvqjzP1woYjV5MBpQ/MzGpmXWrKGHqEz/5FxgHMrrwza/GDaW61xFPS78YVLBjXZMfcLqBNxymhgDa7X19ik58idts72dCZj6CIqF5JA5RjUKW9nr1Hhd3zZJ04AKIursZpB2SBKHYh re0eD10P IM+MmdAzHqArO8hkumhmqNdqSs+BrGB2PP2zTwiQtETip/4oVkp9xMOvu0a9c4I1d28M/htIQatETI5socdkcfhpAArGcN7EbLKL0Bg6n2pR9R1B5/bfyxlbo8kxKy73nF4H+IffCHFwK7kxGfVMNWoyupjJVIrXxM2N6NUBFhB/6foENcp5D8qGRSHjmuMbiBEPRYF+SsWt/xxSe83j6km4NcOr1w/hQGc/B8F7VLs8S7KgP4+Rx4m2UA+zhbnPp39Mj+Tg8SYWl1gWq3M1LFTuO2ZP6DXR6PCtI4UllG0MolWtCYkR42O+6JtnYSXeVCxYJbjHIiLQok+f0F5frarBlvw9Jluv0ubvYyzyhhWz5NVOZGeEvDnGRnmeZAnh+e5L6+bBWW13cF01XEWm0luSbeeQ3NC65PDXMqoA26QwYHVW/CcBO4RWAdeNZBwO2/NdNWHlzHlNBMnjzmbAGD18twxlBREL5o0LG 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 | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 99a2b48f5662e6..95250db81981ab 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -74,22 +74,7 @@ xfile_create( 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_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 Feb 19 06:27:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562214 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 35669C48260 for ; Mon, 19 Feb 2024 06:28:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29CF88D0011; Mon, 19 Feb 2024 01:27:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 227708D0008; Mon, 19 Feb 2024 01:27:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0786C8D0011; Mon, 19 Feb 2024 01:27:58 -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 E07778D0008 for ; Mon, 19 Feb 2024 01:27:58 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C119EC024C for ; Mon, 19 Feb 2024 06:27:58 +0000 (UTC) X-FDA: 81807573036.12.88CD902 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id 4CA5A20007 for ; Mon, 19 Feb 2024 06:27:57 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Ylps9fj9; spf=none (imf03.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324077; a=rsa-sha256; cv=none; b=F+sm8ERDQKeW2O28L675EFDUqEia9EwMslm1ZBw3jJzHfwFm+7x50kkpFuj7iQNMcYvdFs h69F83PxLkSQWBYWIUyldrwjChsroOvThUWxPnB8c+K+MjC6i4BSCFo7DgGNfMD8L/lmVf ZJW+LzaRnlEO8TCwVhDNnqMRBI3MRnY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Ylps9fj9; spf=none (imf03.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324077; 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=4/RzxoU6qCYdRXE8FBWrLOZ1ZhnSkg1CJzUAgg76AuQ=; b=ruPllQbguWXxZ9X5t360XqVyXhT1PH/M/f7oCl8ivQhQW1wSbshrx3WsgPWR65p+GX2D0c 8rmvE3BBkDrSn0J9oOmhE6XRecQBnaUhbswt3sEaexEEwRrX8OuyiyvhlBddbb5KP3eUh9 tt59anWPClLFuCvHwjAyuyjyNTbuRIE= 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=4/RzxoU6qCYdRXE8FBWrLOZ1ZhnSkg1CJzUAgg76AuQ=; b=Ylps9fj9kWswSH/VAjHL0D99wO ZtNrfmMTyxBNhCzdsrb+GHan1koTpZ+48krwxaSBys3nUG5nU4YfcUcY+QEK+BqOvThIq6hWCoE1g TVqt5cwjhleyjDv4UoIz6SGk3Z4Iq9+zTUT762u9Iigm4yJ/lNSvEXE1surrmYKXZCI5Q4LQ9tfF0 23Pku9TH5bSskgXJEMhsBM97A9sdfYcsSLuWXDPuS7eVXTGnYz5+uhgKYjEU1vrZbSb0IZNrX9kWI Lk8xqb3R5ZDqlqJQABoseBufqf0Qxsy8s7f5lcnOGmUi7dhmoiMp/EXyqoI5rHPzWs0bJw7TrmVox DWV2VB8A==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx86-00000009FFe-27dM; Mon, 19 Feb 2024 06:27:54 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 12/22] xfs: remove xfile_stat Date: Mon, 19 Feb 2024 07:27:20 +0100 Message-Id: <20240219062730.3031391-13-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: 4CA5A20007 X-Stat-Signature: syifpisp9bzwuau3zo3wrstjg55cmo7i X-Rspam-User: X-HE-Tag: 1708324077-899622 X-HE-Meta: U2FsdGVkX19zGRharwPI7AGV+sObzKJBzBGOKnYy2j99PtvrXgNxVxYKqj1GWmTPZF4vL3E+EuPGXZ9Z7PgspBQKEI5xwDTGZc2RAdS4dZZu2nFUUIwrQPkHZzK5HRN87NrUb/Zl67R6oMMNFboybcUqtV2dk4fYWDp47VuDPQIm2YKyeuf3wLQNQxtxzh5lGYRj/kQqyUJmydRmggJBQKDRQeApe6ddxql2RRwS41FX24+SejdbK+lCADvnffwkh8G3JCV4IXgXmEey9fwm534WT3lfZQ3GAHSxfbFayoTqSR8lYDVmaNaQTzN6EzlJtFQK4IQtB8e167CerE0g+Rn5PxpgnFZliIQ1wZ77m+DKc7FybKrqkkReIhMwJpmU8Zdwac0LyUY6YZon3/ZOdM05SLC6yfHL4FsbTsUOCiCMSugGxnJed21iguVO4IOWqU1BAl7LFzxEd3XVyBTyzu5lyCvdJqfhl0ve04EgmKXH0t6xIeZBAPByikajrKGNwjx/mn8YU+tW7qEzL4WMs9WClm0reyPvJq0aCL21eITFYFxMoPM+Ed0ncaw2IJwYY6AhbM3gCmzRj1z5pK4OHZpa+jCfxUoeSdzVH/bkiNNh6qJ0tVdOLc7XTFbwUT+HX9vyRdhr4NA9PNf5QPubdAgLcFXy790s0IAiCyq3e6x9Mxe0+3WiNjQeVp3biwUg1Eb5nAr7r8PHQymDhPFk9xyfbco58qioFF3E8UQ8FEsnsyxpiYpVhLzI8FaUyhJ6lw96Z72q2zE7+4FTms0vvXMRxCTlWyhVflqC/jU3Vk85L1R840dySlsC5aMTk2UalKL+BztI7YCnwTqDEW6/5CUfy1ZduffJzGpd0FnhvyHRQ3sk69okMamsvRYTiQK081ZON3JXNmhkfyicbPZyhAaSpkkEPAYaVF0xhdmSG1SgqCWgfzNPGM4KZhovRLLtnYkwnEA8DFw+pEKnkOG KO984owj HmMNyFWZD9e1YVJ8/rXWF6AiAskcOQ64Pz6vtK/7vHDHWLzh3naP/VA8H1GNGKCYf9DKHBrjp8eYa4O7TexirVyKogfMKNQJHqUTk0Cz8mA0X37t7I80T8gKtvSOv8PUixfspJkz1SKW7bC8s56Xl3o1HMi9NMUYje+SRJ56eDm3q0+YvZOBfD27U5Fsq+SZNjlfhV0Og9Ubjk3bIQuVObQ89vA== 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 95250db81981ab..b212d4a9c78028 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -274,25 +274,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 Feb 19 06:27:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562215 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 95747C5475B for ; Mon, 19 Feb 2024 06:28:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EE2E8D0008; Mon, 19 Feb 2024 01:28:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 950FB8D0007; Mon, 19 Feb 2024 01:28:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 755508D0008; Mon, 19 Feb 2024 01:28:02 -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 579FA8D0007 for ; Mon, 19 Feb 2024 01:28:02 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3537340240 for ; Mon, 19 Feb 2024 06:28:02 +0000 (UTC) X-FDA: 81807573204.29.04D4F25 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf16.hostedemail.com (Postfix) with ESMTP id AF29E18000B for ; Mon, 19 Feb 2024 06:28:00 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=bTsWPB8B; spf=none (imf16.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324080; 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=Juje/fNxq4HsRavgv/96/ZPbOSkX3oiJ2aQjZ8nFOLc=; b=rPzhDKxqY777MIJWRx07GNSRkx8dNHljQ7FvdvSHqCPxPIDtQbEtS3JGVWLh0DEwwYO6yO fP+PSpNCwWC29ZisItT4X3iyD+weKZG5R/5SCtauLB4db6crH3LQ6JWT6D1RzCnsYnlmHa AWii8nbFct9KTJJi01C7fw5K41B22Pc= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=bTsWPB8B; spf=none (imf16.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324080; a=rsa-sha256; cv=none; b=Eu1sUFTtNKbxUXYbZLzILJoAba936x/+xexLpmJtAmsQAEwyea6BWnqgDUIUuOvCd3Y9Kj Tsfvrb2ENqkSux2SzMaccEpGJf6ncN14OwrdE7XZjxJQxEYRYxiqyfMt+CRxwY+JYE9tHp u632V0RpSdysMfavBzLfsD5348cNBGA= 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=Juje/fNxq4HsRavgv/96/ZPbOSkX3oiJ2aQjZ8nFOLc=; b=bTsWPB8BmzkIcim1FaDpWCWYQ4 rqONrq1byD+56udJHRU0ZY451jn49wdwHazDFKWrw1huOtfJ7iv5Lca8d3LjGdP8nkAaHZk1qa0vn wIgZm1Flp7ab+SV8yrBwOQNoUDNVlUN/0vFZTNZ4KRgbNoRb9AmxFElq5HwlDUOrxDuUrEDYRhf7t Chh6rm+pLDkaSHm2bFpliLOTfKGOM8ar9CRt7FeJ5tuyEPSGyZB9dPH2gcJxxTSL6s/ryE58uHFyi 1apZP67f9bKUQKoYb43Da4Qgn7yE4NTcSWoiBoyiSQ0965u0Yagu34fE3qEnqgDEUGp4JPAqPccuk LxGs81iw==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx88-00000009FHI-3OGx; Mon, 19 Feb 2024 06:27:57 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 13/22] xfs: remove the xfile_pread/pwrite APIs Date: Mon, 19 Feb 2024 07:27:21 +0100 Message-Id: <20240219062730.3031391-14-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: AF29E18000B X-Rspam-User: X-Stat-Signature: 9kfo13wz8jmecojcybzjtijpgdz7oge5 X-Rspamd-Server: rspam01 X-HE-Tag: 1708324080-553423 X-HE-Meta: U2FsdGVkX19BbbCSrlCvIRav/skpHnUx5q9hSPIeIC+Y5zybUaWSC7hHltCzm58Yz1VdoKyfVkPY3cozrJ3tEARlKeuJeaffjuxC3QwRNawucYUIb5xCytWxp7Rts5IP1IHIapsEAiFT8XRuhHfNNExmDZuzqo4/m4TZR6xQxG7PFy5ah2YXMXCGN5Hb2Cm439b9BAegwbldLYoruyIACJ0eVdU0JlsMcKr/EyzzrK/2oe9QvGy7LZjB9CSafUyYI7HlU9ugkRrXXnOvqn4Y9LD1mw4LAli8hoe4evVEjRDdF3QX6PscieRMY/JKaBoqIR+oKIZHJeUX9LDjuAfHtwyT07TUIb1NHFYvq/7MEXodrhC8nNNqzcNFeVb1dNIMaVrYZGu1V9dy27/tHp9lVuWOT7puX4xua3XDYpCZz3t34E2NQsFWiJPKMlQbQ9+98Ct/LYCkvbAGbXLlhkDJ8oD7MRb1nxATeo+VbLI4Y4SJSJafZ2VPELKwvHzwhAE9pF0Ecwv7MhHLwIP9TzsNL8KLg465lqKZGwWB9v/AnmXy9/1hIAeCBUf0y6aEzkfVjdN7w+3QpOgdm8mhi30coB8uQ1IXBd/aQJRdmBR7rgJT7ewVEWMMEIDkG1eFEyaBGTsLCfcFE9wY8mlff5USL3SbrhYJfkfA2kh3LFsO8ClIMgomsNqaWIrydsCryNhd0pPN6mg4ZZQ86+PFHO6y+APwHP76Qfo9pDyaAs2V9E5cBx9QjXBYW6IANGEu4P87iZ7edQhZaIauOvu6anjDHPgudNRq5phNQtJjfYsEYgDY2vmkmyvBTNPJS3H5gqu92uBZv4h82mbL6OC4EPCAVn7Ts44kcphVHt/2zn2PuBAXYRpKAe2teOOA4KPzEGI+elHS9ymOhl48t4XurVoWZC2OPSaLgLjW+HmypVh+5C84AL9fyE8QcNibBuDA4Pj6hYIsSP55kTMmeejGuf2 uBgaZRXX gCESUPWpBOAsz0L4CXlT+J1tOs+ooJsVRdQzv/9y2VnS+/57ojpucRJK9MF224TfXjV7a4sMqC4e6Vk9/KAiJJ/Q/4u6Hwxdxq9E9Xc/qgohgtTCZx4HuqOvLaBAteT8FseALwvSxYpblodiPqkPsugfa+7UI8b+4+cfzwlZOctjsULnPUpkT8pJdWVQiH1VvrAtZCaY1VeRpqFbaj4EOnTDE4g== 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 b1ff4f33324a74..5055092bd9e859 100644 --- a/fs/xfs/scrub/rtsummary.c +++ b/fs/xfs/scrub/rtsummary.c @@ -119,7 +119,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); } @@ -130,7 +130,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); } @@ -142,7 +142,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 b212d4a9c78028..c15cc886888001 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -101,13 +101,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, @@ -116,16 +114,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) { @@ -143,8 +140,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; @@ -168,23 +167,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, @@ -194,16 +188,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) { @@ -222,8 +215,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 @@ -242,13 +237,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; @@ -256,8 +252,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 Feb 19 06:27:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562216 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 03E7BC48BC3 for ; Mon, 19 Feb 2024 06:28:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 225C28D0012; Mon, 19 Feb 2024 01:28:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B09A8D0007; Mon, 19 Feb 2024 01:28:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF6D68D0012; Mon, 19 Feb 2024 01:28:04 -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 CEE578D0007 for ; Mon, 19 Feb 2024 01:28:04 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A83FB120244 for ; Mon, 19 Feb 2024 06:28:04 +0000 (UTC) X-FDA: 81807573288.21.35D00A1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf22.hostedemail.com (Postfix) with ESMTP id 1838FC000D for ; Mon, 19 Feb 2024 06:28:02 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XdjKpLfK; spf=none (imf22.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324083; a=rsa-sha256; cv=none; b=BWEzHNwiKk0gtGOtXkUCjSLQ8kx6ldZmmGhsTYYHhERIiZIQfdmmlLLOa5Ta6GGnBZIfQB 4IywhONH7idGBRXAFmooF9kdpnIy/aF+YCZaqnIPlFwpanylIc9QSHm3rTN7tFK2N9Jo6Y jerB3sBJ4uhLt+i/cXQuhnjluX3W8Yk= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XdjKpLfK; spf=none (imf22.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324083; 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=F7Vyl1D3QQTGAjflgR6G3n7BYbKCD0s/3rfb9BjRAcU=; b=8cYKclwngbx3hUTlmRVssbHHCQnaGSJka27T+TJGrj7Vc9GkdANHmA4leM5GbLDREFZV9W lxP/l3jC3bQ5PVN2EOlb/2ZBBAbObYGQBLEi1QynDOvNUVxQQsEEQBkFwrLSBlv/zviZ7N In8xfcKuLzSMm4XxXcqkcyWEGub/4Ls= 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=F7Vyl1D3QQTGAjflgR6G3n7BYbKCD0s/3rfb9BjRAcU=; b=XdjKpLfKFuJN2lTHOZIm9KlT6v QYEa7VCt9CBmlb5HYKCkB2uV7sM8fUy+SnkgVIAukNQEAIh2GtAcVVA4w5rYRepnGwY+CRPFoPswx Ku/8skOkzKDp3banGGM5S9ey6r8xva9uxEwxt30NlzjHa+ASNa01UJN5ck3z6XcgNVMD0lt9XFUcA K+6D62p8TN4G9BIO9uQt8y/n7SKx7Q606hvWTKHwwhaAO3Us6oJ8UQyKL+HK3QZfK/6drhsb9ryRa PF1ur9Fggmog+eFByc8PuglAwKW6WNSW9n5l/uIDIt9k9Dy+rijoTGS5X0eFruF6fhK7BeW9vtM2N snmxUPOw==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx8B-00000009FIN-0N6X; Mon, 19 Feb 2024 06:27:59 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 14/22] xfs: don't try to handle non-update pages in xfile_obj_load Date: Mon, 19 Feb 2024 07:27:22 +0100 Message-Id: <20240219062730.3031391-15-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: 1838FC000D X-Stat-Signature: 9zym4rms9x9mxg3hpqikeiin9818ddzy X-Rspam-User: X-HE-Tag: 1708324082-97663 X-HE-Meta: U2FsdGVkX1+wU1ldoDt3Yw4rUuoTI9yq5zo1dF2qsBB56O9dMgXjOoNcHW+jrar5lfY+LFimB8FFq9vCCPvu4supNvtZLy3augb0W3loxp5b3AeqK72LL48fbMc66fB6qkccsRGz2yYKjewTSpH66AkE2jHuTnfw9WQk2eV05C55yNHooH2199gUAtoQ80odb36XbbhBeU7+T9HgFaBZ061e6UXynZJ1smcvMDtY0AakSpluo9HqyeLbhdY1DmOqDWRJcLEWpNqN7bp28uEFFQxso1WWK7CVcNR+W82+JOaIHoMGMD3kzjEBmfdwYE1vj06+fiUwIQxuJYLdMaz8++Tif5mBAAyWvk+shvxAlEvNQtgVmH3rFMln/fYCp38sRS8XELfBTzBzTo96A50HPF9iT+NjPBfK0JRa0+Io33PMKM6MnAUKjW45950EuoZDvyO3GGLdqvtT/HhwqLPW/6X5amAyzqp0Ude3NOiYTkdGoQVOqvTABglVlpbMWJTFIuAOHBRI8YyPjOBcRRHW7eEqba+sDwqsLtXY1aIn8QABZ3znQNSVYOQl8Sas/xK9/PnTqNSZf9rPSW4C66ECS+RkcSR13J5UyaffpyzZjsLTz76c1P8CtcdCcRx26Enll1B3hzrf/ln7gPeSSYRoP2ZU0PxuGqgxfFoXTZ9DdkyfG/0wjJNfLLaDHYtSLfuO7QcZEDMO/3N8V/N+Gi1Y+FqbsIkjueH8b98oXIx+F9VdmxcPjV/9SRRGQlOqT3wpJdwFCT7KMkWITv37KlesIWsKlTp98uh+nfHhSiTz5Ui15S+1uPlErVwc3owDMYZ/OXexOAGh9mTlBWvGhWx2DReyn5js4Z75IFHXDw8ktowsYUswDZfxuiNKYVJjG0PTRdXUuVdF9OfyPz1RWL700w1gHdvjC4F5jvfRJ3ho5TkpKPj3e5mvN/3f2GGQx6pvvH4ukSIHF1qJ3YlMN+3 BH/IZvWT GgoMLBGic0UBADXzP+xTEyipF4z544bGB1MuRoeJyWEFEKDdesaRiajoVu5HjoliK5Q9G/nDkgpQ4/hPsS5neTZ4fsNMiHkh/dj4FzkEF4jgL9FK9NmID9PiCkyYNDyywVoxkOh4UFyxXyXT6rhsmn2qaCkcu0BAine2oTtA6QOcf5Enr74ypdpbM2xvqihYw+JVLfhsB5+rEcK/yfA9FG6tt9Ek8KpZSB3XXmSOnIyaNCrS8T/0f+x43kV8DKQ2HVRHVEc/Bn6MElIclAzSTxprgMMMgMlY/XfNVeK5zxRitVXshuVpu77um9sW+c5LBfDfQcM/KTKtFEXkKOpCb4oXbzGIu6MjaoN0wO5/HfUbZSTF6QjTNMu2sVjYRxiULoRsVr8CYc1emjD+JD3Vb0iMCmYoElsrDf8EA+ov5rA307kKL3qpmeuBNjktCB3PJpsTjUHlnVTXs16sE0etRyyh/NFwQJf4Dv9d++qj/bs0sSUvgx3yqLfEb9RxbaszA2NCIgZk7X0PkfH0= 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 c15cc886888001..4ec975977dcd4c 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -149,18 +149,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 Feb 19 06:27:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562217 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 69902C5475B for ; Mon, 19 Feb 2024 06:28:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8190D8D0013; Mon, 19 Feb 2024 01:28:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A2798D0007; Mon, 19 Feb 2024 01:28:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F4D48D0013; Mon, 19 Feb 2024 01:28:06 -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 429F48D0007 for ; Mon, 19 Feb 2024 01:28:06 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1498380215 for ; Mon, 19 Feb 2024 06:28:06 +0000 (UTC) X-FDA: 81807573372.12.563F8CA Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf25.hostedemail.com (Postfix) with ESMTP id 9D05AA0009 for ; Mon, 19 Feb 2024 06:28:04 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=l7PjhVSO; dmarc=none; spf=none (imf25.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324084; 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=vMzRny256EkGSWXtzu6dkmMncaSoQLHVAAjTF+P8DPU=; b=1Y9jB9js3daain7z6CDj9+ePKaCUX5EEQoFkjIP+i2HI4fDn7w29hw6LToNCK98p2hLGvr TyOzi9AwXLjXpKFrtRAsHjzqSS9LTIrMdd37WNEVhNylJcsG3sIf69Wb8Sxj8HgkV/nOcc ipU+itakdtLsiDLRCH1FgZBucJIIM/Y= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=l7PjhVSO; dmarc=none; spf=none (imf25.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324084; a=rsa-sha256; cv=none; b=KL/+auZZkNgNCigBhecmN7AXmytwEj0Rf3qLAGqw/se3hVBboTXenwSHo1MTbSrbDoMpNu Foc3M8i6CzrMbMyi6cKDeC1IN/pBXjAUb/C0ZMXWvUK4apMUFmc5Dqq1UvBnZ8l1nuOXU4 ayH0oab0aSGEWaifa+oaax4wx/kWiyE= 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=vMzRny256EkGSWXtzu6dkmMncaSoQLHVAAjTF+P8DPU=; b=l7PjhVSObLkfcFoqyT6zY51FWo 13Kloz7QLofMNe0OIsIR/0qVXE3WbIp5jV9zl1I3LG3WVI9ekTkreKtlRH59ecJQO2RXyaFMcNKcK FznVdfnTKaC9yqaH0ImYO17FuUHECDFQjhmEEmiRh/8gfs62BYynfCCSMmaBg1z/RgmcLSrC4iilT YFo5kbXNiW88gPCpO7YaTbesY8BXgM3OS+eiUkPEj+YAboum47aRQkucmi/zdx+k+tOeuBJOpj1Hp Av9yzSMWXNX2woXEb0JM0mcnFwEdK6dTzafn/t4DYeIEuLAyAUeC5Y4/OGiv0AuX63sc/3NIwjzQ3 H07cnAtg==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx8D-00000009FJ8-1eHT; Mon, 19 Feb 2024 06:28:01 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 15/22] xfs: don't allow highmem pages in xfile mappings Date: Mon, 19 Feb 2024 07:27:23 +0100 Message-Id: <20240219062730.3031391-16-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: fix6zrqkbrexytqgrigk4ike9kawgjs7 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9D05AA0009 X-HE-Tag: 1708324084-156209 X-HE-Meta: U2FsdGVkX19dYazq19CoYwfxhKNCMzbTISEZCtJcTEnZf6n/t/H0xaHAGrHXy9w+L9U2yAlnCfQG/iYmGxtRAd2w+JQCCjiFzuU+b1R686qiLc936ZFaZZc3ALLu0s8E/b1AOJe9nL1jM2+fMTZsLO6NewMKsK7kGsupllsFvEEKo/dCnxJ8thXTwrTdfv4R3OwegCvLNRPaa01Vv2P6rzZv01xZ0kmJaaeKf9VX6OtA2t/3Ir0eOoN5cF7rVlSABCPbk4Oby39y4FTH3xhIsx2B6AN+ARlpMsmDvsXB8kB+wShV9ndfFKKazVQQ42QUfbu7z0iD1Wg0N1tbJdQ9xeKlWlv8iAbmXLXoSdUyym/RxOTRbezUI0HdZS7X8Kj67f4Ujn+umuyMnC3zwdF2hokj5NinWVXs0mBbETUwsZ90lHhWEQi/LcRloCHvTwD8etvPr1LjjuM+2d9basPPKTBSBFVSkD5w6m9eDok2Xu6K6Vf/pdyxsmI3qG5y6eSKdqh9bdaYwzOo8wee66PBPLeaTHngZEt65ESXL4OsASjnsqz6XCuTqZr8qbgn38whbJAsglzWdQ4rp2dggnyGgAOSse4sL6BGO9KmB68MZUeq6eeT9XqLT3mmS3ptBL06LxpfD9Kk5TS1unGfYklvW/wH1JgS2mA3C9d+wqvGiS2TnZ6HuO2WKFxzUICJ5FOk16FjILzMkh94E+rWcsG/pAHynhjKshz545rAAjbDULkdc8b0cjd5xsFpxRGQjnymZR1OEvIrqgft78LeurTyvlyDLsTzfXSFObX9KV8y4dTQHWIWcWIY2NOAAhr80MhNaHi0RLIXSogo1z8Hvsb1IXJ6RAg9jVaHjWccE51TYR6nS8NqOAH3PNB2PsQ48/0Y2dPqZEmt+o35yKfNf8ddaqp6+5MJgR+cmlA0kkoko0xtMy2ahiHGVEOpiSzK5tRBKe/4Eg+9dkOHIsJUpdn QjS0GKqX e1G+r+koyquCAsJWNvumsh72HEdQr6mIrf4n9BLTKpTCr29ix6176dLuNT6MhLarNX3vpHTlIzzPMqGssS1UnX1kidNglP3byxFSFVBcoovMIWPFVlvYuU5EV+93MQqH2cireQOZzc3GOdhjHGm1fwq7cQbr0TAWm8p3F 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 4ec975977dcd4c..009a760cb690a0 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 Feb 19 06:27:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562218 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 A1A5BC48260 for ; Mon, 19 Feb 2024 06:28:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1143A8D0014; Mon, 19 Feb 2024 01:28:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C4D98D0007; Mon, 19 Feb 2024 01:28:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E32FE8D0014; Mon, 19 Feb 2024 01:28:08 -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 CBD568D0007 for ; Mon, 19 Feb 2024 01:28:08 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A2C3080215 for ; Mon, 19 Feb 2024 06:28:08 +0000 (UTC) X-FDA: 81807573456.30.26F61BC Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id 305A2140005 for ; Mon, 19 Feb 2024 06:28:06 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=K0ls48wK; spf=none (imf23.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324087; 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=xrj4yc1TectagwrKRxl6KUlUJmMOtbHo6U4sVcgHs4o=; b=8Vszv3F8aAsO2K8FiaSXxhCDvlGKiYs1yTXvY0Bjd2Kcbuar6yaq31NZAKjHh6XujlL1WH nhUH6WQPNSqVzfOM3zjFhR1gEpzYoV5ycvjVl0DaYGNpDFN2UXn6ycyl5jXOV/8+yNu4s5 bBseGbrIoe8++ZWMdzw07FqBC2Ncgeg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=K0ls48wK; spf=none (imf23.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324087; a=rsa-sha256; cv=none; b=Jjx2v/hvvCV6p1DLNYx2SSzCFAO24gh4riuJnbqh8jXND6H0A2CxluAe+AUpJUgxXR0l+a Xt2wxnJKqhT4Hps47A5Kqla75Er5sAHfprRu0iL25AMzPMFeNYAu5uuRIT4SGZwe89PueD 4NQEMzc/xn+YwOrT/E9477oJFkqPQWs= 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=xrj4yc1TectagwrKRxl6KUlUJmMOtbHo6U4sVcgHs4o=; b=K0ls48wK4VPl7lGplCByCy2qS2 geFAEADRgLi6t7LWg1z/FXMmJ0itwU1BYFTfhBdUH9pJPD+qLjtyUvdChARsW6pEBkFoARx2vIZrj SI/ss6kgcLRD8ATZVVVDNGFNS6D8/zXbBYfguetpuIAXflGOD589THOcp3aQd4gE+MU5mgH094zip 76Kbn1Ez8zG3yiCD7GJr/SgeVr4/4CYuVbfQAfFHLnTeY+//tQzyxvRSHiWQxp1NI/kXwDS+1zzBi LGz0boxbLaNP2imfGV9qDwsIF0bTjiqRdXR0CWqAyiQ4tOjeWgbDTupq5xQmALMldmiUlLZnjfmm7 9/E8/DgQ==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx8F-00000009FJm-3UmA; Mon, 19 Feb 2024 06:28:04 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 16/22] xfs: use shmem_get_folio in xfile_obj_store Date: Mon, 19 Feb 2024 07:27:24 +0100 Message-Id: <20240219062730.3031391-17-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: 305A2140005 X-Rspam-User: X-Stat-Signature: 935q631pu5oj6877e5dj9rki47cned7e X-Rspamd-Server: rspam01 X-HE-Tag: 1708324086-199179 X-HE-Meta: U2FsdGVkX1+zqjetwcC4XAf7LBbvSxKz4gmLKzGBfDA+GfvQk5EPWZzba41KaGYcy144Ey3ykFS6RmWcryPaAXlF5qanuqc5pKTsE6d51Vo/4Q1ooU0CIFDfZYT01VxHzIr4GtDqi2yk1lVYXhkDL0f/0FJGVoEm53TfXPq/FYPwBSj298XlbkiEeE7h5S+2k60UiYuGMX0OSHq8g81CgGbZTnN1Gjn+Lnu2Au9TjlmtAVuhMihuskYlrLIrXggbfW3s3pnSO83VbqHvlZSFAWMkSUjHyOS8iwjPimE+IzjuaFHxNZpmfM4g9RbUwfLyr03N3gUSnqAV0dfudFvuJ1H8HlGD6t0ZDeo3TU+BokENQY3GhRhizRPtYKpLYrssQqPsNDH0l55bEOX5qyERQokPrnPhhT9LHtmmYu2qYlJDNRoLgGtxpBIcOobJXK/binYHbCJnl6FM/aa+O8frFgrIdQZp36aEEeAs1bmzDVVzu/e7PIbAtvkMXq5msg5l0IKtNNhW7fcP8HaGqkNyTkq5eYSASXpFy451b8rZZ2yZB7v3ox1gBRuzUoDf1C9st/OuzF74DjMhG5CYQmDtkkD0FT4hnYK2FWVV9p4SIziu6iQOhl4vS1gh0Ke8BNm9gJS5DT7gv7rkyDhd94E+GI/GTh/4Vf6vlFQugzxBdDRl1UEe880O0sgl7Esm+YpzvOLOdU2FeuBnYKdDoXwW99OX44riz9NlK3FJblsuLRrr89kRRgvTwJc7E4eg6SnPi6iXMpY60JCbNty6fkIu3F0KUCGDkQfUb9m4Tm+keim7Dy0k8V4kFfV3/HfCUhO5HnhFntygSo2CIOdha0TPVrjoYrOLfup5MfkSsrwpkOLLczUTSoobU+5b0AVB+JGNgCpn84JQDH54YIKROuh7I9DxHWFDoupCJFrwot8Tq1bKfjxGlzXXCS+IoPGE4zWrZTkX2Xtau7mIgc/5DlP 7s/Xydne 6i405jVQ2lkUkoZe2ji9pClvEVK7mPg3q52qPwRNcDh+nO+Aox/7AxrJ0w6XsFsZIF2lk0WbNqKOIaCV51sBxrFBnXwWv+9kDjUXHmLh1KwLg0YYADgDxt1WSOiq9OpQxt9a+LhGghPQu9YmKPw81snTDNlFdzUYVEiqIeyMS0TPnlEclWpf8ncjvoqXgA12Eng5B6iRJipunifrL5VSg5mZ+ew== 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 009a760cb690a0..a4480f4020ae16 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 Feb 19 06:27:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562219 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 AB2AEC48BC3 for ; Mon, 19 Feb 2024 06:28:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC0B08D0015; Mon, 19 Feb 2024 01:28:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D4A418D0007; Mon, 19 Feb 2024 01:28:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B735F8D0015; Mon, 19 Feb 2024 01:28:11 -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 988A78D0007 for ; Mon, 19 Feb 2024 01:28:11 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 72CCFC017A for ; Mon, 19 Feb 2024 06:28:11 +0000 (UTC) X-FDA: 81807573582.21.B5BC942 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf05.hostedemail.com (Postfix) with ESMTP id C5A1310000C for ; Mon, 19 Feb 2024 06:28:09 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=e2uivlW0; dmarc=none; spf=none (imf05.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324089; 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=4yvOV2MFFDBEYH3fUNbndLoOzOA31/axOU+QN+8ByXE=; b=AWVMgYqDz2CossLDpCiL+yIAa3ZztMC9X7RgbU2S9zfTVdQrj2oPK0Sh38qfLoKaRHVBcB j01vrlve+JWBM3e3dnKOQ8gvRmPFs5L1sVPtzOfivEuvyb5hyUtYl/zDWTDRdpNeWXROBd a/EKk5Y9Dqc+8OTsAfVG21ThopLmL5U= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=e2uivlW0; dmarc=none; spf=none (imf05.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324089; a=rsa-sha256; cv=none; b=ItKp5qky9MgE4emY0TD+R9NU5yrr4h31fagKQJnSSgf7ER8JvGp8Bey/BJ8daxrvKKr2HR cbq/YaNw3zZo6x3lEmbKMM9VttguUlq2VJNAC3HDmTbPw8OTVZu07h9u989Xez9x3iByGS lUxnXadADtCJ74m4U8Mjht8p0HnUdNo= 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=4yvOV2MFFDBEYH3fUNbndLoOzOA31/axOU+QN+8ByXE=; b=e2uivlW03g1+8GmPK2PN83ONDb 8r2sIyKWw55ly82HcTFXQ3kifK+iVITq1bZuyY4AGlqCN3lGKOmYotnk+DiQFqbJw8nBSpHTp1akr SG0I6RDyp6qQP4VegoxnWaOfTFOLB1wpkazAM5VDuh4Waq6h8Be2PRV4KeVXXKSXrEXj8+6nTiLL6 AUiomGcGpS8RyBeDMThtqT4Jj7U0srNcyPcchaLWs4pkpDq4OHqzQaraEVnyCTJqZhUajtp8t39M/ R+77fnfIKA9dsgJ7unLxvnmm7IVQAwscrzyN+5fwMgDmdrTLenopCMcujqXKDOCn07o8A2nse68l8 zmfUA8rA==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx8I-00000009FKl-1Xb6; Mon, 19 Feb 2024 06:28:06 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 17/22] xfs: use shmem_get_folio in in xfile_load Date: Mon, 19 Feb 2024 07:27:25 +0100 Message-Id: <20240219062730.3031391-18-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: C5A1310000C X-Stat-Signature: j8tb1e3xd1x8rjguqez98fxym5aea1rn X-Rspam-User: X-HE-Tag: 1708324089-319647 X-HE-Meta: U2FsdGVkX18ehr0CtrH6RVGbJz5lTZyXS+JDi49GGKGWFCtBudCVZ1PRVgfJTALzfoP+D/fS2uC8wp7WGTi/PTPG5d35LB6NFPGdYWA1+uywS0guo9dyjcUpbeVep1xvsYvMfD16QazBoK1ZWET+xatZ8WcyCUFIi0t75MmqcSVH9+HEKT0S+XmXnI0gEieaPvydRVeZnCvBNxTIHyqmh+tlFGetIRcqI8PPHiLL+CwihtEAZXMkzR9T7ylZ7h/RR3opquFSzCpijP0aZgKBORhijBZMwHIvgqyrn8EKrMSg78MJXeYBtTTunrpNZnI3GZqwIidvgycVKqZZUyelUtHlKatV3NE+waoMz35eyXxsEaje7DORJZG76dJuKoT69GYzNMEk7PrQT9cEC5O37zxNliyzxxDn5R17P77Bo4DYu3H7sEMbIVlS1OHYioffOJZXlxoiVx8etmBYmO/nJcPhRbkGD8EBh8nH7GJAzrTRZqq/Jrj+X+vEx1p+Xm7wiQLaor+Rfzd4DuaUaC7wJ4cWlK3dLceQiKZd3K5Srpie06aD/2h8xjOt/6ktt1hFCVy9/nFL3lYXlO1i4o+KGMDVpp6wVB58iMSmL7sDumjcdaWj0ZrjrifC/gon2t5qHuwbyUert1eTyxvX5bIAG2hzscqEjN+RVbGvHHUQAoWp2JsqIU1uff0Ew3gAE6kEtblS0SOdN1X1rPikqkKAvncMazJ9h1rG8msY2Xc8E0pUVpkN3oneCfJzpKx0PQbCG7k60UOaYVf0V1rrclAPooicsCXKzyhk5EmthVzjCezCDQZJImmDe/RQ7kXJ61ISLwJA1pTMMwFOhgnPPhfMoTgoRxoGgSb1jsHJRv9+xg0xdEdcO3lCXVQjfPjRF0VZM0XhUwh7T3K+7U/cIMSuA4XQr1OVDBjVJeEn15RH3RZxcu4tn4/cd4JXurqUXA+zm9D5TeDb4UkFUn0VViv ZADTcAG/ YrTpF5KbDMG1OmWAaEBK7KvFGQEgM4t4T6LqT4zJjHF5PQN4ZqcX6326pkIOrK1KV/kwDgw3J1vp/4eG+cjBBHdBivtJLxXyfoiOBgAEMhzAmBWk4k+eDYVsacl1IWQLlez8vDqOpHw+k0S0prDh3yyn+dH0hnCCuyDMNOSesp0Ep4tMCeTM3SJFa3mC8IFDcYwTknQCPeEsFZMpctBbDTc2hWnEmzdf+/4KGhyJtFWuxfPy/wjJ0/u45uBn/cMdaSqOnDulDLA4zFHjazM5KQCtctsbUNXPx2MVHcnEd6PrdJE9qNShPOFuqroHGsAeDclDly//Flzl8v2QHZ2JT0B+F0O/Cgj7YBO99ScZwxiW3mtXtKMcm6jgTn4phMv54Jk2ZzJK8ZAj1kMaGe0d2zqyqpLXRVJsq5YlCyqPAfoCJptFqBxbAKjf8F0m59UUZ3Ujh/G9GLs8vOjdRNEN+loXF4yrDNcpi+aYNZMUz4XZoj0caRlDmFq3zWQE8GuNgfL7HGGthSX62d2rJ+Lwr4crC3BDZZl2A3PpzgIDIkgRWa1/pR76J44yjBw== 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 a4480f4020ae16..2229f0b7f9ca49 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 Feb 19 06:27:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562220 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 96EE5C48260 for ; Mon, 19 Feb 2024 06:28:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B00BC8D0016; Mon, 19 Feb 2024 01:28:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB0508D0007; Mon, 19 Feb 2024 01:28:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DAF08D0016; Mon, 19 Feb 2024 01:28:13 -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 743B28D0007 for ; Mon, 19 Feb 2024 01:28:13 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4BD3FA0267 for ; Mon, 19 Feb 2024 06:28:13 +0000 (UTC) X-FDA: 81807573666.09.86DDEB2 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf02.hostedemail.com (Postfix) with ESMTP id D1DFD8000E for ; Mon, 19 Feb 2024 06:28:11 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=b89o2NlW; spf=none (imf02.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324091; 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=BY9QXf9JYyzFQugvtu1qyaPY3i+2wGC3CEzX5n8IPFA=; b=ik1yF4ZLuyEGglLzxoaVhWN75CQ2sPhvezRJhf6g9DjnAwez5nq6xddaUuFcW0zDxmg8Xc l7LTNJvxvdnhwMks+OxoI3hV/E9QnF9uCNc4Qo/7xYiKs8T0mbiVUFoahRHe+I6+ZGFUek Bt+fJWXdyKx0RbeoDkI9UNgCm3EdOkw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324091; a=rsa-sha256; cv=none; b=ki1b4RYe4O/5W5/PdtWoTMuzamexqXL7/CNu3Sd68HNKAuZe3W0HcrvxDOMYsmXODjz6G0 aBZm5zLHPFgP6Mds/ZO1BQ2onoINaRWWkO+HEFoQhO+6ve5HkjnXrh8IiGOjOQgpy1IM8a zw9brwlwNWWo4WAg8l0fXl94UKIQgHE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=b89o2NlW; spf=none (imf02.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=BY9QXf9JYyzFQugvtu1qyaPY3i+2wGC3CEzX5n8IPFA=; b=b89o2NlWaoioaDR5zmAs4ZFj8r 9YQxn3xFdPdkmjpth/4Aq/DaMyJnREdJw8lvyo5PULsUUY7WR9gmwtoMTA3arynwHaDyE4BTO0Uvy cai2kbr/mkeSX16B/hvUjDTredgAvWEx+sAaqrv/w4U1oAxAEtPbLeamS3QrzLrs0s7mFfeVnVz2p jQ/QAGooUSg4oEg6BnXb1iUA3ihNuWCKyM0XX/mn639FB2etByX9cwvriD2ax8Tt7KkzxwJ0V/yI2 j1cRlvPGphGa95NE+kugmLfhI5Xy1pIF8aeKBBm+xrH3OrzURd1dC2a5M6/9mFylrmNXk//XUNi1o o1euaQjA==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx8K-00000009FMe-2iEY; Mon, 19 Feb 2024 06:28:09 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org, Kent Overstreet Subject: [PATCH 18/22] xfs: add file_{get,put}_folio Date: Mon, 19 Feb 2024 07:27:26 +0100 Message-Id: <20240219062730.3031391-19-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: D1DFD8000E X-Rspam-User: X-Stat-Signature: s16ep8qphtgzgg8syeaqnwdyt1je6fz3 X-Rspamd-Server: rspam03 X-HE-Tag: 1708324091-881767 X-HE-Meta: U2FsdGVkX1/TQHnelSSi5KEx+JQapDEie647KOKqphfcogDET8UUMrLLru0l1r7MDfRZW8ihLdBlxFr4P6teJjKiP1d90tHsZb49amUfFMstxKZzB86YzXvtNFGeOYn9O6P93cLM7RTutLdozd8j0KKh71JlCv3sLas5Q3yW3eAO7d+VQW0zGABNspZlwUwfBh1v915Y6tdOnjTby0c7UtlfDooLjTvgB1OIGvpaEpUl9dui0VFKhoDYYWw7EXFhfc/wPhpX2Qy/mkqyasogVl/YjPy8xBUgyEbpY/BbLYcq/FOTQVHB6degdTBW1huVw76mZTlLNOutmhsVOLnDSFPX54KVDMHNfyIXz4FIGnjeiHVukilhWVmMoKc4UoNrkD/Rr8u5sbaNt1bj/kAs50jInh1JZLaDkNq1mc4HxiZJffkP2Pc1yTDAQFFgNRGyPmpMqbf9uWmYfSqXqqKgAM0NZiJmj93MJxdqbe3Fa9wxFK+7vgdOsqcgG9rutUbZcoE46o04em3Ac7lBwX8SchlUXQWSkGIxsDKe1nVVRmXHj8BRGFdrdTCmKL8m5EJY0VUVwH9dMWRWr1+vnrFerBF6KJBRP+E/7sRy6FrT7/n8/H+Q+0Abt/tKOoE4RcdpVn8/YZtS8mmNspdXQT4vscnQk2foJdhq7Q96sPEQFTxJ9NtKk9rC2Bbh3KsSqj56be4PjJQvyavipsVKd1x6rrHC0f2Ig+b7AzXJ9a1PoLZQFSKTBOLLeNzo5zff1js+8W1wshKUS2mxKHGkgFc+SRduM1IV87rIhB05gYc24L+xNjafdqVivHCa/cf5bIIsVc84+CbZsmD/b+5FnZmjUbLVYJdlZvdk1+5KVvmvxCcLek4AbPNbsV4vr51Ag+lxRVZBmx0umCLCZMXAUvQUnN0fBQEs91Y8fdSauzSEvwQ1yeYLRAIwFXbc1VURchFTW8c8XYRCd8xJVC9RQAa wvSaoEUO oiaukjQ+hcmAx8QQrjYW+CZx/MabikL3kJ+WxcH/g2qHv2EiuISXy90R5Lvn9uFxHqtC8lC3EymMEDh8StZ2TfGmSHXkohRS+eZ4J9rZUkveWz6dBJWUqEKtIkj3tOdcclGKhdWn8JCui2+NusbyU4ziC0CZcDj9YWBtV7zQziEXKUyAlnfmahdBlL6v76h9QLTLcxcuPCfS23V38D3lLz2LpNQ== 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 2229f0b7f9ca49..0cab9d529365bb 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 Feb 19 06:27:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562221 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 A71F1C5475B for ; Mon, 19 Feb 2024 06:28:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0044B6B006E; Mon, 19 Feb 2024 01:28:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA7B26B0071; Mon, 19 Feb 2024 01:28:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CAB966B0072; Mon, 19 Feb 2024 01:28:16 -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 A5C886B006E for ; Mon, 19 Feb 2024 01:28:16 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7EA141C01AA for ; Mon, 19 Feb 2024 06:28:16 +0000 (UTC) X-FDA: 81807573792.27.FD9905B Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf15.hostedemail.com (Postfix) with ESMTP id D2E58A0009 for ; Mon, 19 Feb 2024 06:28:14 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qukGHfrg; dmarc=none; spf=none (imf15.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324094; a=rsa-sha256; cv=none; b=MS6frdRoEb9B/nK6cAA04EK7PlhgwbwV7UB/a25SVtEICxLqssqpKxnlilBqYOD58RMj/0 yqclp3Vodtwspnxy0iP7XUNXF475yx5NZxvoMYMNu9N7Ke6KhDzj0CrYtGtqiPZPgNYeV7 2A/G/Sg+2QQ+GGgz0ssuHr6UFyHgVrQ= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qukGHfrg; dmarc=none; spf=none (imf15.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324094; 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=ce+30fpE0YE5UXSyweiYt8QFphx7mErg8pqsio+OP/6RIRKfhi9aYZY5zX6iEEgEU1b/eL Z+C+DShQnlD+6rVSaoKjnOxB0AS71MD6OnMhbEjFW8/gm2lkn6VwZE+5mTcHPgYFh1sH62 kEMF12EQtCFF4a8tVUe9mT3jTMHL9Ic= 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=qukGHfrgvmCkUKibrGcqlD6fPi Hoc4k6zg8xjQIztJlzH7nifjE+PhY6CZR4I+DpVcoGDzS+MU8U5QcQj6CMS0Q8oA5whu1MdDUt/8+ bINQxzKyIrBN8nMvliOYGD5Gw1kVkJ3vSjKHltfFb5NGhI0KAR23qs0OsOYyZDNQu6uodlIY3I1Ab X2A3wGDVR3w/wD5MILvfjYyvO8vZfpAGIsrPCIrVY+DESAZVc8cKuBfFqSt5T5ptJ8OIPxNK/qL0H vGW6P9nFH5HOFl00nsvo0EvoreumP7zTp6aQt4mBOolmxhYcIUk5Y79KNdjhUiwWscUZbRBKh/aI1 3rBVbauQ==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx8N-00000009FNK-18XK; Mon, 19 Feb 2024 06:28:11 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 19/22] xfs: remove xfarray_sortinfo.page_kaddr Date: Mon, 19 Feb 2024 07:27:27 +0100 Message-Id: <20240219062730.3031391-20-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: D2E58A0009 X-Stat-Signature: 3ahsis1sak9edj8no55jf1gh5n44dowy X-HE-Tag: 1708324094-423476 X-HE-Meta: U2FsdGVkX1/0tj1jXhASO9Dnm/kJJhtLFsoT0p9ECkN+W93MMt9ITBuI2vZXYqYWhdfNjS7nsFIT8knfPbsLwzkwBQGSYmfnXjheKVcBLuDAjr9YAox+0RbD1RpsOzbtxN6axJ43KqCSJCXdightM9+kuwELf52hnsMm7vgHIfRmwrh6Aa1EPX+arIxOj5/sotc7rGMIYDJ7iDiK7K4/eaDAvcQB0gBE6nkJgB6Adpk5uzvswfxKxfkThgPVbBYLnv9LYjbQlvWfWs6GMkFgJL56+YqW57WYziHpiZx8R4nTFxLsEwFRgkKZ5Zx7e+53mVkwYfPjx7oyoDnQ43NAjLJ3JsOSGmrrfcbK9Vts34QrdNpDuLE0PbVx1BeimJy/kpkx0GidR/ZhgIZBFsLzWiXFWxVbsJXX/5k0KV9/CshbVmHK5wYEEh36h0j+kkrrTlcyFsiaDwjU4HsnRY/z8U4kfKWa70yqy7gD0WJft1jiGOdsxBNmjcZaGdGugz8mF/1uiJmy7nByVkK+9EA0Vt86uM5UMTKoA75ZUpV2SCC0NBzNo/irRKLut6QHM0/+y9xGfpTrPuzgSdpQR0sOy9Vo62y3j+fX014RgfKk6RDQRWYzu2q314mgv3i1YJpC/GlbcMiNQdgDmO4gOFLYrBEtgdt2agAhCjp2m5BzSiXJlg2EMvpKdFffBLDQOnTsqKiHpmeWrC0DDmDvJDclDYotAEnmGGDRGlT3pu0zgplu9OS8jVLZar9m7C4xL7wOeFeqc0a13SjVkLyUGp8F9K4JHdJSB1PUUoG5Kr2QXP0zsywmNGLuoEn6zAgYBkX+BwAYR5HyuiMl3f7X+oSCmad+gwg4VU9986KS9tlnuh8J/9Ys7LPOEvkhgjdi4Y32gGOFbdpQdfOhGFIKHA7EuPjOx4CXcDnupcYp16w9uuBMlZ9LRbxGw2+FP6ErRC5E3OhAUPbHk31RfHMBOv1 BRXFhGaG eV9a0YLVGo6q3LH7v65lYaVGOpPl5g2itT/9XmqG6pROpfjn+7LsaHXYnMjDMCobZzXG8JjnCxip89cV9FP9FASEma0GgFcqSBY1WYrixuABsIKF8Do3ZvvZsojUdUbYLKEWdf8BiGKjNqElJNp4tSCh9Fe81ZqlvqAChlWopDspHAuLKgjY83WGz/bxZClni4EwGaNb5l+qtYhDXQ2E19qWSDcfO+LU0+lraFf6oz9ixX5o8+Gssrc/wDI3R2k+BGn07ZPWLuAK+xQBN1fFrVh14DV8Q69quQjwFziXBveWj5KMQP0liFTesJSJLYD1RYh5QckEN0fpv7VE/Guze/JHmJyoYwodGcMpb2ngWJwbpHC53C+0ddC2exO4kk0ds+uRywSwv3RgqiD/tKxpYSD1O/o4/yT/P6RNSPZcydRf5tsjOyW1rbVtY4qvFoDrSiASHuzXZjZZqH+88DrPYQLFSfNyh3bRC0iatufY9gjUnUoulVXrlHU4+6rkS3A99ZkwCTKvgr2GyFYw= 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 Feb 19 06:27:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562222 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 8A761C48260 for ; Mon, 19 Feb 2024 06:28:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50C288D0017; Mon, 19 Feb 2024 01:28:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 47B858D0007; Mon, 19 Feb 2024 01:28:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E91C8D0017; Mon, 19 Feb 2024 01:28:19 -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 0C0A78D0007 for ; Mon, 19 Feb 2024 01:28:19 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DAC3B40241 for ; Mon, 19 Feb 2024 06:28:18 +0000 (UTC) X-FDA: 81807573876.19.0D303C5 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf24.hostedemail.com (Postfix) with ESMTP id 45A06180010 for ; Mon, 19 Feb 2024 06:28:17 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=o+Gm8DCz; dmarc=none; spf=none (imf24.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324097; 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=DoczPaPdXlR+L/hKvC/KODYYLKKGxbFeD24B1DuKWMMYc7vs9ZcxYOs7JJaIgpGZY6f5V2 9SfEPrTEXunOAArlnOIwm1wmyl6yPDN8kk8ssYf+GhGH5i4L1rPrcW/PURnjRNPgpn8AuH xwPuE3Q7iX4FnAkoFZhJWZ8A+u9EnKo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=o+Gm8DCz; dmarc=none; spf=none (imf24.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324097; a=rsa-sha256; cv=none; b=wQ96+0WIrbzzj8AATg7+F5mcN8fRYTAO62eE7tZyJ8i5FCnC/Xd8UZ+kOoCbfUVDgHxXOW dcOwL3eVT219flrXCB5XhhJ8Tc2Z8wVvtydFo5vC15B76XtGBsYedxVpdG3KT7uAynaDh7 4IQGo1O2IBPSm34RarPE9rG2oIKqu9I= 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=o+Gm8DCzOqtOIMlnlZaWx5DX2/ gP41wxs2zHwXQvYLkhZzxFYkT/0dNYjnWGNp28ysgK2FfUm6CDOQheVeZTCjfyTkEa27UuTCPl4fH qT0jQvGScWH6Ru5uylqx2IptuLIaOa5jhmQ02BXvkUAsPWue2a01IztRuk+Ujq9hSGe0kdA1J1ute s7PTOXU2qhIJuyE/ODerqw90G3UVHsqRVE7hkMu6lrOiuutIBIbj5v1OOvSJT5500TZR6hfflADpM ZuzmgF4QFjiDKkcxgwrEc6yN651dX+tUeHWTDkzNtH98zMFGvMyoxebCqPOZgd52O0LqWKLjhkKJ7 Ua+6RXtw==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx8P-00000009FOL-34gs; Mon, 19 Feb 2024 06:28:14 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 20/22] xfs: fix a comment in xfarray.c Date: Mon, 19 Feb 2024 07:27:28 +0100 Message-Id: <20240219062730.3031391-21-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: g8e4mcmidksbx7wyc7uuuc48wpzx35iq X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 45A06180010 X-HE-Tag: 1708324097-792723 X-HE-Meta: U2FsdGVkX1+HhE39uUSgoVOMWxYF2ItanbuxgslXgA4hdbMvXl4H4d6xdv7mKflidJsokIEyL3Rj9G+AWiqoGGXa2SaOyD0YPkz2tH3pViPqDYZ982FQi9eHz6eLAiNl8x6dvaap+5eDYryg7IsWBVgRIrNtr+EU+n6qZDP2+n3K5Ayxj2hWbUmG1HIRwHZVhoTLRnZSEOHAxHRL0qsOBL/AT4mF2JviNLhkES1J3N9gTGKZ3rBE6QYDmLXfiriKsObSXw8hzqNNdaR22hDcDXomIO/YV4bM9pU6Gve8J/4Kh9LlZZTy5xqanDwr4CxkFVK3N92MUwXl4XCDOoHk9tpa7h+FC0qZbDK4DGdcSre3HL8F61dL39P3fOHkkG2lIhVkm5iX1ApkbY81Cl9sK5sdwAk63iJVjQdy3bLaS0QyQWKbIu19qNoTLzOi1dRokZaq1SEJGydl6ccO/Vp0wHGYFln+6vA5eCg1zhY6FM7iPxv8R7DlcDri/93lKPNrX/szuKkOvBfzw30kRVgUFLKrlsIt/a1r7PYk8fAjJiNVdOscxx7CRT1PCGTWLgVKE81xrMMINRVf6P1h02gKxHCmFKijaVrDDHXNKqEYwnLh5otNxVxPoqTyZpuAj/omayZQR1vNWLZkV+MoGS4ARywwG3w2W0v0Nm37WEjIVN0HDnkKKFyeZXzNwbODemKzIcxXDZ7EvsPUrENQyXpcz0ppaSvD8nxzOcZxOU1j1/wtvZWt76RkQ2xy5Mzc5EhszadWdEzmfjOD2TiJlIP5qGeQoc4gyMX+OmVFS2+fjnv3F2wDjjcAhHuR/gMLRPqFvgLgqhrlePRppki2SCeva8uSDOgLVfSOwB+LqjP/VPOKByajg+OZ/zTkr+nLydawppn/DdqgvH4SP513Z73QDTcqnsUjwa9bLAcQjaUtLCsof4+2uSiHhh5U3GOTRyc/exCiWX0HjkOeGrMMu8c Coznfydf H7rQkEC3STFI4rAnIxaSAzIs5DnA4EVUQYlug+y7Kio7j9vWCLrM0r++4LC+DEQFeLfI5bQZXxbA29HBkweZBQIj9gOHZ5ViDGPrApTFeFZfx8HnAFSc669sQwCWNRsQWtbnJVVpsnpz+WJC4H5NW6X9mg4ibXtJAzLsFEMjScv1v/D81/zzmWra2svFidWhx5V4Pc9NQUd3aKybQdn7u7ZPvhmvSLX4Duc23CVGmA9NCUO8CGIFXiJwB+RVjbYllqLeCxjCOlTyVpfZh0qa/I8JgOlrsKMx3sQbiJYuB8cMQRuuv0YS5b2HnHnfnH/Gwc7DWbxyW80mUb7nA8ji6m3abfmYtdZN0hqdbWhdOQqSCAChu40/ypD4QXTSi5qtRCjWckcS7qr06fI5VIcVA57+Q+wCfJUXZ1SwsYyDH3YkH2aZmjbH9iRCoiBtkWi59tHgV0i/1WPF/pMndh2U4kARsAM7Nf6d3dwSZCQvVUx/wAqrivi+3OYY+0w== 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 Feb 19 06:27:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562223 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 4924EC48BC3 for ; Mon, 19 Feb 2024 06:28:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B27D68D0018; Mon, 19 Feb 2024 01:28:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD6688D0007; Mon, 19 Feb 2024 01:28:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 902E08D0018; Mon, 19 Feb 2024 01:28:21 -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 774EA8D0007 for ; Mon, 19 Feb 2024 01:28:21 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 50988A0263 for ; Mon, 19 Feb 2024 06:28:21 +0000 (UTC) X-FDA: 81807574002.12.5734DE8 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf06.hostedemail.com (Postfix) with ESMTP id BF823180016 for ; Mon, 19 Feb 2024 06:28:19 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="t5g/m/i5"; spf=none (imf06.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324099; 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=EZY3k+tmHQKUZx3byxubzX1mgUMp92Lx7XveMairZJ2VC9oYkbcnieAtmR8lb/zxKgYAwn +825KoaAbi4ebd8A+MddLNIUd1DXpafXjAmrkSfUnkWEBEqgg3R5s7zHJiDt9yfk2F5Mk4 g62aCnTr3DvMUF7KV492PI7HeA+vio8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324099; a=rsa-sha256; cv=none; b=ALs515XgBsLOzZIvXaJ05ic7/1DXl0N9eIaSt+dlRqprVIgT91zKRUIU0Ney27l/TKqw6U 0xMMGRPMY3e5ejA25WRo1VBYaVJehaK6/hncIyUSmbT6z+BdzcY06k+e/Ng9zBQS/qzdsP zM2SCYqGjBzjYtEO1AuccnIFSE1A5eo= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="t5g/m/i5"; spf=none (imf06.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=t5g/m/i5EMJ+LIPgk8zOW7LzcP T+lzBKCKblJsDxRrmw/3oCbjoh2Zeb4MM8smpvSyg5zucDcDiflbOaCyPFh/BVCydu15z/lZbI2E1 PAGAcC+Y7KtfQBFERPBZ5d+WKaThFCUuPk1qjzFwvUL/tR8s1dEb2dWfXeabVwHweFQR8EPIgETgT pxhl2tCQ2i/vLRTqPmGd7Tm2kR6GUw0O2/N9BuwPUdwhzuf3uZ+KHTbTvxx8J892JfiqmoZqMmTFx FIamPPraMM/iGSmxSoD31TVvihK84FCO/52Q5Rpc/yuOs0xyE79RPZ+zaUk+xuGam86pX4TMQGp0U yY+qTP0Q==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx8S-00000009FPX-0xlj; Mon, 19 Feb 2024 06:28:16 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org, Kent Overstreet Subject: [PATCH 21/22] xfs: convert xfarray_pagesort to deal with large folios Date: Mon, 19 Feb 2024 07:27:29 +0100 Message-Id: <20240219062730.3031391-22-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: BF823180016 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: p63z4xhsa5ur7tc18965a7mcgti4qdq7 X-HE-Tag: 1708324099-721693 X-HE-Meta: U2FsdGVkX19ICt2ST5AFL9Bmb2Vy5QFAEcJTHbrfxlYhSeyGF5xWEjrzb46VXqlItO7nGZYS3CEiKRTR/MsbfbZEsn8CJh4DFg25cW0bw2WgYfeEdEP4W0LdwfuUikd7R5Hiw9fiK1V0RZCmAoxJIzZuZO/JWAbnElVKZ6qXxYtV1sy7xQvm9jOQ8s4U0cSBfU2Y0T95sGTnEazd8TgIxsckGq3DewdIcXtAV98vmsbp9nHqMTsZg7/AT6qSyj1nhcOdAnUpbrJplbCkZtq7ICJvuHp91QvXkjFez2E3QrH05IFVLQa1rtiwA+PakpJTCIxg07ReUVtvDPHMqBHGrWb4aBqmxl1E+eba8NWVVhoxxFmQAVOtC2CPS7j6RmM+PXF0mR6jFzS5NDFABmoge+DO7oK8YQUUzyjRLOMwhcaJjsiTgDyf7H2xIGxJR08iW80BWy5qzT7MTAH6rx5iIqOtrd5dLj7B0EJDClawkSyNzsc3a/CEtymuwi4JtRzNWFR6WS8n9D58tSNx6n25Tr7fmynPD6sXLDtschanKfBg458W8qAED//gGVyWABaqrl+w6zj/lpEbGT25ey8hKCRrD3ooxb4Y4RYYLdqYAMSNoJ6bY8t1Gyvj43XgcHphvnR5inkz8u4YIqP1H+K/1eBfK9/ZV5HytpqNMkczUuvI+gCrp9yd4VuyX1CnjsVBn9rWUbPXjR3fvjU+PVIAXecRYKVROXv3El0V8z7kqxAQNiO/Zxk2IipuVoFd5z6PeciYMN0GrZFfQQcHy0OHTV/eT3fVjXIpo4MJhkC5F6B8hc8eq7XNPHJS07FDaGjj3vzMWSColQtbWlKor6lhbX2iOQ3qGGXpDVTSbrQsx1HMmit+qwTz4lTPPhxx/9U4mQ6CJFq81zVR8Zw63d0PTOzULamVLgXN48mpXv1Uwk8gfSxGy0zkiJg8bc8KVyAgRKqqGA7cvFs3CduGWoW xzfBRR9g A0fbOFEqKmZApjui+xYl8MkG8JD2dWQA83EOuOF+PB7ggksgYWeYgzR8Y8qgsbPtjtPtYg5r4i6gvNRb0PoL6Lv3Qx/Qa7gCaM0fS6irzbcTvyMrDr6uFpvAsa+t/L2E/GOE4xsT19l4w0M5w2qGOSrtLAW9TFRYV9pzMZBluQVjtQ3jpqvdf4teo9kGSCcf1ypOh4gZedVTuEpVqQiBzEkyISA== 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 Feb 19 06:27:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13562224 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 C11A9C48260 for ; Mon, 19 Feb 2024 06:28:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4BEB78D0019; Mon, 19 Feb 2024 01:28:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D2CD8D0007; Mon, 19 Feb 2024 01:28:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DA2B8D0019; Mon, 19 Feb 2024 01:28:24 -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 026978D0007 for ; Mon, 19 Feb 2024 01:28:24 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CF58CA026C for ; Mon, 19 Feb 2024 06:28:23 +0000 (UTC) X-FDA: 81807574086.03.1B3B2AA Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf21.hostedemail.com (Postfix) with ESMTP id 3686B1C0002 for ; Mon, 19 Feb 2024 06:28:21 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Xvt4cAps; dmarc=none; spf=none (imf21.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+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=1708324102; 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=qB3oCZWTiw8s0dhbgJTiQSmqK066xuuSv3N8Ml/12ps=; b=8bJqzcBgE29tJia1sMYek7LxWoJ1V9Ux6oV/i6NhdNNS7gkyl2znR94ZOw14tsv8lEubpM 42ATnCq/x9Eomch4uM4B4/QarLGF7txKw+92XICKXjqVDsHyTMc/umY/oUn1v3V81J9wv8 FHzEvfpBbIIfDq2GGiMwuOhuMbOjJpQ= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Xvt4cAps; dmarc=none; spf=none (imf21.hostedemail.com: domain of BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+994827af29a55d2021e7+7484+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708324102; a=rsa-sha256; cv=none; b=iP2wz+vmz1bOV3T7myEWKXqw/m0SAN2XgtagSsCDLhA9grz5LsdWJOw8HHl7zmKgQx8e70 gSRCUvehhn3zAyDCQwIx9lLEw/XdK5Q2M5eaCA+sV3UflUCKmnDTBuJSRFQPksKXIB4tcq Fv/O3xUUjw6wAcmKKaOwn7dYyKOsvzI= 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=qB3oCZWTiw8s0dhbgJTiQSmqK066xuuSv3N8Ml/12ps=; b=Xvt4cAps3yUB3ZpxPI2FwzBr71 D9zWDZQhcndLRxLFk/nIX23rHjupxFXz6sX5spx26rtfCfQ0tQxV/mfXJupb6OKPVLyKdtBay3Xv2 kvP1k4WRCdYISYSKjtu1uIsy1jLE39bOhwbs1FpNpqeO69go0FqVhvEJzTyjaebIR9FksP28UH9cM Xs/Itv3B6JcR5NLq+iMUa2F3BIbIa3JfTC23Tga7XM/Y6zO/gN3W5GdhkCxzOYtEGaYArgOMq2R7I w0BAN4hy+wGEMKK+7CYademM08iRL+7A8lttU+Xu8GDvPtFJNrSyPVSQMQNGwYM5oWqu4eztAEAjA UtRlXxXQ==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbx8U-00000009FQi-3ZFU; Mon, 19 Feb 2024 06:28:19 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: Hui Su , linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 22/22] xfs: remove xfile_{get,put}_page Date: Mon, 19 Feb 2024 07:27:30 +0100 Message-Id: <20240219062730.3031391-23-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219062730.3031391-1-hch@lst.de> References: <20240219062730.3031391-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: 3686B1C0002 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: x6a4q5bd56kg5xj9d9pymjhofhp4sufg X-HE-Tag: 1708324101-276876 X-HE-Meta: U2FsdGVkX1/gDdvUurqHCFSUYHjRyyhBzKujf7MTRvshxNNCh8rgOeU83AMugvvKgpnrDHXrgFXSP7MdUHvEZ2s1fFyF98D4SY0R4NyFSoRIQmDQ1F8+iEtoRQf+EjVe8DfcOSQ1Oxg19ILM5hKfbAboudKUR7+gmmBxLqvsqLFRXGDV4BgQb34z0B9BhvedE4dkgsYY5FdqM2jUZMNlKfSKfL0D08UoLlgKpK1KBvYc+xvhSfPoHxGSf8L8Dd3MglDc8aMxX/ECcWk1hX/3d02P3XAx1g1av2HJT8EL+GVNA9MYrJikEbyPLl/liqm94E0IDp99MHDgN/1RcIm00vnfNmjrHsaGBrqVSYJqjXP39WaIg4rPT2pqxv1a4NDNuNjhEAlk982qnOpGduA+LMqaQ7UIMblQGvTcDmXcpEse6VD3qclIq8J2hnjTOnEbbRZMKVF8tquVtZKjq4GZMncQ1PO4mCHJ7fOEitpytSeapFOHBC0E3ZfHtGOgIC1byNLZryjnHsqwiupClCm/Nl116H4tYo9Fo4+1U3NXWx08kFjbMvimfXwbr6C5oqPVAfaf3WywICDNBAaseNMwJsVweSgOowjuQiaxxvQ587fv1k8Xh3+ITtTrviXMPvfMVqI6Dv6g8kwE+IeFs/FDhL1Iabh5GYUg7/TzREXQtbZj6qfccHCPg4AGY8weICwAB7BRCIszxKhf0/xW9CwU23crNfR632nSLGb7gjUWwpoxGEe7I/shOFfTT5PyAVgU6sDPvkp+ylofj67ucz75YuNqmu3iSFhADf0FXot6GSFSoiJbU020UrhdOFie1g/H1Ra9+yq7+V9VBkZvsLGlq6mc3Ij7P3++lfHVxMS4MXhzo7vkWFQuxdZr/W57GZ5UTEcCLCeoIRAsocxx9uPyB4NIIjo9BnmmD3jtpCbnMKfVV0/LySnHZIkocF48ZWJMTvHOVNQUnV3nXc4TiFI dA4UFPUy Kkf/MdllAlhChrCtCiREfA1mR1tcrgh51+X9olkBp1jDFf/nXxHyWfi4HEF1C+T6LHmNQHWbxliDZtNkmZW4aq8XnHZznivlzltcjrcmqSFYBvw+m5Tp5SM1GNuFoyZVkPEyvbT4DTzs10Op/HIV/7irGhyt6EIJYKH9t4mHe9JCBSgVmbDWkcuMcSZAdREUs13khYsOWIYVL6vKuBsOLIbuC+Q== 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 Reviewed-by: Dave Chinner --- .../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 0cab9d529365bb..8cdd863db5850a 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 */