From patchwork Fri Jan 26 13:28:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532564 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 82AA4C47422 for ; Fri, 26 Jan 2024 13:29:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B6AE6B007D; Fri, 26 Jan 2024 08:29:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 167A96B007B; Fri, 26 Jan 2024 08:29:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02E866B007D; Fri, 26 Jan 2024 08:29:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E88D46B0078 for ; Fri, 26 Jan 2024 08:29:18 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AD390140EF4 for ; Fri, 26 Jan 2024 13:29:18 +0000 (UTC) X-FDA: 81721543596.18.C270349 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf15.hostedemail.com (Postfix) with ESMTP id 14247A000D for ; Fri, 26 Jan 2024 13:29:15 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=vCE7GgAB; spf=none (imf15.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275756; a=rsa-sha256; cv=none; b=E2LtLvvM0KSaKxBYdo+ujBKcDRPLfrKsDER7l0ZZCyEAIj2cREs5dgkV40m6hA9d0ejwTc P6YMw5demE9QbMhlyTJaBcKGAPk6pcD3LlUXWK4y4Xz3CJ2PrkiUnoMCciH4t5+CmCQgZ/ wbscwbRN57Hd7xBY7EgDhDvszbthRTU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=vCE7GgAB; spf=none (imf15.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275756; 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=owr/vlw+gG+D7l+zahUOl4d4YuUBj7TuMNS/fLNtya0=; b=PZH5u7fmP9FzXllrLh4S7wELH37Y9nyTR84MKpoHlUqY+TOhUH/fxU/CSZOxWWjS3vnDBU RDrkgwktedgTzSvmgnEbHDeAq4D4lV96yhIchZR3Gznr3MrTHpygVRT4f8ZgOXDgRkepcw NloLfg2FsbbrRFaaExI2P+e5MSJF1aM= 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=owr/vlw+gG+D7l+zahUOl4d4YuUBj7TuMNS/fLNtya0=; b=vCE7GgABB7RKVc1xXrUquxSSXo Tm+y/gatJCRztthVwTFX3SDm2qMdDX0H9Thx0vNKqlDHrYiujhIH01vgp8bPJnMONQLQtpo0i6vgv x1yYUuD9Ot9Y1TKfMA5v/DA5EVQqQheYxTNJqa5WwdSY6AEMsWVdj3o0LFDp8Ua8w0z0EzQZ0iggj AmfKZ5m4Wh5/BXsHh9PDc+zQbJR/WBnxBWhK57cN00I4ZU3vuQC/1GjPVOe8L9nxGd/uO3Bb4/Iij HVf+QMAqRxy2vhFzbk1LGoP1mEKMcN3fqwMDJbkcNcszTPMwEg6HDROIvSZx558PCexj78+7vTL/G lW15wIiQ==; 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 1rTMGe-00000004Ca1-0B1C; Fri, 26 Jan 2024 13:29:12 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 01/21] mm: move mapping_set_update out of Date: Fri, 26 Jan 2024 14:28:43 +0100 Message-Id: <20240126132903.2700077-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 14247A000D X-Stat-Signature: adeb3kub9jhptyqku4j451wk4gqp4ezw X-Rspam-User: X-HE-Tag: 1706275755-750085 X-HE-Meta: U2FsdGVkX19nScSCmeHLUuV42F2zZiF5F3pHdPPHe5zRApzEZFwlZdRXzUSiZLr6TtiuaDiGaFlyoguy2hofbgUr6WsqwrGW+CAT2abNPeVk3CsHSgGt7zENW3W7BhHQcBL5Bntlh11TgTg2jmjltzlD9M9TGXCX6RyIo+pzPodsn1uRJIwBO2wtxYKrPjJf3EPXzh1BGFRzVOSm3tl0qmjfeIO/AmgL2Nl1NueeX2dK7weRKuhLRFydfVIzGGuk4AnWs5bKGmWroag3IceG/YvoIPLO0Ku3GvdtL/bSeAcwG7jWUXBeVbyGzNcMyR1YuYi7ndn2WKhYRpd9ar/NHefaDYjxsK2B8bcm/Gej6QCh61UJ6tHf51erV+dGOG4ARuPhCEv2iGIKxeOIytTcyT45ynn8kRIT+AWtM4sozg5ilrwrj/qM22C1y2w1T3dRUxBRZ1hIoZ8EKae3q80d9Uiduw7PaXwls/s6WIKDFzaHPqpbVmbAVahsFBStZU0Vg046/g/ZuyrOHUgvJetwTIy7RoPDe2djTzi/VnSsIEydC/pDWMdf1jZxRpEEaGPJavurcJUa+17iuK0nBLR9BJX2wfTPSxNEPoJv/xi+tHHNFwE9bKfAqDCoS/5UTG7rxHUQWnv9PLVAZC6eqos/Ve0xACSHeoRJwa3HETBEW0Z6rF9gsbBlz6H10Zz01LDph4SDPGnWQ+qWCGyEDrvDC5Vhj8BywjvyomJY3uI3bJy+7d3zEKITD7b3VLI2u0Q3z10LHGKKTE03eI7VQIL6ssPK3r3PBmi3grCmqywkhnu48jzNW/SvEfHC5Vj0A7tnf3OEEXIPvjj5KV9CrU9L5w8Kk7cWNxIQlpMgTLgODn8tMqOLT7kzasraN0V10OLK1PSnRaw0LgFMGzdhKu3swVO4hJ8Pb5M+eqq8hKvOVFrTLvIakt8S/kGzRClqOqh6YlT1fo3yEYm/D99v4LZ PAE0yvjP XyHIgLEyjH080XhEeqUgday3A6u+8/2bOrfz83DEH3mDeZ8KEl0zGohynJD4vr4CCkKVPDyIUYtfkyxolpDNa1sfnNo2CGmnyV1YY1/uK7WTnLUf3EvkDmx6UizhvFqrbXoPBt0Wm0JN4h/rjZoonLPCK7fTav9kdDR34soAyWYiqVU+ah0x1T3D9/mzx9wwZMYn/X6rv3geQbiYkULMhJim1gGIjQPCaYrZqvDXwSQhSDnuxMk0CVc7IE0jLzcwD9peeZNhdBsPr3j8Cc/YaKp/0zri/7OtSMYz5ZgHbEU7Sit7kmNrwSHfO3dC8wm2wCWxtXhHWpHbhKENQBU3754oKBMrukuY9oCNQw601v5EinAFU2oAcAJLp1zNJTTatkL0VJo3AepuBnnGzAjJ9S2vtg7VgO3NFiM8LKkmeGS8qeYS4FzDemWPvsOk6/iFAC6XJtRVVCpmgq2Y= 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 ++++ 3 files changed, 13 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 */ From patchwork Fri Jan 26 13:28:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532565 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 43B71C48260 for ; Fri, 26 Jan 2024 13:29:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C183F6B0078; Fri, 26 Jan 2024 08:29:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA0026B007B; Fri, 26 Jan 2024 08:29:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F2446B0080; Fri, 26 Jan 2024 08:29:20 -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 8C2B56B0078 for ; Fri, 26 Jan 2024 08:29:20 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 35A0680F91 for ; Fri, 26 Jan 2024 13:29:20 +0000 (UTC) X-FDA: 81721543680.10.F28934F Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf01.hostedemail.com (Postfix) with ESMTP id 7E8AB40012 for ; Fri, 26 Jan 2024 13:29:18 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=J1H+EZdm; dmarc=none; spf=none (imf01.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275758; 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=V10/A/+wNuc0NlJNXVGAXChnWVFO1SMkrJedGiK3O78=; b=syMTkXBPiv4hzZL60UM3MKEmkGiw73Siu+RLis3mm90WNNSW4xvvLaNO1DWPltU6ul3xWJ Gr+BLgCKJf75mDtS4x0FFi1SODaRtsuoX3Sl5/pnLBq9UnP5qBmt/T1HmI3fMcWn0ymZ7G +90Xc5ZRrDpmZl+1FVLQJbepVrcpIm4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=J1H+EZdm; dmarc=none; spf=none (imf01.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275758; a=rsa-sha256; cv=none; b=bgkAInsle/NVc/SrERS77RDKtIL+oxHz+qG2D6DCRloSqmXG7VstzLzaKmFWHDGbqwh5Y9 3o63nUMbkpB+JI8/mL8qv+NyaKL9VQUbY9Qp5iJ3gZ9fuKhPKb44FVrZ/dHsfWhPzXlkjl MNDhJRC7RkFOAqToFWJv4wTFwevzJvg= 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=V10/A/+wNuc0NlJNXVGAXChnWVFO1SMkrJedGiK3O78=; b=J1H+EZdm9VT6WaQwDXIf7WQzZ2 neIrk7Ry57Zndr0qGsUVy5pE45VTLlH/vAX+Hri7DcR5uYvqhIjnA4oj/M4Op+o/UO6K9nJ/BU1SP vQPu0W5B1jY51UZ7HmnKd6k0U9R+Ijlm//w9apBs8DwZCQ8OKQhjdXc+jBCWxobWhA9XM7GEFRZey I68z+53WHEgykpnFPVyGUGhDW4HNMNWj+EsuAssuhkXhWj0Yypc7FEiXzkFvvN87YjJuxfWmRq6Zf v2LXSDN4FRsJ1fHUGZrE52Ep7LKpIkmQv3o50EV/DIPMquQ9kIetFBIBHDVIHMPMXt8gW2+SZyLqk GmmjBzTg==; 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 1rTMGh-00000004CaT-1noG; Fri, 26 Jan 2024 13:29:16 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 02/21] shmem: move shmem_mapping out of line Date: Fri, 26 Jan 2024 14:28:44 +0100 Message-Id: <20240126132903.2700077-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 7E8AB40012 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: nm4sya519rdqmucgtj53k3s1gbc9xmy6 X-HE-Tag: 1706275758-463078 X-HE-Meta: U2FsdGVkX18Ykfd22XjLmDuBVDLQl0q9jV29cwBm81CKA4adild/YsizuuBN0JnR5amaeokPfdfSMMvuUthjs/oFZ8hzR3uAY7zWFnIWEVfU5VD5gQ8Jc2piiFBlXmwap4iDn4sg5kj571UI8SzYSV5HYbn1gCPE8dFa79VcqQLQSPufJZ7Zf5d+DvgXaJKRuJsuBs/n0hvrC3XPcPxDiPiBfga1z60Du+y7v++xSD1yN/Emgh1ndi/JYQVi8BvEavYMEU4nJifbHEIvfZ3buod52KLH5mSIo1RQKag81YK3RKoLxcAGR+S5vIdifDZ9gSF5j31QK9ZEbeVtHZK2gT7fCafbEpEcs1hyJrSna8OEsdrozezIkTSzGnb3C34wdZo+BhbudXDZeEIPd9xWQ78RFJi6hm24fOWPaftnrs2qhK/+JqrCjZ69mFt2TP9sCdoAQPMaehfhd4TcLXSWo16lMvqZ6wqcvrzrbw+KhP0NpQIF8+fLiDJj+ABJq8GJaoU1MMzrVQ/Opk+oyxgSCbqbFCBWRq2vM3blvr2sn0F2l6Yym+9Qy07+sAkJ48NPI/qODOjH8KbuRzsG6WP1zJcTUsS8WJBqNV1bqo6SuEOigQbYJ7Q9IXMyIb/INTreWJhMm38B4TJJjiJMCG8nlmJhbrFjn/uRp1VuGdVC2GbmjGf8HAvY2sapbV/IzrCPE0djQ2lGxT1KNeFQ5o9rWquFnRf7X4p2QPIWinlbh5mf5I8FmmgOGhI9bROz104ZDxRx4n0u7rAk7ayTb8q1Q74sWa4QRa7l2eSzGYB7bPMuKTPmPbUozzjROdfRSTlZ0gpZ7ymRDKOwjHJg+xXjROpv8643evR0plpoBvcOyKv4Dznv9w+dQloFwNceCNdqxyEi/VqeTi0Pv5K2xCoo+aeoqVGxjAuw7JYgn+936HHWBD9RCAucrmMBYXlBJCtYUyd35Vwe1vckqI5xzGG ijrhwiBa wE4ZJXUYneyDUI9Ts9SLl5Vybg5UNq02wJ4fmdKkcK3rEaO/flNPiJiN2fjuWMhsCzJEQwKFaQdj8FgXsxEtLX3jRgdCxHZrJk6BIzRp8Eo+S0lRdK4LkBdXqdAfWBhS1Fv5k2QKOYG79/O1CMD+b/v4Pjk9dumbQT0Rno4wIoYheN7wnDw39q0BbxAgWAjvNpmDfGhJkMdOxxu0Y5pYHYZhnQN5qFTEt2zwVxhgvyA1efzLumiky3418AHRZWYiDjzJGCPDqDhdjLP6wK6bofT9au4bJdaMWLpbamjD68lXepZRJJOM+TK86t8ftMLfSU+ntJMRwBELM7qB8MwgdWDA9mxDoSqQoCd5wNh7UiLuba/dNkzocxwtUT7lgC8kClumqnAsSG3epRoRmZpONQa8z7exb3Ht9UepPd86deOcJbLsZ3yYtPwgPUIBE0NfeaV8PyhLmRg9JU7g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: shmem_aops really should not be exported to the world. Move shmem_mapping and export it as internal for the one semi-legitimate modular user in udmabuf. Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/shmem_fs.h | 6 +----- mm/shmem.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index 2caa6b86106aa3..6b96a87e4bc80a 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -97,11 +97,7 @@ extern unsigned long shmem_get_unmapped_area(struct file *, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); extern int shmem_lock(struct file *file, int lock, struct ucounts *ucounts); #ifdef CONFIG_SHMEM -extern const struct address_space_operations shmem_aops; -static inline bool shmem_mapping(struct address_space *mapping) -{ - return mapping->a_ops == &shmem_aops; -} +bool shmem_mapping(struct address_space *mapping); #else static inline bool shmem_mapping(struct address_space *mapping) { diff --git a/mm/shmem.c b/mm/shmem.c index d7c84ff621860b..f607b0cab7e4e2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -254,7 +254,7 @@ static void shmem_inode_unacct_blocks(struct inode *inode, long pages) } static const struct super_operations shmem_ops; -const struct address_space_operations shmem_aops; +static const struct address_space_operations shmem_aops; static const struct file_operations shmem_file_operations; static const struct inode_operations shmem_inode_operations; static const struct inode_operations shmem_dir_inode_operations; @@ -263,6 +263,12 @@ static const struct vm_operations_struct shmem_vm_ops; static const struct vm_operations_struct shmem_anon_vm_ops; static struct file_system_type shmem_fs_type; +bool shmem_mapping(struct address_space *mapping) +{ + return mapping->a_ops == &shmem_aops; +} +EXPORT_SYMBOL_GPL(shmem_mapping); + bool vma_is_anon_shmem(struct vm_area_struct *vma) { return vma->vm_ops == &shmem_anon_vm_ops; @@ -4466,7 +4472,7 @@ static int shmem_error_remove_folio(struct address_space *mapping, return 0; } -const struct address_space_operations shmem_aops = { +static const struct address_space_operations shmem_aops = { .writepage = shmem_writepage, .dirty_folio = noop_dirty_folio, #ifdef CONFIG_TMPFS @@ -4478,7 +4484,6 @@ const struct address_space_operations shmem_aops = { #endif .error_remove_folio = shmem_error_remove_folio, }; -EXPORT_SYMBOL(shmem_aops); static const struct file_operations shmem_file_operations = { .mmap = shmem_mmap, From patchwork Fri Jan 26 13:28:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532566 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 859DFC47DDF for ; Fri, 26 Jan 2024 13:29:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 142B86B007B; Fri, 26 Jan 2024 08:29:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A2D06B0080; Fri, 26 Jan 2024 08:29:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED6596B0081; Fri, 26 Jan 2024 08:29:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D4F796B007B for ; Fri, 26 Jan 2024 08:29:23 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A4723A2688 for ; Fri, 26 Jan 2024 13:29:23 +0000 (UTC) X-FDA: 81721543806.10.9271324 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf10.hostedemail.com (Postfix) with ESMTP id E3111C001E for ; Fri, 26 Jan 2024 13:29:21 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=mQKrs4ng; spf=none (imf10.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275761; 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=Ai62sSrlh2/pqyKEZx0ovGIMBLUhqMYLKAXhWcyLh60=; b=gtGBj0Nf3aQ2LKztC/LtgVI59SyMfp50DOULxegQraX7sOx8rLpHoM+cDax+wSzTCJjrVK fdstE95Z1TUOSHHICH7uIAnpjypo9Rk7nspFOwh3eOhdpzwa+QlcGAmoIjWT6AKNC6yo2p /+3mtPn1idHj3MUfQIJo8Jtnir/y2f0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275762; a=rsa-sha256; cv=none; b=WHQRSYB661g0m/nH+HeMNqjh4l4ZrqCJeTq4FZqlJGB+A+rEvWrFxfEdbu/h4q4mHKlG9w JCR53WGJ+WI3xCk41ZfUd9FY9pLvKhhWdYWAWHMR0SoZM9gpQqhma4yvbvMdwKSl1UdyDo qaLFknyKU37PLVZLdGjHzCUdM/X217o= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=mQKrs4ng; spf=none (imf10.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=Ai62sSrlh2/pqyKEZx0ovGIMBLUhqMYLKAXhWcyLh60=; b=mQKrs4ngo4qu6BMNq52g3Xoh7/ O1zh9BQRalb2rgsldg+P4cm3P79MSZ374U5u2xMs9aaCXSTKGh03bTGb/fEr3qiMyn8guEcmy+SRw JHIN6C8IUSYHKbj2Es1IUtbK5021qHQt+HfO7TM71CzncgPPbJt7BWwm/rZtDZAM7uumax6KLUJ6G ghdizB1jiJ3qdlvd0MqYA3bxJufSlmzYMLnhqB9xerL7YZP7mRcNamDKWenB/tltXQ14lteiYxVHx AWFrf20QD1Np/CHZ+sEpXUp1sShnsCrrSaPHyLxPfA4KaCH1MKn+lzrpxVLgTrH1CiMDOwTHL1g41 DcUeU/mA==; 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 1rTMGk-00000004CbH-2wFk; Fri, 26 Jan 2024 13:29:19 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 03/21] shmem: set a_ops earlier in shmem_symlink Date: Fri, 26 Jan 2024 14:28:45 +0100 Message-Id: <20240126132903.2700077-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: E3111C001E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: u9fsh7jbzipz979uwgzqop5xaij3ii1q X-HE-Tag: 1706275761-982887 X-HE-Meta: U2FsdGVkX19fR9Ulqw9qd1v1BGB6J7bVJ0NLaTWBUaAZd+vjmQE6S1Zz+hqazgYEw9pIYHONTEn8Y7SRtHVx3nHqK5Z/0LFguS1R1pg95pWbcmke10KyyKQN2GXjiiyrLDdkvdSUMn8flUNHTXMbJkJmvOYHrHw4OuG++HN7H66h965PidpKCjPLlsiMKW4xwSQ/w/DA9QvcgZmKLIOoch5D1uu1iHrZAODMame72R5HmmO5u2UUGLjWuD4gR51dyoAsZ7gflbIllWxTTNm5Mk++Z5RDn7D1H5/+jc0c5aSA8ovf5bRkNd1y5bioWkOozTbW9nGxNyvn5fz4t8NrPxNsMcy4ONPlaBUwgaK3HFJ1OH9E4AYzja7FYfpmk4f4MTZ40bo//7HRcsFt4SQVEbAx6T/Ttic6IbKv1hU8cuqRJU4aLkAsbHRWD74AF3MQQXxaWN1NvVOicnOSeou1fF7dOSpbHTvbON7zOsXm3eVHuJuwoAm/TWM+hfNmqAjiuarYNwwvfSHFAT74iZrYh7dfxwjWdMmL3WuQQ0uwT/WAvSkixckOcbDtGkMTrH9TK67xRgIKAQ6Uug4VVRRTS/kcyc04cSqFa82K5dVvakRNnSnCwLf/cBDfOk0Gah53bBVr11zJWGiDkNLNs07Kyi6y47vW94NShmdexQ1kJuAUuq7MObWGfborxUcc6szzCevTpkAcEFw2bFI9AASJsoQg0LJzWyzLdvQLWCmSUre7oCC+bwO8jcd56fLJ9AUvt0ZYOZP/QDCyFzQrmKXEiJV4vdx36U73fgpo07xSBvw5XKAE+cqdp2+612/Gn4mZmh2AkKdSE58zXHRaSU+8QMJPJbc/RQCBg1CwVsPsdeD6eaVtHUaDG+u35ZXbjtv9vvb3Ah+qi5DfMaSW4FlggXSyypwhVKOlYDYESPtJ0npSCaBSMCu0QlxXziY51kLQaTA8dDqapZ+GEFqBsgR OgkcqlQg qh19Ts6Ojj/2EnrVvTjS/yqGOYDhWp1c0MyAVD0ngCNgkEB2RjBWHE1bfz2gAgh9npTXGhUdyh4tz/2wqMUOa7kHZC7t8CGw1MUWDMQcBwD9YiqOq33tZmcx3UAVcZ0IgymEtCJKYqwPujtyO0Ay2JMwnCZf8WN2vTVBWBoNbdZ2/KLsYB9R99TMc6RuMVo+TPRUbWE1Rw5ZThEDwblbl1fCkexamubdpiNSq+KtjULBIwrHk/0sW9X7s3Y9IGafPPVBz8hTytwHbACTDQ569+HntCqlvZg5TkOU3lvPMMdaZGYhVFpM7oCchIf0MX7qACz7c+uAj/n6hjnRy/Uc5fXRdJrTc/y+PrgLB2zyFB7p75ex05nVD2uTr2+wh2gxLMahvHv1tWIxkPHv0MHpnF7Og0rCwwOawnjranxgWdDe7ADPk2r9jX9sBr5oaYyr95t81AVxLwQPlh6M= 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_aops 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 Fri Jan 26 13:28:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532567 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 25889C47DDF for ; Fri, 26 Jan 2024 13:29:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A913B6B0080; Fri, 26 Jan 2024 08:29:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A682D6B0081; Fri, 26 Jan 2024 08:29:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92F826B0082; Fri, 26 Jan 2024 08:29:26 -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 7F5936B0080 for ; Fri, 26 Jan 2024 08:29:26 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5556C140EF3 for ; Fri, 26 Jan 2024 13:29:26 +0000 (UTC) X-FDA: 81721543932.13.8208D8C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf12.hostedemail.com (Postfix) with ESMTP id A732840028 for ; Fri, 26 Jan 2024 13:29:24 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=jH19Kj60; spf=none (imf12.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275764; 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=N3rE3t+7Sfh1ch+jG4/rL3OFi8MZBkGfEkeN2S3CLmM=; b=iw44WNagt70eDgPIQpc/yCcyJ/+JULI51lKDxXTqtQZ58i2wG7O7gTERymQMfMsWNTtgJZ R9nJAxzRezSd1Qtb4S6Ofu522Uj6tjIRevn0//wH796uqHwbMsoZseVq0zkVDB+k2veXIO Fi9s/kS0NTXaFg1seoNttzRr4skdRKk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=jH19Kj60; spf=none (imf12.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275764; a=rsa-sha256; cv=none; b=BNpqCZaLv8vlX031evZnZoR2IGn4ol45xRYPxQEoPeu5EB9AxeDofkGqeZp8tpmt0+kH/s 7Dvv3ElsnPD+9yMtztYibBtkMmVB04HftfU3hL78fDAxsmJwIl5q95hXAyI5kAG1co/I4v rcEcfdudD0In4PSGrLa3kIrHTPEFij4= 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=N3rE3t+7Sfh1ch+jG4/rL3OFi8MZBkGfEkeN2S3CLmM=; b=jH19Kj60uBDT5ZT7yUS36ynTVX cmD+U0mwww+RdyWA75x0RtpSmsuslCrGZVbWSAdM8/55p49Tc77N8oFKzsOHo6pQGPJuRyxxQkvLE QvkBzZtnVnWU9sMc44kK35fu+5k9buUPG28aqwHXTgvAaG1YhVhrnnjAAhSQuGGmeiXsaMrUrvwZ0 G2PvG0AEf7veIxjQ1TmXlO1ee7RCEBnM6wrkCqjBv3Z3+XVcmOtlDnSEL4XlCRJRQMNvre6lkyLim yCgcL0EWFEACRe4+puqj0/shszRBRqMYMaOVC7pEDfEgc3jBaWn9a5mn5pm3wpUEp0nlXBpI3YG9V JWpJIosQ==; 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 1rTMGo-00000004Ccm-01iG; Fri, 26 Jan 2024 13:29:22 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 04/21] shmem: move the shmem_mapping assert into shmem_get_folio_gfp Date: Fri, 26 Jan 2024 14:28:46 +0100 Message-Id: <20240126132903.2700077-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: A732840028 X-Rspam-User: X-Stat-Signature: aacjosssfxfe6kffgizgyi45khakq4mc X-Rspamd-Server: rspam01 X-HE-Tag: 1706275764-827605 X-HE-Meta: U2FsdGVkX18nx9Gmwen0VwdFozzBAHzl176jwRH/Ic/vhCv3L/Iyd7P06+10z4sY6BpKJnQ+WTSFEMniSca5GpEMAvN+JQFgfEnNFIOiLrf4gBULAYk2Yy0HjIEAziYM5vOiyb5hA+5w9fbxhlMYeiKQ/juAyp8NzB1EYgbIOT1ILl88caUipI8tnSopNnujQidekKpWCySL1KmwEcb4MiHLQFWJrhFGONvjBfXubZ7BgwK+QdibACPGTXhEiVJdAu1KPo8ZOhpvZhM59J5Pgdoicy6cm32XFVKfxhO0GXoZQ3mBurLxcVXXUI1hTqJ0FiFhD9D4tHmRftb/9q5KNv35X7b6iT790FkfarTyD0djIxCTChkv8I2LomVWdU2wOha1Eo6fNVRbF+mCegRlggqGpV0v/b9QVTPdqatsmPOh2Vr2NqH6s9bj5RR7KZ3/nZd4PdhvIx6v2CH1nx4HmGuO3AYROI3eWWEJ1cM7G6gGIXfLHkqv4QQW4EP2zPdHEYXlB1lDk2uaenz29CjTZ8GauMYQx0aXQRipMfTPLTiZoPLNhdyNuap2M2E5qdRimnk13L0Eh82R7IQRQrEpJroO29jLwCs85m7GElKtKb8k+eNn4zVCu0hD6UDM0XJpVb5l7COJZq3IFL9glWK8NwrydfiWoLDW56fzMhjPpNgwtK31pHSQR7wiJpP8h3ke0vp1m9mU3o/tem6NnyKic+b9lbpPRNUhAsJ/3fH7o5UjkKY7msrtQ/MwR1KumSinx7esu/P2D4d6K1vLyoisAKgUleghQ3OLXRc3jr6EHK6U4qOZnJsCzaUi8iPu2B5l6yQjZ90oEZMDoYSveuMK4vb31AiUylGx5/Xi3rw2xRqblqHCm451Rq/x8uxtelj//SZavmEu13swyG7HePEH7yv6NQzKnHChuwkgQqrXlwO+XXPdaUInteQkV3OES/mHrTdt2ZOSBjwNU/oBzIP JHP1gId7 FHfHSj/vJKkiXMNY/05KVwV6EVKG5qN69hmLK+P6LaROUMHNBGu5cX4G0aTGlB+G99NElrHAN2U/ahXSOYHvMbsz0oKlBIkjbFheF55owSMBcLymvEu1012uElbc1Di7CHsUznwtgGMfz9fu9CsxT3HsJr1q+jaYzGVoGevGdyoEs674QKAtNEbmWn0TI9jjUAlHkWvXQ/eWwIEYXZq9vzuI9Oo9XbUzHMzupI1b156spGkFBpiQelppW1RxPUURYNz4C3vV0/r8fOCMSpck1Z1A/+8PmMY41u/ldNFjgvnzWcAq3/nddEKEs6mEluW29f7gzxsr051DPYQviocqnm1+/sVYUg3VpQYL+gGEqiVM7+81LDA6sLO6J0muo3ZBN03VhrTRvHyF7rF2vOFxHmxDYYLLc5z6HFgpf11jyY7WcLzqW5icayv5pp+Em3mH8g4ph7UDpQvsLLAzsDtn0eABh33nJFDxDAJ8B5H/x8XUbvwmMvJlQitzyS3eN+ZQl8B3APPGxrcECmGg= 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: Darrick J. Wong Reviewed-by: Matthew Wilcox (Oracle) --- 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 Fri Jan 26 13:28:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532568 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 10EEDC47DDF for ; Fri, 26 Jan 2024 13:29:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 846096B0081; Fri, 26 Jan 2024 08:29:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F9716B0082; Fri, 26 Jan 2024 08:29:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 673826B0087; Fri, 26 Jan 2024 08:29:29 -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 4BF676B0081 for ; Fri, 26 Jan 2024 08:29:29 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2319FA2691 for ; Fri, 26 Jan 2024 13:29:29 +0000 (UTC) X-FDA: 81721544058.18.6D72490 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf25.hostedemail.com (Postfix) with ESMTP id 7BFAEA0008 for ; Fri, 26 Jan 2024 13:29:27 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=pum15BU6; dmarc=none; spf=none (imf25.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275767; 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=EXl5jDeu7XONmlWbPRrm0Xu8RAKAjEJ+6x3o+QggOTo=; b=4R5C19UNeUp6Sa+mxynPSjYiIFglbw5aAjXw1/M5ELL4nX0rjiXDHjijGSCTR8JtuWFswE 8WL7JxnF81+jdGBD+JXdCbdhBMod8DCVIUiNybij+jIXb5BTp2XoHA5G77s3Gb1OJn/stY Zps7WfFpa7NVp6RVVfNKc0Syw99j4jw= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=pum15BU6; dmarc=none; spf=none (imf25.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275767; a=rsa-sha256; cv=none; b=gwDyIhUpOtjbJewDcFOef+Dr36ctv5+IlmdU9MLJh/nr5Ol/YQAQL+rnhYDFgCNim6UksM +NJH1BMxFnpmDJOPyG9RC7AOnZDh1382YPEfgIzf81rjTdhjNE393mNjHKATnQhwvn8ZNj ouEEh39klB1LgbBM2GLEWUMS1FjzU+0= 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=EXl5jDeu7XONmlWbPRrm0Xu8RAKAjEJ+6x3o+QggOTo=; b=pum15BU67e0aLpR1792YzR24oi MBaFfufHtCKkulLHA2z5SDqiyeUyDGOqykVa+NNtXdh7PNligs40WxGAynkcqKEJlXH4gbMBOARtv GRVUyHmGU/VqlPahIeBYDKyBRl7QUKQU0nFYi01Ic7e4cbH9acLTb2nBIRGxGdnW+oC1xSGSDhU5s rnVDBPv6nK+lRLt0CxXB6om0Czr+Ylfytg6QF1d8YX1TqaLJeYa2XMtRrGcWKyhoWm5iWzB5n76n7 jzpRM5Z9aTH5QS+ToEDinsikPO9sOsZZDWXVZqAj+dy2scmGcWaZ4ycSS21fnFlZhP+TQh+/uDm3O Sv3vMLDQ==; 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 1rTMGq-00000004Cdo-46Cv; Fri, 26 Jan 2024 13:29:25 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 05/21] shmem: export shmem_get_folio Date: Fri, 26 Jan 2024 14:28:47 +0100 Message-Id: <20240126132903.2700077-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 7BFAEA0008 X-Stat-Signature: nzt6ip4z3134e8fa73jziq3hpzdz3bk8 X-Rspam-User: X-HE-Tag: 1706275767-550884 X-HE-Meta: U2FsdGVkX18UT/bvIxjkYVD6Ex3FHmxVgnG1tp+1p6/YBezNEnCqlNHfSWU3WEET3R76h5ZaH9RE2sP5pNOmDqEc17CPPpHFAElF5r/54RBNrQpy+/XmB2LE+ZK6hJYtWEV8j7eLBEDIMvPLCrEV3yiHSMI63sKvmZj49freHShs6ZMg8C0BE8XzsQA/9hue52onXUF2yDB+m8vidmzgsczYSiXv++wRL3+vzUgI1pYVGEW0Oe1KTRqqkRlM+S7HC3LvsYWMqHobI2/7z8Zi4o0KoVxxzdBC5xzSxg9p8JsqbHUAcvCXMMKIGcPcdfWIkx/TxQx7QcQeJJUvQPpHsHLJO6VzqtDjff7TS47dC3j6IvzEOR9mxp1gC32NnbIICmbOlY5b9sidi8I0Oa7pjUVJ3UZKIFOJdBb/Q/HYl73XJg6n6InqPsIKKAVCc2/1pmWbvba2jWqSF1/tYsqqNs92Eq3Gy8q/boxFO0uKNpIHlnIn8IsdhwtFpvjVNaGqm8tfz1NIMtEaesvAgQzA/ho11UfLKTTZf33iTWnvIc+ed/L0lfy/VBkrePGnijSxJXN7EAYTqzq5ihI9EBmSVFIJIGUqQMVRWWJjLSaDj/ATJpdERyBkvAqiPU+GQJDCC+lDtXsJoMeT4MssoiybMCUl6RssrKc/segkJmpnu2alt6P7tYeMrXi26IIufMkWB0Y9JcRDo5PHHEful+oBw1ZA5w5mkNPmIJwg7vlcqK5TUfTlHlwQ5yPI0qiO4v1qnkABWIGQVUx/C6rSQiBPRwMdazng1WI3CCyamvUwXCrMWazFtTbYoMf2t6xijaOVUHg49/TParzktKDR4pIrbG8ZWT3WXTaVli5VPEQvSuYKrKGkEuu1aDyGA51V3J9zzA47x0Ngc8Y+Y4qLFpKBqySY6G9WbH0PCJIldkS7aLnRHprFhdqgRpxe6FlRPbNIkB04wBrpHtReCRppEoD XLovkvKz sw5+StYKonJKZGpGJAvCIMdYfd51bvalF+K1MVpFbum96brljvlq7DhGJS2XhfXo8ndRcoEiaBzLGXzYkzzNg6fPDWQwWY4QGfdqU/wJmF1zpayXVDClPhC5kk1L5sRswxtIM2QFGeM0xpESjHsNPYdNCvUzroluM8WS3w8ujohe2+j0jynQ/YRpFzbKwJXkcOHyhFaiY4UEsrfReEL3Pf2HAecSmjKYuCtMhFowuQe9+k0TnkpZOqcowbFieKarLbO0zgNBEGRFmbFU21p15uARqou7AftmUm68z7so4QqzOj92OZz0hgG5d/rNQk8gP7g4GRRSBSHehlbydn/IvonjNEPSB3jh2G0AghguXSaTETNy5ztzZjg5i34Ow0wafmFgKv9YY8DtdbnCBUSt0e/bzlhLNAiLL5Sw1gCGPsjqWbaiZ+rAcMKVdNJybySJQfrdqJvebNIdPKHQtOmT3JaOfZk7aynR/WMIHTWEOpdx5YENed8Lz+YyDW5GDXpf/IY2RNItNOI6Xofc= 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: Darrick J. Wong Reviewed-by: Matthew Wilcox (Oracle) --- mm/shmem.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index ad533b2f0721a7..dae684cd3c99fb 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2137,12 +2137,27 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, return error; } +/** + * shmem_get_folio - find and get a reference to a shmem folio. + * @inode: inode to search + * @index: the page index. + * @foliop: pointer to the found folio if one was found + * @sgp: SGP_* flags to control behavior + * + * Looks up the page cache entry at @inode & @index. + * + * If this function returns a folio, it is returned with an increased refcount. + * + * Return: The found folio, %NULL if SGP_READ or SGP_NOALLOC was passed in @sgp + * and no folio was found at @index, or an ERR_PTR() otherwise. + */ int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, enum sgp_type sgp) { return shmem_get_folio_gfp(inode, index, foliop, sgp, mapping_gfp_mask(inode->i_mapping), NULL, NULL); } +EXPORT_SYMBOL_GPL(shmem_get_folio); /* * This is like autoremove_wake_function, but it removes the wait queue From patchwork Fri Jan 26 13:28:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532569 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 C8878C47DDF for ; Fri, 26 Jan 2024 13:29:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D4B76B0082; Fri, 26 Jan 2024 08:29:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 586526B0087; Fri, 26 Jan 2024 08:29:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 428186B0088; Fri, 26 Jan 2024 08:29:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3529E6B0082 for ; Fri, 26 Jan 2024 08:29:32 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 12DAB1A052C for ; Fri, 26 Jan 2024 13:29:32 +0000 (UTC) X-FDA: 81721544184.30.EF27C6C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf21.hostedemail.com (Postfix) with ESMTP id 667CB1C0016 for ; Fri, 26 Jan 2024 13:29:30 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=UeYennuX; spf=none (imf21.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275770; 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=0iKTKDcwlGTInQAMwUK2KO8AY6uPQ9BP+hArH0/aSbQ=; b=tr+/HH0pDXWaZnkztXQkL1G1pgTuzFl9eLvFv0Ee4ksTZ9OoJFBNYoCDXIrq2Cb/SVR2Ko bkeLZxUd6w5mYErSL2Jc7mcpO/V6ViyC2c/lWyNihuWlsFY8Gd14IUJB9Fnw8cHcUnTvpU J6ZqsML2wynBI/In+718if4MgasXSzo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275770; a=rsa-sha256; cv=none; b=Bc6c7vePhb2fgWTpOcArWBlbRrgpSJLURd1Al17Zde+asKus0s2PVJ02m70hFFaW6s6s9g xX5BuhcIzHjMrg9R4/UQ8ClX0h92n17cAhFVVf2kNM/sZfsYZW3Yk0rv1V41GtwxTmiEaK /N2ny9AzOHz8kAET86Td2VsVDa1y5f0= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=UeYennuX; spf=none (imf21.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=0iKTKDcwlGTInQAMwUK2KO8AY6uPQ9BP+hArH0/aSbQ=; b=UeYennuXziCc+zdB372FuC0/HR hb6hwObADJ+u0qirrQQSkwydcainIxZiErI9BUMvAeuIgioUBjkXfn0dz0Gx6FjLryifXOqo0JZai Kq9uCtM8f4VKyQaLNpLcZmlNzbMkerdRpZVjQvFLw5gH9dLYYUFCmKP0/hdOzi5rwuk958xNLk3Jk zheSxk0hFT/FcGN+8kdqe8fKZYovpF30hiwAj1n31kuDgmh0jCcpHc/vos3vyvjpxO3bnKqYREcwz bHZet5+xHphrBFrHS+eE2iUHyRnTyFmOT9Hk9D44NQnmNOFzM1uVw+gtYUwXp3UweuimJByQTHHuV XS26AYNQ==; 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 1rTMGu-00000004CfW-0d0W; Fri, 26 Jan 2024 13:29:28 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 06/21] shmem: export shmem_kernel_file_setup Date: Fri, 26 Jan 2024 14:28:48 +0100 Message-Id: <20240126132903.2700077-7-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: x6m5ce9rogrs56s3arg4fnreujw6jbgr X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 667CB1C0016 X-Rspam-User: X-HE-Tag: 1706275770-842514 X-HE-Meta: U2FsdGVkX18tzodn/U1INg/sEwJgChaeDr4xtzgioxyuxuCddxc1JLQJH2izkOWzN39LrqN8UsKK3KPPy4ud+Z+MolGNx9CPcLRJ8Jes0mNz8norJ8g+L5LDp15ornmahG77RoCSRWJuabu2/D61Z5iHU4G4iSQJNdd6Xjt+F3PeuBDTJd2M1vU7XSX8i+Bkx9av99BWvpqjqgRb0IxNNRhWPVhN8Jgnd4qNOtDfwPU+3S3aYrf6lamIjPXpxOpOaKusnKcC7ZCc8OJM6QrZgIMdmVE+GaK2PDBRikLniQwgV6CFQVG7/8fQ6Zqv//Ck/AtMbrj/KQ90JlLHWFQUpvYLPudZShOkAKLjbMYCyAAJSBQnJ2TJyL3179hb9hbhIBJfPRMqeOB5VMRmpW4ShMr84rNbLyjOG08+XOIGM1yK2oSc7IOaE1Cx1cF4sA4doMMl3GeC/n+462eVym7/IkG7LtU9s8Hie0guLYE20kkYfCrCbI9kYcSPUjWLGzJgU/YZ9s85T9vBaOVxhRKMSX2s6/uQN5zKlVlxbKHh4QHo4hBjCEADrMNVLGsfgVNmtQ1/aU+9MgP4h28Z7pnTqLt5uVjT42GyDZg1CBWFRiyhnHJuCco3gGRkgrVZMVj6bm83OKnZ+ltUBx8wL7n84oPMtd+2bdKbhcxbA0sGtcOYNk3v2VSRL3FF0Wp7ftq4CthZAfm3t4qZTuVrES53vCVPG1q+daPAlprpI97+g6iNV6pn8ZfXwirdxJrTWTF0aY+RLEElZlS/Ioc3bYPWHNv+S5xevW1HWoXbj5mLdIik+c1LVXCkWm7qWNuvwLla6mVWGsVwfV8zSodY3EnW3ZBp/+fOmUs5MQvxwP9rGLJCIfevuhbl31tBdCN0XMPn90HouNyJu7/NPo2JM+E4B22g9ws6elEsAVaVFLhZkm6nCFFLfbvVywFdojlexhCMl9SnDneLSaOrKaRqwXj +/Dny0Bb j3OE9y8fHWb1p0URwWnOB+l4iVBNYBpPm1ZdVVCJs+vYOdXPT4U5nn06bxDKSwBkOXYF9i9NIEIHxDUKkU0KqWqGSFaR4HkLDP7plr/pHldkJ0sqFIdKmH2GMeVL0Yibrxwn1kDZuP1FlHfNI4qMfCSr+UOjuWZYi4tXuivwIHhJmQD97Ru7NcjB7A4ZINP71hqGDyY7v41VVkbvNaZN6OXzX+j/6jSalAb5XGgeBx99jisXTT1e18UyJ7a211OgWSVSolXZaG8p4rAYWQmdIcqrpjRYPGAV1uqIJdJAzPll/1Pdv+Zj8j5c6hqA7NhvBnMaccsb/0fDdEF24B9IoiEoxo0ptAkOFgGVFw1XsnKHOUbxEAY8mjH5fyWCpQ1bG/k2DJY/th1XB/LOC3ryg3tDjuAIQYUztUcjWf0CeK3Xdmx2PM7iz/S2TKx2No8UwLs9b72uZ+VLCbG8= 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) --- mm/shmem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/shmem.c b/mm/shmem.c index dae684cd3c99fb..e89fb5eccb0c0a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4856,6 +4856,7 @@ struct file *shmem_kernel_file_setup(const char *name, loff_t size, unsigned lon { return __shmem_file_setup(shm_mnt, name, size, flags, S_PRIVATE); } +EXPORT_SYMBOL_GPL(shmem_kernel_file_setup); /** * shmem_file_setup - get an unlinked file living in tmpfs From patchwork Fri Jan 26 13:28:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532570 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 B9C61C47422 for ; Fri, 26 Jan 2024 13:29:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 538806B0087; Fri, 26 Jan 2024 08:29:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E8F76B0088; Fri, 26 Jan 2024 08:29:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D8466B0089; Fri, 26 Jan 2024 08:29:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2F8C06B0087 for ; Fri, 26 Jan 2024 08:29:36 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EF2B1160F35 for ; Fri, 26 Jan 2024 13:29:35 +0000 (UTC) X-FDA: 81721544310.25.9429656 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP id 3EECC16001F for ; Fri, 26 Jan 2024 13:29:33 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=hBXzXlpS; spf=none (imf08.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275774; 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=1ZlI1ZeOEvNmLW1NU66Umna2PQgDHzmJWRjfo1IHrxA=; b=EgctxG2trBydsmRoS6fdUScK5dYDHfG+aYifo15N/BDg19gUndjD/sQYmEXVc2Q8vcZrQp QYOL1JYyegq099IBCmUNd6jWJsZUn+lE1mwUNfba9VkBkjj+tXTGQ9DtQuxqQs0nF/no1d wigReGq3vs6ITp9ZG/Ag54GVRSzATA0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=hBXzXlpS; spf=none (imf08.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275774; a=rsa-sha256; cv=none; b=osfsC1qtiaD3yaPtCa9UsmJPAZKtAF8TOpO+Ns6AaZUfAwQD0A+muLX9/9CGjDHs1U7W8A 5V24R6+x6s9BS3sQr3GyLeoktCxVeCh8BsGY2G0rE5sLxusBrAIKG8FIy6c8ExzWQrRCK+ OHNgJ954ftljLkFFOMKExUyntF41f3s= 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=1ZlI1ZeOEvNmLW1NU66Umna2PQgDHzmJWRjfo1IHrxA=; b=hBXzXlpSNVfwODPh0iAWHy5XE2 Hfntstaa47+3zsTC9HXLiMvZQcVj6O03twOhOK6sB6yQ7L8H+JIabfU+ALOLsBbqYrQInmBVtRjOZ 0gVY/MvRjLVuwMcxSmb/QApth1Ze7qjV6wJ3ZU1ocbv5cwpC8Evwz1nU+3qN9oA6LHrW/pwrfJK3v Fnhb8fbzAT60tCdce84FedQ5jOY1+4PaTrQMI7jP1eNgExBD6hAMRNcy7ICC2YoWmoN0HudxwXuG+ P0eBnPJT2yNlX3nu9wwNPpscRVLswTIpaKDPw6x0ZZM/DpKawySlvRxz+oP5AsEts6ZY0fM9dYgB1 zParwbug==; 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 1rTMGx-00000004Chj-2hTj; Fri, 26 Jan 2024 13:29:32 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 07/21] shmem: document how to "persist" data when using shmem_*file_setup Date: Fri, 26 Jan 2024 14:28:49 +0100 Message-Id: <20240126132903.2700077-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 3EECC16001F X-Rspam-User: X-Stat-Signature: q9rmrh1uo6fngnyqng4yyu7bkf9pke8e X-Rspamd-Server: rspam01 X-HE-Tag: 1706275773-96682 X-HE-Meta: U2FsdGVkX19FTEDvdvA6NlMNX18xg0GbQQ7YPRUFDoK93gzKI2QnWuyHlGbp0/l3cwYGRV8ebaWX2AqZpm3geUwhsleeMv9hKHapNQX6ijWLFjhexL5xwjhQgHU6QMDpCg7kxmo9LuWW+FM3THvnQDn8XBx8AlgxvuA04ov/q2kUR3FKYyGLU/l0piRUgtCz4zNu56ZkE8Etcpor3X+XPre5NmMlMG81FeZhAqFpFY5jla/Ocu37b7syWY/5KdYn0nVn51GhC1XJ1IUAq4o0KqzKUSqDJmuZjJW5bG/eEeKAErwTwGND36Cr29KmLmK8D6/YclztmWgm1wtOTORAH4v75yTInQDJ+aD7o/YYnkP0g1pl+nskU+MeSoIoF+P3Axuxumds8EV38zbA80RqP1/7/xfHorT1oee20UXGk2oIT/m5RT9EzRqhWwDet0Lr/iHfDpi4zhDtIWRJ9dV/6T8D45hooIyyxSwVNuMV4+0r4DTAOSnxN1PU4zG4HsExdpx78apfTbu6FeMFoM7sFqJJMNgtEH55d8KbfMraHCOCE4oxgbuKKved3KeA7pOcJXHVz8Z248aC8znxX0CQieusI8E39P4ugeEDT+bHsj1AVCPTbNOW++L3DKjLmViX7y7kR4w710YADpLqumhWnEOL8HGVR+H/gEUboFb8XDIlT5bYTO4KWvOzH89OR0693ftjALXo0W/KixxCFWKv3DsgDCCYEDXO4YhLX/YG01tv1bUp8LYEmR3MivEyMNcAitgYqwb7JVpvdhuxxKOrDztOcGg9YADuMbxrPeIlQxDGW/jt2Tk7ajWbQMeUO0XCec9B2AcTHGj477DguG21ymPfE3bu05oeEY4V5p8gy8CU4HN5nqcwHZyYTMGLw21PpSFoR9LGCvFewYoaABn5Ql8yI6MNE0SH79t1mINyG/G05pTCaOP0GMpukg8nRv7jle0L+TcbBd/3NDY0VgP xDJjRxa3 Lvz7AEi4bBvdvogJNbHZh395yBQ/HEXKj0RxLBmPMOCWa3vIPDG/panQrW7dkrguIzDZkEXfzQYpGdoUkqahwkO5l5cPiuc84DpkMKcpSf6nQwNags1xxbM2kE5VeY5XNsELqSbvgIQNSkLemWScFLWFXB+RtNTpufg7rzp1UMYlKyj9kWpNsWPmDj34WeBuBLbu9NCERLIGVXsTQ0PEsGm8d7UhXIrwe+aq6Yt3vkFlH8P0YkqrB2GRV76siJ2CPM8M/eq0D5oOjzwyib/ypUseipoTfncIvLqy8mbrh2XTh6xi0MarpR0O4wAztGaIXjwTV8b/c8KZ5QALKh/oIybVdRaKBY9/f/Qdnq44EBVsIyWKfkQQs8RdV/go986KtSzxX9fL5bNW1meHjPeS27x2SAp+z2q8HYJCa4I/4h25njcAN8rHr7MjRbt3+xx+BodCioLD3uCoN14tPg2Us2LDefqZcghlCgAxQz2INBra8C6M+oujU3KybGR0dlHvhuX5q2VjoNmWFt2M= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a blurb that simply dirtying the folio will persist data for in-kernel shmem files. This is what most of the callers already do. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- mm/shmem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index e89fb5eccb0c0a..f7d6848fb294d6 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2150,6 +2150,11 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, * * Return: The found folio, %NULL if SGP_READ or SGP_NOALLOC was passed in @sgp * and no folio was found at @index, or an ERR_PTR() otherwise. + * + * If the caller modifies data in the returned folio, it must call + * folio_mark_dirty() on the locked folio before dropping the reference to + * ensure the folio is not reclaimed. Unlike for normal file systems there is + * no need to reserve space for users of shmem_*file_setup(). */ int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, enum sgp_type sgp) From patchwork Fri Jan 26 13:28:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532571 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 AE62BC47422 for ; Fri, 26 Jan 2024 13:29:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49BF36B0088; Fri, 26 Jan 2024 08:29:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 44C8C6B0089; Fri, 26 Jan 2024 08:29:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2ED596B008A; Fri, 26 Jan 2024 08:29:40 -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 206F96B0088 for ; Fri, 26 Jan 2024 08:29:40 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BC966C073E for ; Fri, 26 Jan 2024 13:29:39 +0000 (UTC) X-FDA: 81721544478.17.09473D1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf24.hostedemail.com (Postfix) with ESMTP id 48837180021 for ; Fri, 26 Jan 2024 13:29:38 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=elCIyzGp; spf=none (imf24.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275778; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pWiZ+uq6s6Jb8DG5zpX+nOBm/9LHv3+s4Lx1umDyLlU=; b=b6ZR5FISSPnQAzGTc0NKBvzWo0zCy1lSeBq/8VXmHdRSnmhAwlDbYkwMwAZx3aqFB6tgzl 4GEThFVtuFsKNtcZF8cPL7n4gjyRzJKBMWL4vdblmJIhdefH9dYiOugjkWD7tGTZY3ZRs9 t9BVQAVQAwipAGaRm+3L8Ic8qo0Tnmo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=elCIyzGp; spf=none (imf24.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275778; a=rsa-sha256; cv=none; b=7FjRXJKV5sXHCKtPC4UaLVfblnx8jnpJNvj6EANkNuYTQ1sy8905rhl5JkAkCVVFq1YOsr Nyix8eNeHPkKsVWHUBIHgZSj047Fnn0TMeSgMdO4WXZDU8B+TdbtSTBsapeLlEPUwt+KEM S3yeBN055YKXFNOBMFfQEUzqW57yzQo= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=pWiZ+uq6s6Jb8DG5zpX+nOBm/9LHv3+s4Lx1umDyLlU=; b=elCIyzGp+nOt85GXW3Sjqc+xJt ucreJIe1XnRuOAMm4wAmDLK32DRnCCwxdZdzl8+68mTreQydzaKPkvpHeyhcC6Jg7zBmdxsAZmq4C RkxEBe13mMR/9QkLVqz5U213MvVBz1XiYHym9tYSjxNB60HfbnAmZ3AxSsoyrA/lPNSyQfgV4BLUW KIx4L1lf+pJKA9m66sV86qp7/4PFANibdgoodUowdEGA6kIk+gqmwFp5e8ISz6ZsEr2qKojOW1R51 qThmAht9NvoXRb6A7z3IS7ywtMFaHstSfjUbbi0T/UMhN+jE+C6X2B8EEn8+7Zj8p4MrLKUAuZOIb l6ENxlFw==; 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 1rTMH1-00000004CjK-2Uad; Fri, 26 Jan 2024 13:29:36 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 08/21] xfs: remove xfile_stat Date: Fri, 26 Jan 2024 14:28:50 +0100 Message-Id: <20240126132903.2700077-9-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 48837180021 X-Rspam-User: X-Stat-Signature: hb4j1fg54ziteix78nr998ihcz3n7td3 X-Rspamd-Server: rspam01 X-HE-Tag: 1706275778-10867 X-HE-Meta: U2FsdGVkX18BwjQNbed6jS/O3a7SZkPccIwlu3/QXKn75BZofXySh7vQowz/mcq9LPH8jJeQJJ9akX2nNg7IQb4BpWne6TfBLwmJZr6VPT9o25F9hBelUMAPvBMRLg0O4wLkNNTToiPVnsUBNf1jizlMLdb7QTOHGLL3H6i44tukRG1w/tzz2Gd4NadHbSO3YBwuvvrq45+ueM9RC6GAL5KHwJNYpp2XJERHaio28ZxCLJDUcSSqhh3xm7GMl68Bg+EquYLKU6BkudV2QVjDUohpqdvpXdwap5seftBZqYMJDLFO4k2YfHnw7ujv4pIBP+aDAwy/IkAcug6cgjBd+cUzGIK6tCRwt81n+gFu3XXG/I8UK3ViUBY3mno7xNQY7Nxh0AB/5q6roVch2dBoL+ngq4fdr8eJxbgkZiKaiv2npt0LUZLkKSNaTt7kOumXKp5Un7rUt4gg2krr9dBrje9y1fMsbxHUzqDlWsc5Sk6TxBlzmrWhI1YsyBB9JjXv8V30AD5So1m6hciSVfVaADjDoqaVhRGt7lMnpwRNSrEu7uA7+Q+Q6qLaLZ+UcCmzfWHx5+v5nWqGLEbX5twNRD9HvLfKrJIqy2DW9jnoLIn0zrYIzfue4o6RgPWBGvafP/OUloAGozfVB4w4UUMlMpYT8AmAR78sttzORLY+8oNDhzLLYEDlpuLPGjRsvP3yAgEl+KH7UoYajroV5kQwVMr9yRruFjP8IdeJHxzzBKOBEnZaE4lWLqhw8Pj3erAxkabUuuXiLc05BjLEXzaxFdpgFc9BBHj8EZuPPHhys+NW1f7BLTdOOQOE0B7LZV5EEH11sbenoXUTF6jPn3L5gvJE6XYVOWIWsFWndK7dQg4KCRDU+CY9q2/vZrSAl6OOP3X7MRnqVq3tdUF96GF0EBHbDst5VPG2ljx6YP9h/8veGqou8TVLLbQsRUfGMuC/cIwaCkhQnrDjv3b+kIj ZmkYr9zQ QmQyyV1kx1nJrHSqk8G9gVMmYxQD4LAIehi3AR/lwUxMpgmtfySAe4sDbVKDSxZrhbDTgTYyXZ2NCuJFdNwGFEmeBZIkQcFmf/WWfaQS0Ug+pw4c9WZi1DbJs8GVoJK66yLWf7QPX+xJFyld3ukWZ9vcpLeIVOL17vB6GiF+fYcwL47FT4MfXQ+0SpwtgPxVYIZ9bkkqsyRDWv9zx8vg8UV2VNg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: vfs_getattr is needed to query inode attributes for unknown underlying file systems. But shmemfs is well known for users of shmem_file_setup and shmem_read_mapping_page_gfp that rely on it not needing specific inode revalidation and having a normal mapping. Remove the detour through the getattr method and an extra wrapper, and just read the inode size and i_bytes directly in the scrub tracing code. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/trace.h | 34 ++++++++++------------------------ fs/xfs/scrub/xfile.c | 19 ------------------- fs/xfs/scrub/xfile.h | 7 ------- 3 files changed, 10 insertions(+), 50 deletions(-) diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index 6bbb4e8639dca6..260b8fe0a80296 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -861,18 +861,11 @@ TRACE_EVENT(xfile_destroy, __field(loff_t, size) ), TP_fast_assign( - struct xfile_stat statbuf; - int ret; - - ret = xfile_stat(xf, &statbuf); - if (!ret) { - __entry->bytes = statbuf.bytes; - __entry->size = statbuf.size; - } else { - __entry->bytes = -1; - __entry->size = -1; - } - __entry->ino = file_inode(xf->file)->i_ino; + struct inode *inode = file_inode(xf->file); + + __entry->ino = inode->i_ino; + __entry->bytes = inode->i_blocks << SECTOR_SHIFT; + __entry->size = i_size_read(inode); ), TP_printk("xfino 0x%lx mem_bytes 0x%llx isize 0x%llx", __entry->ino, @@ -891,19 +884,12 @@ DECLARE_EVENT_CLASS(xfile_class, __field(unsigned long long, bytecount) ), TP_fast_assign( - struct xfile_stat statbuf; - int ret; - - ret = xfile_stat(xf, &statbuf); - if (!ret) { - __entry->bytes_used = statbuf.bytes; - __entry->size = statbuf.size; - } else { - __entry->bytes_used = -1; - __entry->size = -1; - } - __entry->ino = file_inode(xf->file)->i_ino; + struct inode *inode = file_inode(xf->file); + + __entry->ino = inode->i_ino; + __entry->bytes_used = inode->i_blocks << SECTOR_SHIFT; __entry->pos = pos; + __entry->size = i_size_read(inode); __entry->bytecount = bytecount; ), TP_printk("xfino 0x%lx mem_bytes 0x%llx pos 0x%llx bytecount 0x%llx isize 0x%llx", diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 090c3ead43fdf1..87654cdd5ac6f9 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -291,25 +291,6 @@ xfile_seek_data( return ret; } -/* Query stat information for an xfile. */ -int -xfile_stat( - struct xfile *xf, - struct xfile_stat *statbuf) -{ - struct kstat ks; - int error; - - error = vfs_getattr_nosec(&xf->file->f_path, &ks, - STATX_SIZE | STATX_BLOCKS, AT_STATX_DONT_SYNC); - if (error) - return error; - - statbuf->size = ks.size; - statbuf->bytes = ks.blocks << SECTOR_SHIFT; - return 0; -} - /* * Grab the (locked) page for a memory object. The object cannot span a page * boundary. Returns 0 (and a locked page) if successful, -ENOTBLK if we diff --git a/fs/xfs/scrub/xfile.h b/fs/xfs/scrub/xfile.h index d56643b0f429e1..c602d11560d8ee 100644 --- a/fs/xfs/scrub/xfile.h +++ b/fs/xfs/scrub/xfile.h @@ -63,13 +63,6 @@ xfile_obj_store(struct xfile *xf, const void *buf, size_t count, loff_t pos) loff_t xfile_seek_data(struct xfile *xf, loff_t pos); -struct xfile_stat { - loff_t size; - unsigned long long bytes; -}; - -int xfile_stat(struct xfile *xf, struct xfile_stat *statbuf); - int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len, struct xfile_page *xbuf); int xfile_put_page(struct xfile *xf, struct xfile_page *xbuf); From patchwork Fri Jan 26 13:28:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532572 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 B4787C47DDF for ; Fri, 26 Jan 2024 13:29:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C3EC6B0089; Fri, 26 Jan 2024 08:29:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 473C76B008A; Fri, 26 Jan 2024 08:29:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33BE16B008C; Fri, 26 Jan 2024 08:29:44 -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 243706B0089 for ; Fri, 26 Jan 2024 08:29:44 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 007AC120F66 for ; Fri, 26 Jan 2024 13:29:43 +0000 (UTC) X-FDA: 81721544688.10.6A3B06C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf02.hostedemail.com (Postfix) with ESMTP id 35D7080025 for ; Fri, 26 Jan 2024 13:29:41 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=figJ7dAa; dmarc=none; spf=none (imf02.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275782; 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=VTrS8ctH02TlUzsdkH8QjNd1/wSjE+HLrbxrw5NeZOI=; b=RN6taNn/vg+GW6x+xLCjFvpX3s6GbR0m8RHOvqh1DPOtwKa9WqfhH6LVZdfeIOaztyRMPE uwgnQxApPYM5RpuI0qEAY+6VKyoDLhfo310OjtveyHbI15X3mQtkEaKtp3KcC4gNaVjOZF hcHjoNRpN0sFzcOR8Zl6gIhYLkVxz5w= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=figJ7dAa; dmarc=none; spf=none (imf02.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275782; a=rsa-sha256; cv=none; b=IR4FxI5m/jOK48kyIczQkr1juUKB91kyraC1hE06EZtPYsxFXXDWgtAxD3zCqx7bmdpwAD /8/mk+U7OPgpcwn8XUdn8Y7g0CAc/qNl/KdQdYtO6fFLyHDBv183U9VmrfUo3AK0N3c0YO AD3bPxh4R3WaboDciM7j5mi+9R94NQE= 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=VTrS8ctH02TlUzsdkH8QjNd1/wSjE+HLrbxrw5NeZOI=; b=figJ7dAaXAQrDvERbrvvg7VKf1 CveDVGJSAGtrgdfG10Z8V+NobMQSJEH7grDuq8Ix4Enhp1Jdam/A2ssvJAhU+azLyn+xYDJo2UDec 66LZ14XtoTdst+X604J9/n9YzbI0uz+ZYIUUj/QsvL19U6EfO+OLr1yesxAZUkkarzA9Y+AADSNB2 bJTmsN7w/nM7BX+sdfPRIZmV+wTEjUbeK0VNloIbnvEJ38wg3Hiy5ikhJzW/WTlHtiZUlQKN9+jmP U+mGM7qVWALkN33Sr2GXTGFHfCH1EKzpSCTxZgd6a/wHY7W7adQ5KZQkU9zuiOS+EYQZv7QFHsX2X j56wqJnA==; 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 1rTMH5-00000004Cko-0ixL; Fri, 26 Jan 2024 13:29:39 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 09/21] xfs: remove the xfile_pread/pwrite APIs Date: Fri, 26 Jan 2024 14:28:51 +0100 Message-Id: <20240126132903.2700077-10-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 35D7080025 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 81tp5k97jzaxre5obuzjd1atnuimq9aw X-HE-Tag: 1706275781-632951 X-HE-Meta: U2FsdGVkX19Pcd3UhU4w8Fl3yDHTUn1hwkbSTEzG3UOYl+D9SXN9EV1Na0wjBHE3XqQdBvI1Syltw2CmolgWHzuDjJ//c2MXoYrHqO9e/QnXOnWBlt/hUHS/S/LDiJiSPQr5GtNr658eMUIiqNRBQ7fOzD90DTPqw6ZjHBPI07WJm+RwpFjsTsHpYF4pULFOL11wsBemfW9bczFKN0qjysDoWi7WDCvmRtMXYFB9e1VVRrg0atwRTH09J2/n+9rdtlvjZlMxxxyBFuldX9QHQrXLq+hii9tAADi/D8C4AYSHwNM3fzcbmSDabNVqWS9E+QIoVaZQTXoSXmgN7vhCrXrGhS2dUWK9+eVJx/KsgnCepsZohYRSjGxtzVwg+SuyXCdiMmoc3dqBuDlDItEsvI8SgEUQHrxLgqxoQvjGoEgA7kBgwOofyOkcxJcNtg156raCqXp46aCo6sCKb4/ynGl/hsIaEAMzUKrd5br9A+FYBw9guw0hnfNxZU1jRy/tiUAPp/0q/5CsqqKTW7mi/CSpSr2X//dZuTgX0EV5RpgLpB6daIB0DtnTGJf36+hKvaRVo5CxZSMJcDoFPw2jH/OTPZuqijkaCK7c8nF1xp1R21bOX6rlXEx1N76+j4zxJr43OJlhj4Hk5zfxoUqAiiZ3wuBzMy8ym0f60zLUZZHANByrJ+83ghzVgzVeKaotghb2mcOLwlPiDg2mXeQsBpUZWtIjQ7Ky0ozRYfYd3+guM7hR1rsl0iZMrzTUlehji261Vk5XOa83aSwq+r1ARwdhCoeP3QR6zQL9qpQa5C1EHDMaW0vj/ES6VRHinxFm1Gc+vc1FuKwo4+ztm2pM6NKCSnD7+HCmds6Qlu62FkLRVmHxpeCnWGOLO2ZRRQ8FhOkVtpWqv/CLt5MuAbhSMV3lrnUAbmmTyv7UMcrLQ/cRUV+PD6l91vmwRLxlyRoh8Gez84GBOFxT0zn/Glz FgcNuBS9 tvFlmmRXZmcQRgpOiE9r9SWeQR1lineTIddJaVUdtXJ7GpjqQaHz/LBMNU+u3ZQ6/dyrnuVc7cnFcUgjnVs+lN3xK6RqyFrj8r/5cHFzA6s5Ih7Iox/OOrzWs0BHTf+1hhCiwBIHlM925wR0S943/6v/U41Fo15nP+D9rkv/EbXqIbhpbo38ysmQ3aEHZAWI0GS/IS1QoyIdJjj9+MTQnEBlG1plhai4+bI4wiaD8VvCv1OS/08QBCHydAl753CgfDbZuj8UL0cTMAPijqa1amjapAqiUfZjcXzaWDtimdWTkH0lVREoTsa23qlGqBdmv+EV2ssykYG+hkgvw7Bpg3iGUlI0JTfKR7kq/CmtkTJD3iyWLC2av7LJ7LJHGjzaRstJfmlF/o4ptnkDzo/IePWgxw4gNrWnzmuSWFwZyR05CV644uouEqyUZoymmg1em88nfiVZrfwdYNCbHwoi6pjnNpKfoN64UcyY2e03KysWMsBVlyYnnCBj8BPCWbnIDaEZJN6y3fDucFxU= 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 | 10 +--- 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, 42 insertions(+), 82 deletions(-) diff --git a/Documentation/filesystems/xfs/xfs-online-fsck-design.rst b/Documentation/filesystems/xfs/xfs-online-fsck-design.rst index 352516feef6ffe..324d5ec921e8e5 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. +functions are provided to read and persist objects into an xfile that unlike +the pread and pwrite system calls 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. However, no discussion of file access idioms is complete without answering the question, "But what about mmap?" diff --git a/fs/xfs/scrub/rtsummary.c b/fs/xfs/scrub/rtsummary.c index fabd0ed9dfa676..30b5a3952513f8 100644 --- a/fs/xfs/scrub/rtsummary.c +++ b/fs/xfs/scrub/rtsummary.c @@ -118,7 +118,7 @@ xfsum_load( xfs_rtsumoff_t sumoff, union xfs_suminfo_raw *rawinfo) { - return xfile_obj_load(sc->xfile, rawinfo, + return xfile_load(sc->xfile, rawinfo, sizeof(union xfs_suminfo_raw), sumoff << XFS_WORDLOG); } @@ -129,7 +129,7 @@ xfsum_store( xfs_rtsumoff_t sumoff, const union xfs_suminfo_raw rawinfo) { - return xfile_obj_store(sc->xfile, &rawinfo, + return xfile_store(sc->xfile, &rawinfo, sizeof(union xfs_suminfo_raw), sumoff << XFS_WORDLOG); } @@ -141,7 +141,7 @@ xfsum_copyout( union xfs_suminfo_raw *rawinfo, unsigned int nr_words) { - return xfile_obj_load(sc->xfile, rawinfo, nr_words << XFS_WORDLOG, + return xfile_load(sc->xfile, rawinfo, nr_words << XFS_WORDLOG, sumoff << XFS_WORDLOG); } diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index 260b8fe0a80296..0327cab606b070 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -903,8 +903,8 @@ DECLARE_EVENT_CLASS(xfile_class, DEFINE_EVENT(xfile_class, name, \ TP_PROTO(struct xfile *xf, loff_t pos, unsigned long long bytecount), \ TP_ARGS(xf, pos, bytecount)) -DEFINE_XFILE_EVENT(xfile_pread); -DEFINE_XFILE_EVENT(xfile_pwrite); +DEFINE_XFILE_EVENT(xfile_load); +DEFINE_XFILE_EVENT(xfile_store); DEFINE_XFILE_EVENT(xfile_seek_data); DEFINE_XFILE_EVENT(xfile_get_page); DEFINE_XFILE_EVENT(xfile_put_page); diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index f0f532c10a5acc..95ac14bceeadd6 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -136,7 +136,7 @@ xfarray_load( if (idx >= array->nr) return -ENODATA; - return xfile_obj_load(array->xfile, ptr, array->obj_size, + return xfile_load(array->xfile, ptr, array->obj_size, xfarray_pos(array, idx)); } @@ -152,7 +152,7 @@ xfarray_is_unset( if (array->unset_slots == 0) return false; - error = xfile_obj_load(array->xfile, temp, array->obj_size, pos); + error = xfile_load(array->xfile, temp, array->obj_size, pos); if (!error && xfarray_element_is_null(array, temp)) return true; @@ -184,7 +184,7 @@ xfarray_unset( return 0; memset(temp, 0, array->obj_size); - error = xfile_obj_store(array->xfile, temp, array->obj_size, pos); + error = xfile_store(array->xfile, temp, array->obj_size, pos); if (error) return error; @@ -209,7 +209,7 @@ xfarray_store( ASSERT(!xfarray_element_is_null(array, ptr)); - ret = xfile_obj_store(array->xfile, ptr, array->obj_size, + ret = xfile_store(array->xfile, ptr, array->obj_size, xfarray_pos(array, idx)); if (ret) return ret; @@ -245,12 +245,12 @@ xfarray_store_anywhere( for (pos = 0; pos < endpos && array->unset_slots > 0; pos += array->obj_size) { - error = xfile_obj_load(array->xfile, temp, array->obj_size, + error = xfile_load(array->xfile, temp, array->obj_size, pos); if (error || !xfarray_element_is_null(array, temp)) continue; - error = xfile_obj_store(array->xfile, ptr, array->obj_size, + error = xfile_store(array->xfile, ptr, array->obj_size, pos); if (error) return error; @@ -552,7 +552,7 @@ xfarray_isort( trace_xfarray_isort(si, lo, hi); xfarray_sort_bump_loads(si); - error = xfile_obj_load(si->array->xfile, scratch, len, lo_pos); + error = xfile_load(si->array->xfile, scratch, len, lo_pos); if (error) return error; @@ -560,7 +560,7 @@ xfarray_isort( sort(scratch, hi - lo + 1, si->array->obj_size, si->cmp_fn, NULL); xfarray_sort_bump_stores(si); - return xfile_obj_store(si->array->xfile, scratch, len, lo_pos); + return xfile_store(si->array->xfile, scratch, len, lo_pos); } /* Grab a page for sorting records. */ @@ -858,7 +858,7 @@ xfarray_sort_load_cached( if (xfarray_sort_terminated(si, &error)) return error; - return xfile_obj_load(si->array->xfile, ptr, + return xfile_load(si->array->xfile, ptr, si->array->obj_size, idx_pos); } diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 87654cdd5ac6f9..d65681372a7458 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -118,13 +118,11 @@ xfile_destroy( } /* - * Read a memory object directly from the xfile's page cache. Unlike regular - * pread, we return -E2BIG and -EFBIG for reads that are too large or at too - * high an offset, instead of truncating the read. Otherwise, we return - * bytes read or an error code, like regular pread. + * Load an object. Since we're treating this file as "memory", any error or + * short IO is treated as a failure to allocate memory. */ -ssize_t -xfile_pread( +int +xfile_load( struct xfile *xf, void *buf, size_t count, @@ -133,16 +131,15 @@ xfile_pread( struct inode *inode = file_inode(xf->file); struct address_space *mapping = inode->i_mapping; struct page *page = NULL; - ssize_t read = 0; unsigned int pflags; int error = 0; if (count > MAX_RW_COUNT) - return -E2BIG; + return -ENOMEM; if (inode->i_sb->s_maxbytes - pos < count) - return -EFBIG; + return -ENOMEM; - trace_xfile_pread(xf, pos, count); + trace_xfile_load(xf, pos, count); pflags = memalloc_nofs_save(); while (count > 0) { @@ -160,8 +157,10 @@ xfile_pread( __GFP_NOWARN); if (IS_ERR(page)) { error = PTR_ERR(page); - if (error != -ENOMEM) + if (error != -ENOMEM) { + error = -ENOMEM; break; + } memset(buf, 0, len); goto advance; @@ -185,23 +184,18 @@ xfile_pread( count -= len; pos += len; buf += len; - read += len; } memalloc_nofs_restore(pflags); - if (read > 0) - return read; return error; } /* - * Write a memory object directly to the xfile's page cache. Unlike regular - * pwrite, we return -E2BIG and -EFBIG for writes that are too large or at too - * high an offset, instead of truncating the write. Otherwise, we return - * bytes written or an error code, like regular pwrite. + * Store an object. Since we're treating this file as "memory", any error or + * short IO is treated as a failure to allocate memory. */ -ssize_t -xfile_pwrite( +int +xfile_store( struct xfile *xf, const void *buf, size_t count, @@ -211,16 +205,15 @@ xfile_pwrite( struct address_space *mapping = inode->i_mapping; const struct address_space_operations *aops = mapping->a_ops; struct page *page = NULL; - ssize_t written = 0; unsigned int pflags; int error = 0; if (count > MAX_RW_COUNT) - return -E2BIG; + return -ENOMEM; if (inode->i_sb->s_maxbytes - pos < count) - return -EFBIG; + return -ENOMEM; - trace_xfile_pwrite(xf, pos, count); + trace_xfile_store(xf, pos, count); pflags = memalloc_nofs_save(); while (count > 0) { @@ -239,8 +232,10 @@ xfile_pwrite( */ error = aops->write_begin(NULL, mapping, pos, len, &page, &fsdata); - if (error) + if (error) { + error = -ENOMEM; break; + } /* * xfile pages must never be mapped into userspace, so we skip @@ -259,13 +254,14 @@ xfile_pwrite( ret = aops->write_end(NULL, mapping, pos, len, len, page, fsdata); if (ret < 0) { - error = ret; + error = -ENOMEM; break; } - written += ret; - if (ret != len) + if (ret != len) { + error = -ENOMEM; break; + } count -= ret; pos += ret; @@ -273,8 +269,6 @@ xfile_pwrite( } memalloc_nofs_restore(pflags); - if (written > 0) - return written; return error; } diff --git a/fs/xfs/scrub/xfile.h b/fs/xfs/scrub/xfile.h index c602d11560d8ee..465b10f492b66d 100644 --- a/fs/xfs/scrub/xfile.h +++ b/fs/xfs/scrub/xfile.h @@ -29,38 +29,10 @@ struct xfile { int xfile_create(const char *description, loff_t isize, struct xfile **xfilep); void xfile_destroy(struct xfile *xf); -ssize_t xfile_pread(struct xfile *xf, void *buf, size_t count, loff_t pos); -ssize_t xfile_pwrite(struct xfile *xf, const void *buf, size_t count, +int xfile_load(struct xfile *xf, void *buf, size_t count, loff_t pos); +int xfile_store(struct xfile *xf, const void *buf, size_t count, loff_t pos); -/* - * Load an object. Since we're treating this file as "memory", any error or - * short IO is treated as a failure to allocate memory. - */ -static inline int -xfile_obj_load(struct xfile *xf, void *buf, size_t count, loff_t pos) -{ - ssize_t ret = xfile_pread(xf, buf, count, pos); - - if (ret < 0 || ret != count) - return -ENOMEM; - return 0; -} - -/* - * Store an object. Since we're treating this file as "memory", any error or - * short IO is treated as a failure to allocate memory. - */ -static inline int -xfile_obj_store(struct xfile *xf, const void *buf, size_t count, loff_t pos) -{ - ssize_t ret = xfile_pwrite(xf, buf, count, pos); - - if (ret < 0 || ret != count) - return -ENOMEM; - return 0; -} - loff_t xfile_seek_data(struct xfile *xf, loff_t pos); int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len, From patchwork Fri Jan 26 13:28:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532573 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 8EED4C47DDF for ; Fri, 26 Jan 2024 13:30:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 204E26B0078; Fri, 26 Jan 2024 08:30:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 18E826B007B; Fri, 26 Jan 2024 08:30:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07D166B0080; Fri, 26 Jan 2024 08:30:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EBF106B0078 for ; Fri, 26 Jan 2024 08:30:02 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C0F5C1C0D9F for ; Fri, 26 Jan 2024 13:30:02 +0000 (UTC) X-FDA: 81721545444.12.1D0267A Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP id 03A0016000D for ; Fri, 26 Jan 2024 13:30:00 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1ChCLOer; dmarc=none; spf=none (imf08.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275801; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5C9VP1SaExA9uyPFl5WPVHE4cTMuqE1mtuEvKQxBCh0=; b=5rccxba6ISsmmEy6mkWgCaJU6VU/AELS1B8iznVnNTxjjAxo+VYGrB5haoxeSkb1mKYHrE /NlH6yE1lc7axOQ7nnyh3+xf2/eQNsLMFQGBFxollnFVM6zj/tCOFEw5s4j69YlMeIzwOQ 7JkKAU57e8hnHclKWhwLpsMUQMfoaf0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1ChCLOer; dmarc=none; spf=none (imf08.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275801; a=rsa-sha256; cv=none; b=Nc9lGncFdpSKGyaaP6uWaQDL3l17dDkEQFHSVDtfOExzEugICvvlfSKn7pQy95e41SId66 xkTYobOyhYOo0BmyKVk67uwDVvTmEc2T/s/bi25nzB90plXv1Ric3eb2wEOkaJWPaIGyzq eZMhNswyTxjlIE83897crDOcvY61eRo= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=5C9VP1SaExA9uyPFl5WPVHE4cTMuqE1mtuEvKQxBCh0=; b=1ChCLOeroR7dQqYdR5AXNYr1Z4 o8nXFMvA03KaWJYAdTLzKQAjFQDtTJLAjUJym+hifoq1BU+ewTsTqMjsM4rvfMrJTXpNkLkQYpxJ7 C5P4H4B225jgIsjOBoQFolOqzPJROg4/qHYpxzifySOP+wpW+l8Lfm5PuR5tOyzesgr0Hk/csyvdG QY5oL1xAe2TGkD8Bm2Et80Pk/tVUVr8ItZjBFJ4qRn6rBKAaaKOyPfZUem51N2STdSXZu2diYvpms NZe32dI0JGZE2SLOiKv8/E4ubitwNdnBLAWJj+w1AOCtlTp3xPqcPKHiVItw5cuXYbd5V26NqnvCk LZAXUuYQ==; 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 1rTMH8-00000004Clz-2KQP; Fri, 26 Jan 2024 13:29:45 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 10/21] xfs: don't try to handle non-update pages in xfile_obj_load Date: Fri, 26 Jan 2024 14:28:52 +0100 Message-Id: <20240126132903.2700077-11-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 03A0016000D X-Stat-Signature: wpaqm45dnwp6wnqp85zdghyc7fa1xsca X-Rspam-User: X-HE-Tag: 1706275800-610035 X-HE-Meta: U2FsdGVkX1+cN9ZiiMFRae4fg6DICEtTgNRu89LZby9dyfzbOuRHeI0Rr1ypvF8UWRID+jLbpoUcBrCzEZ3M/XTJ+w7M5bPJTcUcAU4SCPUJ14S2gPrM9F+WHpgs+TQVeLJ0dv7bdDYrx7IkT/4Xm6bKaCf7cE7BGpZlRPiG0G1SWKq3XHpseVCGbTuzsEBeWJrQ/bacat5ng8EciLcCNYI17pu+jPDNMXseMfeRnfcSQsnvXjuNsRcFiFWHnNq/qY9aqwInDDBVE5kV5EsUHBbwSTh+GKI9vd4+IJc9hD0Tu1fj3BhbbZ2tDS4/JT2WBRkK3GsxjjdlmgSe7jPkef5ZV/wESvjqK4IRFs1ZJtvNHbhZsUdlGZ4QlNkm/m38M7Fivf7wfqddl7+H8xEyh0P96nXgv+fCoqiREV7D24zM2CNBLdX6K9AzhmCb4eNqu4XBbGDcOnafBmqS7nv8lN8mYPs8e4sRD6T4NB3Z6ncwxtrmDpbWMCqqwSrKlTy1CUDhEWLe9a8Dn+AMnkq8f3vOvpryuUaZ+hr4X/GrTIW3LOJ3vlKoRTcAr6gdqgyp5M/f0W0yYwEDNjrjCJXh3lGMW4xdZ/Co8bQx2lqA+JMpITF+k51E0r/N7xj+PoyWV1kD+Cjikkhsqq5iPALmpW87SQtuYgEeNZ89mH2X0WOW/W/RPazoF4LzW3GFv5jCtYeiOzrTILkFSyeyDvnZVQf2yxfc3NbyFkmmrI/3/i1cFhpiCBDELoIYQPRvlhe5DO9FXt+TaxIiHWBHTDgoQrVGdgPMNtYmvX+Ju0ga5HQK9GYvPZBqOQ6+d4KAIqQc1C92MNj9WlYhrDNu1FIrH0PMhV/YgNr1EadXuKdtxCKheRsWK/m170wak3Wf2aDK14dacjGr41i9Vht7z3N6O7WsMj7I2ssRM3Kw1Z1YXXPXkKdgLFm7+eiHpLUzyMXoLsPPIRg5y1aeehR1Mqw 8XjTieoi KD2Lor99ar7bwDCpHwzP+KWh9t/L23bNX/6Cv2YH4JHnfWKMwmq+kty6v/E57eaqdhWOro/0CtC7cJ/KxcuqcbgQzr2X+w0O9IP7kGk+wAdlDyQ1vk/bKGnbetQ7TDwaGcffYcMlY5jjOhmEmzGhXl+I8/5Z5LBtMb4USINiq+b+SYmAQaOHGjhuKqvZYr4XLghZS3ZC2rPsNSu+fpmbtGwHvg6I2r+IAPPhKJqoddLwwoVLF+sNvuCiFnQCh0dY9qMjPgfGzuK+vYcLMKd/eRQERlTl6eA1A18oD+2xhN88NgC26dhXYUAyds4vEMeWHdGXDD2PmZVZZgbIoOqJO14rSIt5Co7nt5unXSlgiizSYC69qTbA2nOl3HBS0+Iic1tGx+a04uNmnAdIuxzJtpiXlRHjm4Ryz+BgIlLp3FbJkt/9lDfan4WDZK1CO105iFt66FPkThVYxscnvwjwsgEoATT6S2lUwBFUjEBkIKJNICHF4D4u/DaOWjIZ8IFllDMAdE2P3oUXTf/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: shmem_read_mapping_page_gfp always returns an uptodate page or an ERR_PTR. Remove the code that tries to handle a non-uptodate page. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index d65681372a7458..71c4102f3305fe 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -166,18 +166,14 @@ xfile_load( goto advance; } - if (PageUptodate(page)) { - /* - * xfile pages must never be mapped into userspace, so - * we skip the dcache flush. - */ - kaddr = kmap_local_page(page); - p = kaddr + offset_in_page(pos); - memcpy(buf, p, len); - kunmap_local(kaddr); - } else { - memset(buf, 0, len); - } + /* + * xfile pages must never be mapped into userspace, so + * we skip the dcache flush. + */ + kaddr = kmap_local_page(page); + p = kaddr + offset_in_page(pos); + memcpy(buf, p, len); + kunmap_local(kaddr); put_page(page); advance: From patchwork Fri Jan 26 13:28:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532574 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 D2096C47422 for ; Fri, 26 Jan 2024 13:30:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 625DD6B007B; Fri, 26 Jan 2024 08:30:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ADE56B0080; Fri, 26 Jan 2024 08:30:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 474A16B0082; Fri, 26 Jan 2024 08:30:05 -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 39BD86B007B for ; Fri, 26 Jan 2024 08:30:05 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0D28040F48 for ; Fri, 26 Jan 2024 13:30:05 +0000 (UTC) X-FDA: 81721545570.13.5255BD8 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf18.hostedemail.com (Postfix) with ESMTP id 66E6E1C001B for ; Fri, 26 Jan 2024 13:30:03 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=AW558L4X; spf=none (imf18.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275803; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Qe83DfTex1z7zqi4GxksjarNQRXeRN9ZyszbsgkFHtk=; b=R8zVjmjJlygg/UIzAtSyoyUIowDkQKdhzSQrPXzSPFpT3fd3U0AMaZZrYJ/nTrSOFNjHE0 xfjK92uy/zjLJBfN9VqU3VBpC4YQBS9CThuTPK0IUEOUIFHuEmw7XSzsNaDEJqcqxvjQdW Qt++4eGGvJgfsK/x0zJ3YQECHytOPLc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275803; a=rsa-sha256; cv=none; b=YEVJQaquGUmAokbfJhBDQbAHuF5GWTGiRpM20g3R3tTBJiX6GVNSPREyFdF3O8qnUvWIds 5Ckoa+Feu9kHEezzL1/ffuv8KrxXojBiFvtGMsbZvvH7GKn7clyGXEw9OCp1tYcGwloMCa DoKhMWZc7s0I21YGh3K07oJkd1OaJqY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=AW558L4X; spf=none (imf18.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=Qe83DfTex1z7zqi4GxksjarNQRXeRN9ZyszbsgkFHtk=; b=AW558L4XK6tfao0hRtcKkesnKc 1+cmXOPvdPSPSsWcDFZDhVYrJ4UbLVK+R1/TdWjTp3uU4x3N+G+ltc0EhC6Gq7wICZl1Z1QeKgGn1 hj5vj/hQDdaD3WpT3CZl1U1au1iLqG8Y/g2jdB94h8SA9nrTRRWAzFgii9GNfFm9rAYA0kuNG6bZN Lpm1NgKVP0N6twIVeBtYP4xvgUyFTWP0VNSM6SEKKRl2MIObXbgMZmhoPm+twLDxH3wzjXlyWwWL3 vkbkkSKgvbnZtLm7wQeXpfFSsH0YQFA/OLb3cNDWViJSDSMeE/IZG4mYYaVNTjohdHkKxuSydMRYl l7daPa9Q==; 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 1rTMHI-00000004Cnt-3lRH; Fri, 26 Jan 2024 13:30:00 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 11/21] xfs: shmem_file_setup can't return NULL Date: Fri, 26 Jan 2024 14:28:53 +0100 Message-Id: <20240126132903.2700077-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: fp89q1ztm9hru4d1fgpsifufu4fh1iwd X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 66E6E1C001B X-Rspam-User: X-HE-Tag: 1706275803-713883 X-HE-Meta: U2FsdGVkX18U4gjxt9HxPKk9rCk6gZ5BNyFtmgH3rxJHIKvLe/nkhLlNlDPzrsS84WKg9ffc5MbcVAzBP9+r2k0CUPgMMX4bX5lTKplWkyb92MbIHiU7icb1pVKbMAsONDBhk8rjZL6BNEkHlfFdCqy88WZSil8PIxnnXv8oTGFi9Kc2WV0LI173yDjNMzQeUT3INka2O/jYuUQ2GP0WCwmufbbi2W8RGVLkLSndJ0jprFTYSF/1rsyVF/hhVXNHcs+qNCoTX/mAiouVN0t/Cj3c5Xu5Ucbv5P90PLqp2Ma3ENFTvpVmmD2fYwhSleBu3iGJ0HhA36Z3m2BgmhATTJHUhRPtDfDnAaHh6S28G6uETBFFFukuD7j8VWFZWOnoN6HrogyO7JqewVQKB1tQp3PfaLGvvAezJvsdmlUCvIl8gghbQ38mCeYlVsAnGj+pffJVU2HqtW+ou61/X0VtM1/nJ361cPmFBOyyBXefmWgx0bvW8YmusrY+br3jafx7f4vT9AOY+xCTZ/xUla0Llxb50wkX/YxMdrBmj4kotH8ULfp/tL9QsaDqvF1/ErISGDkMvPZI06bQDYTuKKiRA0FjgOWtjrZXzvEoK7TBG4gThWgwUjrwo5TwZqzmqX1iyqIz0o0fyh4QTdsMXO6MEAXvkCpP7DMHCvo82nNlBRzywJQUnm3vwlENL5//8+DxiNMPZqXdAW+NnR7kA0YcnalQmfw9Ssp4pTQTNmtYYEDgIUj/NgRi8S8tBTul5rmtFjzTHn7GoRjgZOZeJz1tN4J1hehAklAzDueXZWXk7mpKGU5vzE3QJmieU/QYI6HUCCR1eLzLYUBTLUplXWuHbpcV6dRa5bV/iUY/mVY+Fi+XvIku52GEsItGnTtspKQWHZvfDS68th0+Jrww49w9gHTgQXne6VuL//ojIqu6OCH+mM+0eh6I7TLRi6In4b7GWHrLzNbvOq9/peAuyF/ FgdOCyU5 UkDFmLhJKgf55AGVsCsql2gcdU8Mq3MpdX1/XCzO7wzG415jRjnwIrHKCTMqkgxbbT0aWxm7qRtzuH0bi7kIpPfdP1YCPG59jk/qzjNmTB8+oQ+g04CJbWbBpjdWuk53T6GIGIBHc+ocKIBKwo7KOZO6njPPhWDImRw4vhQJP7dwJMi58be3blW5Bd89WjhnJqZR19fQm8qDqNWw2rQRE0TIC/jmTC2TFzC7ZTQTXFz5+DgwOtogwXAcCpg8F9Uian77h1ME+Cu/KCHTCnbs3VnqLoL+sq1ErnqcfiNRw5kD6gG1qMRXcA9GnFDt0eafnUtTg5L/IDX/6Evx1UxL0xwqziuH7GTh740MdhjitXOgGRyxUvEj7MeLyY1J1yo2BtHqzkQPLCyqDASO5tqAXdkXaKoXGt8nQj7VpdHlo7PtLsaG9Xvi/S0Bb0/WPQKvbGbSWK1nX8PAElq4X8lDGOu12Rc3+8vgF1Ljom9PCAxAymV6aC9dJ9Ry0VFP1aDqvJS+Kg3WO3eNPKY0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: shmem_file_setup always returns a struct file pointer or an ERR_PTR, so remove the code to check for a NULL return. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 71c4102f3305fe..7785afacf21809 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -62,15 +62,13 @@ xfile_create( { struct inode *inode; struct xfile *xf; - int error = -ENOMEM; + int error; xf = kmalloc(sizeof(struct xfile), XCHK_GFP_FLAGS); if (!xf) return -ENOMEM; xf->file = shmem_file_setup(description, isize, 0); - if (!xf->file) - goto out_xfile; if (IS_ERR(xf->file)) { error = PTR_ERR(xf->file); goto out_xfile; From patchwork Fri Jan 26 13:28:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532575 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 66984C47DDF for ; Fri, 26 Jan 2024 13:30:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F24816B0082; Fri, 26 Jan 2024 08:30:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EAE0A6B0088; Fri, 26 Jan 2024 08:30:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D75896B008A; Fri, 26 Jan 2024 08:30:07 -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 BF3CA6B0082 for ; Fri, 26 Jan 2024 08:30:07 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 85C9E80F34 for ; Fri, 26 Jan 2024 13:30:07 +0000 (UTC) X-FDA: 81721545654.07.317E30A Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP id DB64CC0023 for ; Fri, 26 Jan 2024 13:30:05 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LO+DAdQY; dmarc=none; spf=none (imf28.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275805; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WZPrkSzC6JP8KIWSSwxcdUJBQA5TQKYe+UX++Ksig+4=; b=syi2S8mKjk5PdpKMYleerAcN8s4ZW3kBa7UT/yBS+ruNGFtbVk2+FUcKORC/sQJo209gLc gfEjOetrDTUXJ7KR5GuVeOBVSHdqnPJ93gmqqM5U3hyWp79U0eS5nRt02uj82IwiymlnCQ xB2wHLopCXpxUHRToLYZSgq2wPT+hK0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LO+DAdQY; dmarc=none; spf=none (imf28.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275805; a=rsa-sha256; cv=none; b=AWIClea1ktFqJNVFVNTO4a/KeoVWOMFIzl+S3tzyazs9RHu4CismNm+iA9omRFDv56x3Uq TuBCxpxn8dw3oP7T4H70INfQahAIHWeHxo3ubVns0P6hi+mr+l2tHZd3d6BBG806e9ydTm xS7gzlngyS1sxHFkUaL95cAuglr9MfI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=WZPrkSzC6JP8KIWSSwxcdUJBQA5TQKYe+UX++Ksig+4=; b=LO+DAdQYF+uOX8P49gTNG+QF1I iomfriNZnLrSsbT+efu9ZZXDF39DBlZIPZaw6ArFquVPkduQutCMvzh6oOd6PogtNkPlSClaZG+VU MOU+WEVg9/Wvpk39S11AcVL6pUcFgdh6w6nVt/nhtQtw/mUnUKl4ZjobkCPZ6vXsiqUo6lVxUDUAJ a6zoDPLVBnonIiXI3nl8p0altSRMBdxDvz/Dn+p4uyE5eDbw/Ad529L5WjibG1+bxH7TfAVlkd8+d YLpMJi+IoZsAverQmxLphYqvJ2F0m4+adZrixurxP2Vj74Nzur0pWuKELHXzvf4ngQ9iYrPAXSoPE osusjb6A==; 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 1rTMHS-00000004CpB-3el1; Fri, 26 Jan 2024 13:30:03 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 12/21] xfs: don't modify file and inode flags for shmem files Date: Fri, 26 Jan 2024 14:28:54 +0100 Message-Id: <20240126132903.2700077-13-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: DB64CC0023 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 6yh6zb5dmjdmdb8ga76hyun85ndo9c75 X-HE-Tag: 1706275805-644278 X-HE-Meta: U2FsdGVkX1/T6J9jtC2nv9v9+3ab+cYO75GXKgEksjpXoSoAh59H21yP/9oObenqxA+LnSyg6JVEXahfpLimNJmWVqEJsXgLf6NQ7UIk8XAyf+zdqdNadEevPjHbOx59wE6IMp9Kt4Ou1jby5kZBd7FzKrUzfEDcuaCsLiRRbZszIA7+5qv+T/XHWveUTIPRtinNLINrA4JpLFV9TW7gcJA36oh6ul05gnLGFvGajC7cmmmtNike8MVhUwVqqZHzkLo0kib8sVUTtz7AyZ58AyvI4K5cyHb+hGf2qmFLQ1QJfwl4U1PPrrinWzQEHWoDwN9mjfEAycJOj4s+i+wAQIJHWkCmX1IPCkEeK+YrF3syvLThSWd6bBsUd92FDaJMgpPOAFc6HBno9xZeLTV6iWlHe9c7b1BIbS5WwhvWdd2pIbTBCgOAV82eKmvtX6/6Cr7tTab3dd4aU0SEU9fKwDzdmBDvHCQFkmPtj64SZMdfHlUmKBM5wcWEp0/Y+NnyPFvjC+uNrKFRMWVYucl8tdOgitkCdYtajpgEGdbolMNQ+7Dj5C61Ay2xHkroL7h8w+674RRkMirbuAvjupTSy3SabzxZGZk1oH7DQUEHnR0Njk1P2+x7nRTwEpoPT0bnXmSJeSQF6CXMisgo2K1n6IoybzkS3NrmAL2s0tn+TOtrXKFkHlciSJ0loZfqk6INj8QbGB4K9JP0uMvU1X9zAqoRyDrNZjqTqz6a7I+203DbPk2NaLrWaEFmaqLqTxy1w2Daz+POxVhZoQWghG9+J93F/u2R6fUBC9U/GhKCAORbx6L2M/wNVaNUb3E75rIml4IA0rzzml97xW7QleA9icg9o6EYFnR2X6yFKB1s6ACq9SfWf3R8Y/ukH8dtetsyTqrbZt1tMTzgsCiRbDwQkp1sHVFXUe3tzFlV/JOVaNBfPm6J3YmlUKzsCev+PbYHEj+0HXUGP7YHocbMedQ tXMSlH2d kMuHD640IocsuUzI47GmejSWjv066PcChC/j2mpVyAXIMd0tALZERk47dN2+uhdMbJVhrZrQroZwj3aw7hOyfubX0vLkpQtTLHeJk90N+WdvU85VOfBMP0uJ27vR3jwxLGhG7O7tb1Ht2CSoNH4Rh3sM85ZvPbfj6Z0XP3wysoa3SzL3bJqHwn2ScufUkjWtEOGe10/AvkkvuhUXM+WI7itkaZVQX5bGOfW4sL9++FZ4l+7gHfRopybB2ZCUbD3w4z38MG+6hFaitY4ibjFlHCfj+nZ4ka5xaRoe4vnvnmfzcXD+GGvRg0i1r883GAt/m6nWetWCeI9RhGwlHDte6/hzVEMXek8/4eNoPCXNspX1HBX6tH+XIvv3JCkzUJTLaQNrK5pjGCibJlCiRY//qY5hP60G1iHgileBCC4wwSTJBRxGVBZ6H2glETa/Zf8aTVbrukhEe86lFCtY7b6w3VDxmDg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: shmem_file_setup is explicitly intended for a file that can be fully read and written by kernel users without restrictions. Don't poke into internals to change random flags in the file or inode. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfile.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 7785afacf21809..7e915385ef0011 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -68,28 +68,13 @@ xfile_create( if (!xf) return -ENOMEM; - xf->file = shmem_file_setup(description, isize, 0); + xf->file = shmem_kernel_file_setup(description, isize, 0); if (IS_ERR(xf->file)) { error = PTR_ERR(xf->file); goto out_xfile; } - /* - * We want a large sparse file that we can pread, pwrite, and seek. - * xfile users are responsible for keeping the xfile hidden away from - * all other callers, so we skip timestamp updates and security checks. - * Make the inode only accessible by root, just in case the xfile ever - * escapes. - */ - xf->file->f_mode |= FMODE_PREAD | FMODE_PWRITE | FMODE_NOCMTIME | - FMODE_LSEEK; - xf->file->f_flags |= O_RDWR | O_LARGEFILE | O_NOATIME; inode = file_inode(xf->file); - inode->i_flags |= S_PRIVATE | S_NOCMTIME | S_NOATIME; - inode->i_mode &= ~0177; - inode->i_uid = GLOBAL_ROOT_UID; - inode->i_gid = GLOBAL_ROOT_GID; - lockdep_set_class(&inode->i_rwsem, &xfile_i_mutex_key); trace_xfile_create(xf); From patchwork Fri Jan 26 13:28:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532576 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 86D90C47422 for ; Fri, 26 Jan 2024 13:30:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22C7F6B0088; Fri, 26 Jan 2024 08:30:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DC666B008A; Fri, 26 Jan 2024 08:30:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A4F16B008C; Fri, 26 Jan 2024 08:30:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EA3E66B0088 for ; Fri, 26 Jan 2024 08:30:09 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C26FDA0FAB for ; Fri, 26 Jan 2024 13:30:09 +0000 (UTC) X-FDA: 81721545738.13.BFD8AC7 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP id 46C48C0013 for ; Fri, 26 Jan 2024 13:30:08 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="QHu/d9AT"; spf=none (imf28.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275808; a=rsa-sha256; cv=none; b=QRNcLLxU02KZuShfxC7c7sG28TxMdIFZqYvREqLKk1QoNC37Arm7fOxjPjuk8wNYeqs6v0 Xv8ozFKdeF/BM3TOUY/D6jn68q8sCYsNqkyyD+zJsS12dvKtvfHCfA0BBCu3XH6imp9FaQ NewXv+KW4IN/IiWnqlC9S/wnYz4XaFs= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="QHu/d9AT"; spf=none (imf28.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275808; 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=sf3jM42VSS5lq6M4a06uH+ctEmnHV/8RQw6R+NlmD18=; b=RbNO9+0pfJQCo1Jwpz18zOV2nnV4IHyFt+/befLhMSnqzFXWP3Am7XbES7ZsJl2IqvmGk5 E+hEahY7TGURcHYyJ/dSOSWWGniSEFwrYRi+4p90tkX1NREJl2UOlxnFAVrqwJ6VKDY3E9 UTqqiZY+Ta1ctM0AQbEqNGzjAc68YzM= 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=sf3jM42VSS5lq6M4a06uH+ctEmnHV/8RQw6R+NlmD18=; b=QHu/d9ATjk8ngW++aVNk58xD4m WCtoflSjasmfKaq9+PwqNFLLqo7o6ZDNehgioZY+k2QmbbAR8fSLNMe8JrDsHbPNifQkdSHIoPHA1 abMYA2YfBPIISehCz4grqvAEv0Zrcb/of7nNML1rnosa6VeuWRG9QrmKBtEuUyMMVLf1pZgxQ935+ fcAMlMp/eUh0/leU4UpZzFsp2xW8IVs7KZvMC9WRV7f4qqgDo9odHXSKiDRYd5tQ4qNtbmmak/jQj lHG9sCYLL/tJXIyIdCJNLvLf19Jvne4AdmQ7tW0zo+zaqE3gjqdEKE+6JKIcE89Uqqg5CssXRT/l5 fnsrli/Q==; 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 1rTMHV-00000004Cq7-29PL; Fri, 26 Jan 2024 13:30:06 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 13/21] xfs: don't allow highmem pages in xfile mappings Date: Fri, 26 Jan 2024 14:28:55 +0100 Message-Id: <20240126132903.2700077-14-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 46C48C0013 X-Stat-Signature: ndeociq34pedqohdtkhfz391a1w571tg X-Rspam-User: X-HE-Tag: 1706275808-371743 X-HE-Meta: U2FsdGVkX181PhhBNmcY6PdvtLE7Bk1+T0zuQKxFzyPuSWb2C8eTZqG+c6t6z4YTfHNZpM4VWuZBLcCTkLXVrfKGj1+iQABXKe3m0KxXC54WdMnO66E20d3ebOj6egSZOy4AnPaYm0LtIV/1vUIQowN9/GLCcMNwL7gb4qv8X+0ejwwnEmiV0VuCmb2xJZ7jIUCMXBes2fVa3BFi8yrE5pY27sDZAYi++BiBFGLaytmsQhhe5lMENM4FvOUBY52mfD8pNv4zsU2Tk5udEbY/kAQyewgFSAzmGNjPcgcC1TjR6Ev9/ptnyvBHMtq68qpcGE+265icQvARK+2x2lDSvujmUvXF6JeAsOL0QuaVCN4IBnSWoNKaI5tz8wwjFj7ades4vb2UVHXmI8bVAjX1p+nzKOxB8LNeOrBfSmVWdE5L7fTcFVxx/0e4KB9jGqV8N26EWu4gjIAoCdzKNVfCdb4mcSBtL0dwaFyEn5/D/hYT5Jdf/ONlLZ+yYsyRCMc1i5suxK+Fl+PV85IhyTElU+//yfRLxdtwlkNKMoWpG1GxXdDqrYShlC/Gn76YBGskf5YGkQPeD5lXVczZnwiVAaJE1gVDZQLFjH6Zrt47nm1w/J8gCRvK8gJKflhrmlYS3yWT5uCdDZMLv0uh2ECg2dEuHfQy2ZR/mqSbXkZKV3oXYutnL4RnX/Z9dKWdZNHf0aGcL1F+BPuJXWlHRu/7pBjBCHZTR/pzJ/yBHUSlo9Y+I1j1KvvVrtJqxp0prbROieohNn7DOAbf8hY/eXf57oSkVIAkepMvufnCmER3VPSVlX9DihqbK1bmT0B0Kf79bqP2Bk/A7qPY4KDSCjlX9oIQIBqoUJsWVhp4jvCTeI1jNgGr52xT6CNw6KL9iSGfvs5Z/JDPHHVsIQcFCAMa6sky30k8VxgSuxsC34IoICiWbEd4z++USi55fMXmLYI8YFbYGXWFK1dF4W/RX4O 9/fTuU5v iMWTem32FWzB256RGmZw4S7OefWq1eKzqhKuqBo6LuI/wiqFk65iogmDxLfr9rKJ16YPC98xVdnXk15bAKcRJaN2dZxXTUffC9h42Jujw8oGS2LdPNHuazsYvTtiWqxsaXVsfpeP9vtKqzirDFCE4+ZD6WkWHSsmqvnpE X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: XFS is generally used on 64-bit, non-highmem platforms and xfile mappings are accessed all the time. Reduce our pain by not allowing any highmem mappings in the xfile page cache and remove all the kmap calls for it. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/scrub/xfarray.c | 3 +-- fs/xfs/scrub/xfile.c | 21 +++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/fs/xfs/scrub/xfarray.c b/fs/xfs/scrub/xfarray.c index 95ac14bceeadd6..d0f98a43b2ba0a 100644 --- a/fs/xfs/scrub/xfarray.c +++ b/fs/xfs/scrub/xfarray.c @@ -580,7 +580,7 @@ xfarray_sort_get_page( * xfile pages must never be mapped into userspace, so we skip the * dcache flush when mapping the page. */ - si->page_kaddr = kmap_local_page(si->xfpage.page); + si->page_kaddr = page_address(si->xfpage.page); return 0; } @@ -592,7 +592,6 @@ xfarray_sort_put_page( if (!si->page_kaddr) return 0; - kunmap_local(si->page_kaddr); si->page_kaddr = NULL; return xfile_put_page(si->array->xfile, &si->xfpage); diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 7e915385ef0011..623bbde91ae3fe 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_HIGHUSER); + 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 Fri Jan 26 13:28:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532577 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 5A885C47DDF for ; Fri, 26 Jan 2024 13:30:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3A3D6B008A; Fri, 26 Jan 2024 08:30:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DEB316B008C; Fri, 26 Jan 2024 08:30:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB39A6B0092; Fri, 26 Jan 2024 08:30: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 BB59A6B008A for ; Fri, 26 Jan 2024 08:30:13 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 86EFC160F42 for ; Fri, 26 Jan 2024 13:30:13 +0000 (UTC) X-FDA: 81721545906.25.4CF675C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id DA2502001B for ; Fri, 26 Jan 2024 13:30:11 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Uon45Ynj; dmarc=none; spf=none (imf03.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275811; 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=PN3djP3juVhL/KNUknZcP0OIUVZdWEXnGZgCPDCtRNQ=; b=m/ztaG76RCh+7C+Ec8uZ21dCocrbz2LE1ehT/9xnxUG6QOruXcTPXod21Tb0uop8mx4jNv 8Bl49GHru6kBjbBEgnfjCmF03uxkvNgTPiICcMo1gFIHxKEC2HK1G6SJMa2yACOHj0zZi7 p0XwQtNvQ8ozltEGiOOhV9VxlpQd1N8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Uon45Ynj; dmarc=none; spf=none (imf03.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275811; a=rsa-sha256; cv=none; b=H3CWu3LzntAt6tCAVZWu1LsmggUGV4tmqa8CmyOhUAbxUJCPyyweOgkPibVyJyWC8W42FV 6/6Zb9KTxV/hDqPn/B9eByHenGpcflpc0KwAQEg8lnxODZhRylRRtWHbDjjhj6T2SjpG3O k37aOf1KhE+EnbircTQHds3aahAumcM= 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=PN3djP3juVhL/KNUknZcP0OIUVZdWEXnGZgCPDCtRNQ=; b=Uon45YnjXTuIOePuwZJX0gy+k5 KIaB3xbNpNu4+wx4OaU1k7IpfEOKnpm6VpR0Eu/ao9enWMc9/Kstx1dr14gx1XLhmrg4BApGb5blJ xsVMXblOjihwDPnPlAFbh9GlfRVMwVC1ikMaysmGRdwwdV5Q+7yFDf7yHnDJTjm4qxnWgXOB5yZek kdVj/WJSQCHa6EgUtd1cSQRp+34iSJMZCoqztZ1AJTmgBVcxPTA6vqX+fJMCHJ4wvIwcTiqv4mk2/ 0otUImdgTldDWzM/7f7qVBuLhO46e6+yeT2noDysOOoFvuwWttwM/yeeRU6/AGUj/C6I9auF/tYtC 5qx2wKOQ==; 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 1rTMHY-00000004Cr7-38VI; Fri, 26 Jan 2024 13:30:09 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 14/21] xfs: use shmem_get_folio in xfile_obj_store Date: Fri, 26 Jan 2024 14:28:56 +0100 Message-Id: <20240126132903.2700077-15-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: DA2502001B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: by9qbekezxhezf1zzow9e66ra641wj85 X-HE-Tag: 1706275811-141343 X-HE-Meta: U2FsdGVkX19/bEukzdO788q5OpNPLV9QZwOVhuw4ViYXI4QFNz1yemythrMX2EOy/zTsTSaapcXyh9uN5EkpcWNQ4C/pepGlzEexTDn3EOiHlCLryQuTKHmHmwhjXFEQMpmunuqlefopEvcNcAktrfj7DXoacTX/+f/ltEV+mbo6pmfFm2/r5Sufa/h/S/Vzf1zkO/8XX06X2Pf7LMJhVmYjeJokua5mKnIgJt7Wcls+8+nkQDxF7/6YWdtWjSEnhurCS7BRZ8CAG0Ygm8rEu2vpnImK4RBTpjgH+1c37xpPahyyvmiuh7VyUQlSGqKwiIfW6gyMUQsJVpQamnpyQD8Qeiyjj66073z/WEjaMWRvsjn5COlb/Yx1JaHOXzMn7uHo8fWRhh9BNepZIrOE032Z76IOVDF9AnzPVngJ4+qI04z6VImdiVkyeMmrXFWkOxLzwJbK4XrDrMecbs+RVPUNp6HgsI5keETQFoDmWaMbn0jfyZitU4dys+g6PxrJtNXriiUT2f7P3o8UokGLsiSnHErMpkTTI2uPA+7g+gutu37HVuKlJd0b5rrCAqhuBmHYPSWJnQIpKzcpmZNELFvw6u1t6nPFTk0FfO8q5k6aLm+aiHVBLGbIdVSrYiF6WVOv9Z48Pw6y0GzL2rWfWXfg+W8iZ6DPW1InsVLYPW41L2qdp9NEebYfT/NC/fCz57n6IsRU3jKp2AOcb85WSvOqcNcxdw5J9WLy/w4NFCB9DKhH6xYkYTQ7jvYK6cdPa6lXjgYjGSQyqMuvNAAznD/4EOW7xfjr3vTwf5M7MUSLy8RH08meRmkMtcs7jfGpj+m331iAUicvd7FICr6G4XBolsNjkmXC2QFdWkPHaMYjwlxIFAGvJkh51oFP9x+wdXc3TR2HjhFaV4xkmgqduIeDGwMeAHQcPBuouppb22SEG2sxh0i7/g/8y778UEVJeVtuKYjuCgnI27ZaEIy nrzS6zSc /84nuE90XdFHPkKVnzY+dhW8ZekmtvPQFIYGemkS5uf0rNQBVTlRMOrL4TfZ0bOjTOqOYxbYMfKnfNO4I6FAxZ3AaIEtKy/z5f5mCLPK0vFDwGnBIZyUw4vqWYVx/RCY4mjEydIfNFmcoAo0STxn3HbiEzQUh6UM24a+IPBPgl8t1BJSEGxkD2lRVMQkSm2M0H5R0HZK2sB7XXNSC1al+8ByjuecJy0qzPjY/1ZMhcu0APlMmAn3wFOMdH7t+tmx3nHNb1QWNNOLMV88XAtEyEfUJUewYT4vHztLfbvTb51dbCU0u5Bb9mMnn4YjaWVMTzZ1EmQ5KWv/EVWtsJfLOhECZTrsp0D2F5aRLVgiE+1YKjGMIL/LkPq3O9vDgGaJuWqUckOTnKKLUtrqAQmfDzIRhFTLjttLUScT/dsI9zf0zLPaPxB3HQFKB0jpczeEt39YXLf8M5pT/PxNbW/cXTyq6eFennivjTzHnipeii+6weUejP0i3P+f7kFfwFrSQgZC0HAOnDJfR5G0= 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 | 75 +++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 46 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 623bbde91ae3fe..c71c853c9ffdd7 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,47 @@ 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 (folio_test_hwpoison(folio) || + (folio_test_large(folio) && + folio_test_has_hwpoisoned(folio))) { + 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 Fri Jan 26 13:28:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532578 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 D076EC47DDF for ; Fri, 26 Jan 2024 13:30:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E8BE6B008C; Fri, 26 Jan 2024 08:30:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6973E6B0092; Fri, 26 Jan 2024 08:30:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5603F6B0093; Fri, 26 Jan 2024 08:30:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 46F636B008C for ; Fri, 26 Jan 2024 08:30:17 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 241B0C0F90 for ; Fri, 26 Jan 2024 13:30:17 +0000 (UTC) X-FDA: 81721546074.09.A3E4851 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf18.hostedemail.com (Postfix) with ESMTP id 806FB1C001E for ; Fri, 26 Jan 2024 13:30:15 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=etgfs9Cw; dmarc=none; spf=none (imf18.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275815; 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=G4dvPmDhKQKKA7EvO7oOePDM7y3n+zoGGSb2RNyoFKM=; b=G3wTjDF1+2TbQNMYIEgq1OADa3m4gdM4x973RpdMI8UJn4pQB1L49NRh0RViP0xOJloxe/ 1XwLmiVc0ES7TaGVOHRmAEwhf0TxtAdfQBVPxX1hee8ZlQolIDknYZz6Ajg8jOv7bxYxFL L6JTpeoR3/ne4WbXZam+GfY4m5GT7nU= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=etgfs9Cw; dmarc=none; spf=none (imf18.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275815; a=rsa-sha256; cv=none; b=DwjxNHAKZHPOWVznJI8t198e2Uu1+/TAd2I99WmQ+gNjh60lMlsoPfiCbVM7hiLZHyoNjt fYIkf4DIiRQLskDsHndzyECCbEd1E6CWBrYR/l7OypXQknNOzRkQW+W7Kw/ByEd9W47QVg 2U/fwq5TlemhT3QjR1Oy+yTgeorxjRE= 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=G4dvPmDhKQKKA7EvO7oOePDM7y3n+zoGGSb2RNyoFKM=; b=etgfs9CwZeMJnpY//1CFGpRXzQ m41dHwbhFTFDpvLigQ3wXMdssEfgRfx0CAvm2jPGFCQuXWAbazyl+lChXtSsIYhbWy3V6TKzyKWah 5NnSr6fnWlBFxVRuvAAA1sqxZtVWp+SX8nzldsmg4M/ZsfW6S+oaFoyWQXdaCcZmi5ZhsItVFFxO3 gk5efBkEpFDP8n7Lz26bVYwrTKqVKSc6iMudbRzvxJ3BCzctRF7Ig6AEP9bfI7Dj6TDIf053wMnpI 4OicIB9TJowMoYh+rk1FNw8cozNfvdpVT4nB3gcbJV/bBmqaaeUsAI8fAzW3zM73RmqT4fnkTHUlT aENs/zjA==; 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 1rTMHc-00000004CtJ-2CJD; Fri, 26 Jan 2024 13:30:13 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 15/21] xfs: use shmem_get_folio in in xfile_load Date: Fri, 26 Jan 2024 14:28:57 +0100 Message-Id: <20240126132903.2700077-16-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 806FB1C001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: a5hptjuopra695p535kegurown3eft7c X-HE-Tag: 1706275815-374200 X-HE-Meta: U2FsdGVkX1/ckkNeeo3y3IPjzEHvUzTnlvQ6tHCnlAXCLuVhIrb1uMf0rJt1+y2dMWRjg8K6Om6Jxj8joktVqo9neVnJlS8Y9B52g/KQS2g2pysErb7q9pdxBPUiD/8yaSN/Abcd24mw36kiHDn5oMSTXZpg3E9hM3oGMJhacIK70rEAnGOV6a+HPp2SS8QYjaCpNFf3kNgDl0W/PQr2ReWjJiRLU/ookr3rMS4vyUXHxjqjbqRleAbA0zrh6fGsofiHRmLvjaOIYCixcQ6TO0bvuybwakjQ9kUV8z4ipKj/CJIQs2QeRk4RlBnyNR/HwxyZJ9nkMSLP1/sHI0PlP4nqeC8FvA8zulVmOjLSolbeeZrvzzmVD5uECgVoiIB3dcDL56t642pvTLmWQXS5UxYOLdDyV2B+l47uXy4BwKbkNsj4mcV2vBh7lxg4Ue9c1l+5WZht3GdjS1fJMg3JMdAnbWmQEJCBBn6AlTWXEOkNAPygpAcatFbnq/wCAOCG3Xppyxu/17YW4bph6mvjGt6YyrrldN62s8D5EmTo7NnYdrNL5mBXeBdF3rO0qkUa6vItH0xfD93VFsZQzc9WYO6kVFRMUXVmygPrgVC7KuG1sqs1NjCgCVKFOOnfA0UuCStgcI1RthWRlDneZ2pXXDm/n/pIYP9tWJ8fczEx56ikoHeaio1qN4LcTdYUxqo83Zhj0Q+pRUFEDm8FG463np6kYftCvmtJdhC07dxfXL7P8oB3ROeEKTBwY4q7yCbNTaTxPl+yx3gH8bkMUL/m0z3H8u8FXRehhgeCV4jS1BuLH+/JtdXxOIzuwiS8TUUmDVQz+mnBABzzSjWP6f7y5r1mtlFiCGlgZNUky3IuvXqpqZjVCJTq3g45uXYkMGRC3cKDqRJDrHtY6y8dy2N5uLcnKDvpOMGpGxU2nYQTcPNxNWVtpqNEUFrK8ntHhgAratdTZB/nkPI6SCXZw3h W9IjzL0T /L2uvPxqDOx1LNjZ6FYJLaUJaCW4jO5Fi4qBjzDaYKVh3smHkdLNOraLCTryukMieqGSOoYnF6YMnfbdUC7sPPJwLLM/t0/f9lD3MdhMfHnT1hpn+WBdMor6BXdgNaGy1o7vfDo08qqHNcvlHI0PEYTUYNX0t10XBkNsQO3ihI1NPkcBkDv9M8kwSW2IoNezjVlp/wPpoMiSs9NtzRE166Th/GnEUx3mc+vwg4ToumlWmbQna7zjGFX+fhZ5q6sZVeWobrgR0hIsEfwy2KMel6NQXMXSWyu2voxBUk+zGjK9TDVlGz2Dwzg3U08QraWgcCSpXP03GB6hVcnpvtroGsRrj8DKzm7dtQehYyq1/YHrln0w5bjpL/e0mbPXHaXUZyw739uzI8r1FlcAKExOJFVBLI5PcTOK+8VD7dLySAUHDjrxjTKt98o/CuTeUoMHrbNJXG2+W/d4pt/wyK2oy46V9IUMkZ4V8naSeqYzHdZ9wR2qh0Bgm5vAoiiFGu+akTshUD2fqzwan4lk= 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 | 63 ++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index c71c853c9ffdd7..077f9ce6e81409 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,46 @@ 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 (folio_test_hwpoison(folio) || + (folio_test_large(folio) && + folio_test_has_hwpoisoned(folio))) { + 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 Fri Jan 26 13:28:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532579 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 BDFACC47DDF for ; Fri, 26 Jan 2024 13:30:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C6B46B0092; Fri, 26 Jan 2024 08:30:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 400D56B0093; Fri, 26 Jan 2024 08:30:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F0636B0095; Fri, 26 Jan 2024 08:30:20 -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 1EBA16B0092 for ; Fri, 26 Jan 2024 08:30:20 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D9C6CA1B99 for ; Fri, 26 Jan 2024 13:30:19 +0000 (UTC) X-FDA: 81721546158.02.A0C644C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf06.hostedemail.com (Postfix) with ESMTP id 333DE180021 for ; Fri, 26 Jan 2024 13:30:17 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=xBGHGj1Y; dmarc=none; spf=none (imf06.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275818; 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=V5jPIUfKsRr3xLsTmFNsrdIB2xqWv10CXj3w8yCOnis=; b=A7IflLPS5pPo6kdIYoQRuTe3dcEHKNRELDrut4zRY/PZqWF8QY8akhHWWMav3qefz+CCS1 ofqPCK66fwcvVQcpJmOSQFUtyKDBF2nJ1Fk2o9p1y6BYt+UmasEB4TKsaYc4MCYBTPF0qW /HiD3PsvhFV5AnQKdwVHDq3lTp/fXUI= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=xBGHGj1Y; dmarc=none; spf=none (imf06.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275818; a=rsa-sha256; cv=none; b=hFbVqTNXaAL2Ei36fc+YV74dqdGIa31o0l8ZEX2yQT41J5FDGtkht2N+6SK2Gwy/y0QE3I ib6lFeokAOL9oJuagrBAwIpcAuk/TD3E8vPjVdqypJVhH0WOaPuI4i+GhVUOeRkWWU+FwJ qkFsG5WhVvyOZQj+B8Sk6fh/VMlWQQ8= 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=V5jPIUfKsRr3xLsTmFNsrdIB2xqWv10CXj3w8yCOnis=; b=xBGHGj1YCvV8LW1bNvApAzq9s2 +XE2hub7o2/AJNtq37KwJ2Q+3ma57HUBNiG6rICNZVXDFHwoT5eTlKlpRnzcviEeSqJD+EFL74+2j rE42kauLYoPjXb5Li/njzEu2xtBBkD5iXHLqKjftVAtQbGhTbdLgMX0DPoBZUo8WgrsZfnnuJ9I03 kcLvGUkg6CTQMPpsFOkzfVLy0Zon9JmN0EDBmCLtyPJIv7m9zLj6bK1I2y5BQjbXVEJ/h84WCwYBd UsFCmk8v7Nn8BTE6HEXoidT98Asq2lyAA4h+fJPEx0R80aDE8gRpCpr5l8kkRkeksaOPk1tyusiSb s/QwandA==; 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 1rTMHf-00000004Cuq-3E2m; Fri, 26 Jan 2024 13:30:16 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 16/21] xfs: improve detection of lost xfile contents Date: Fri, 26 Jan 2024 14:28:58 +0100 Message-Id: <20240126132903.2700077-17-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: kdqihzb1h63ts1gj4zhchbybcugorbcm X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 333DE180021 X-HE-Tag: 1706275817-95630 X-HE-Meta: U2FsdGVkX19LH4qzN61qwy1R/JfCpqEu13PfU1kKP3u0cBqgbn9DIwgp6hVgjcNb21MkeUQJD46zMEe+wKb1M6T5QcVe17Rwf2pbV1qERhD1Fyb0npTmuWKdCSDaN8TiwKdYOaeWw+0hjHNe5mJ6JGp4OAPOl1KhMNXCx/bM+3s+UW2dE272IvmnIKEgydhtsHYXIyeH8IAK3xN42TglfuO4dcH5ZdPKlqUEs318VNjfGlOC6zljGFkt9yhvdMdQZEx28vhbk6aFTA64qgtCfkiSrhWGJp2dUMJACH1Grh2VGavmwygOol8qOvB8h4r0Hop4Z2RoQgchK/dORb5ihPhR24VIhlMaq/S7mHMTaXj2HTOAYwj2/Rr7LSjYRTNC0vDQVdw07NAg64/75iq5XD/V6pHbAS6da6fVUtSBQc067XDsX4P/MQ5X4XkEhEGRBjkpr1KvzkPpZ7spB+GW1h+B8dJgabsh6QGZ51/xG3R03NEMuLsWC6shKApmMsnCXb01oIbfbMnFygusAY6eH8DQH2xNZKFkWVyp8EutCeQ2FIfhvZFCTp/M7xXHMaOmfEsKiBW55GPYsVM6TKg/Kaztvm4fuwa4gIk6n1vDLqfVQ25s9UKSNeCIeBJZF1/j9AlFxY55vsVUM6Q0jqn2n87DrAMGFPrfdIdPky4Z6nyUiGvN/oOpDwS1VZEiOuc02KlTWQg7MfPDOeEnH9VVDptuGAT8p233BHvP8Kq7L3HnZYyetY2FdKtZty6OpHduo19yEX+v2BOTvpGlBG0xEfMbHURBsjHDpm2HCsYBnmjyiRakUsZyc06t8cPpuoZT2meh31/TBKv5BNufSmmlJyBjZvHWuNDfPUN7lPSVqxnfflzdQDxFHa5c1Y05TZFGjO+z9m+k7vU8BrzHtj0Y2VwJ7aIoJKKcyJ8Em9J5aUCP7Ie8XKwb15rxsmZEr86HExIMTeO1m4gx0JU2GCl IQ/oqGIg IiOe8Gu5f8fEjtxuUYhiDETSi+MNGxiTOMUa5EI6BDRn9SX7sJbvrOdZTKJ7BLgkX8otVLVvhCk+uiiFkZyTMV+RX1ktbuDmvV1x0t1FSVvzxIV2Zg1uDZyOxwTco8rfVkZ3uEUpUi507vlaDU97oN6pqmgVvM3Pcc94TyWl7GmNm841x3e9MvNeJ48u0hr6mUfiTf6Pi5cF7/SVbiSNgzWKA/NUeMMjJTjJOeZtP+yv3uaI2/1Mi+V1O3LxftXO4nF5MBV2H0G+5Xutkl0CIA4tGYvfmWnaOIko06QKpvJ8ZLZaHN4UMF3sx3A6fdmk7UwvtOHRM7KvZ1IkdsC62rpjPjfgWBOuyhNegginGW3J6Xqk5KZht8kOZU9YkTFAppIfObJqvsP3o+iddQKaOYOLJ+Vi24tsNamLJd4iqxFle6x1eqMgmv1/TP3nfAHlifS6wNrj+1pCE7dgX0hx1kpG1Yw== 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" shmem files are weird animals with respect to figuring out if we've lost any data. The memory failure code can set HWPoison on a page, but it also sets writeback errors on the file mapping. Replace the twisty multi-line if logic with a single helper that looks in all the places that I know of where memory errors can show up. Signed-off-by: Darrick J. Wong Signed-off-by: Christoph Hellwig --- fs/xfs/scrub/xfile.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/fs/xfs/scrub/xfile.c b/fs/xfs/scrub/xfile.c index 077f9ce6e81409..2d802c20a8ddfe 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -99,6 +99,31 @@ xfile_destroy( kfree(xf); } +/* Has this file lost any of the data stored in it? */ +static inline bool +xfile_has_lost_data( + struct inode *inode, + struct folio *folio) +{ + struct address_space *mapping = inode->i_mapping; + + /* This folio itself has been poisoned. */ + if (folio_test_hwpoison(folio)) + return true; + + /* A base page under this large folio has been poisoned. */ + if (folio_test_large(folio) && folio_test_has_hwpoisoned(folio)) + return true; + + /* Data loss has occurred anywhere in this shmem file. */ + if (test_bit(AS_EIO, &mapping->flags)) + return true; + if (filemap_check_wb_err(mapping, 0)) + return true; + + return false; +} + /* * Load an object. Since we're treating this file as "memory", any error or * short IO is treated as a failure to allocate memory. @@ -138,9 +163,7 @@ xfile_load( PAGE_SIZE - offset_in_page(pos)); memset(buf, 0, len); } else { - if (folio_test_hwpoison(folio) || - (folio_test_large(folio) && - folio_test_has_hwpoisoned(folio))) { + if (xfile_has_lost_data(inode, folio)) { folio_unlock(folio); folio_put(folio); break; @@ -201,9 +224,7 @@ xfile_store( if (shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio, SGP_CACHE) < 0) break; - if (folio_test_hwpoison(folio) || - (folio_test_large(folio) && - folio_test_has_hwpoisoned(folio))) { + if (xfile_has_lost_data(inode, folio)) { folio_unlock(folio); folio_put(folio); break; From patchwork Fri Jan 26 13:28:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532580 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 47A8AC47422 for ; Fri, 26 Jan 2024 13:30:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C19F86B0093; Fri, 26 Jan 2024 08:30:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC78A6B0095; Fri, 26 Jan 2024 08:30:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8F606B0096; Fri, 26 Jan 2024 08:30:22 -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 99BE36B0093 for ; Fri, 26 Jan 2024 08:30:22 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 700A8120F6E for ; Fri, 26 Jan 2024 13:30:22 +0000 (UTC) X-FDA: 81721546284.02.1510414 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf15.hostedemail.com (Postfix) with ESMTP id BF10BA000F for ; Fri, 26 Jan 2024 13:30:20 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qIB7chEq; dmarc=none; spf=none (imf15.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275820; 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=X21Ew2yPXjed2nTt3K1ULzd8XdBx85Zv7/geftx1aII=; b=6dTgRbIu03X9UV9j4P+SUUXPL2A3P0O/VQv9JrWi8YxOmF4RnFX46M8QsUEiZqfUZesEyH PrTm2BQvR8AO1Z9gLTCiHr2px3plTm675qQCWoOWc7I0ECnfbSulLx/V6n5qg0kecTRFFV ccb5kNqru/crxfJaWn/ILAEiidNt+Tw= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qIB7chEq; dmarc=none; spf=none (imf15.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275820; a=rsa-sha256; cv=none; b=zuwzdQBvULV43e2Aq6WbwoiVtHZ+euaMYobgejSKAfwX7yyLbHvOV6sAvhYjMkQk0XPMn4 jooK925ANPPhb+SbtdpPs8CLGovqx1hArI7JWRRAWpReQVkSYLMbzbKLtRq8JmkNx8AhVJ YdZlEwdoNPSapSvwBS37LUpWlLtMI20= 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=X21Ew2yPXjed2nTt3K1ULzd8XdBx85Zv7/geftx1aII=; b=qIB7chEqXgv/83F5fXU4aGvZaF cd1gr+xzZw1byceF6Z11y2RibY9b3sEMHeiM85ZZzIL5byv2cYYlZdM05BTpxcd61Rcu8tqNYNs/i ojQ0/qtmksiPtgScHRplfmQi7MD/YEpH5s7CiBjxVuhxk3Wbgw93TfJq6FDsFZ3uJI3IJHD7EvKzC cDbJA8pcexmkTiJBDFHKdiCXdiG/X9HRYys7MiXf0ydJ5RIsL5QhMTac1wg71uQ50ggIgC0LfBqn/ JELRJFtYSrnVxj22jJsPkF+yhbtPR2G5f7TJ/kJd/GUsZBwSLe0wsjDhiFUNJTmhLu1OaHRE7VfXO 90Sx2HDw==; 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 1rTMHi-00000004Cw5-0efr; Fri, 26 Jan 2024 13:30:18 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 17/21] xfs: add file_{get,put}_folio Date: Fri, 26 Jan 2024 14:28:59 +0100 Message-Id: <20240126132903.2700077-18-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 8pd485d6h8s61nt1w36bajh3e1xrxwcw X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: BF10BA000F X-HE-Tag: 1706275820-286744 X-HE-Meta: U2FsdGVkX19VwSFsWGsYY80T/OwLsh+Rcjg8afTUm71tofbzNSOU/lJ/Ftcjbe4wQ+rfhwJNoh3lTfTM47BwxPBANecuBaQXswoS7Wf3KvSsxEkW90eJQVg5jmMqH0YEQ4tiQNZQxWqpDYEOqAgQdlgUhr3nPitbz9xFmsIP6GtfiwobCeqZvCHZqJk9Mk84Fl/t9hwOeXXCpSBAWWA161Mci3sbPXuObtM2v7aPwqmr2pUkgORe4XNIUdXch88+k6hIuQXjNTM+COGVmegatIOESVP3FUn1YaDnm20taWDByIZbkz3JP3/GunEdMDLI4uU9Lb9Ri6ooaDtDXiuipnzv58Q7PR5jsRcJxvSKsChB9hmNaY+2CNTnyMICiKGVipv+d3wxoOQwUv8Yr6UlpTymKsWQvtENV82CLZ6H0SGOnGchXtEFB6Dg5V5xx34//giUZtxzrVbu9sV8gQVPElxiwyyf8ykaxZ3W5H2gScnx+sFO4Yh5/eKjPitkvml9uM9YFtOUsAjM5aEeO+kn0u/LqYZnfwwQFbD1XKof/RkXvnDaU7w7zKVn4dBEaILATFo0mUL/xAXXtnOCcV5fR7CV0RAKgITNF+leN6ra3nGOGjJehJSONCQZezjcBzV/IKNykENXuawQkNmr/Wr5lKELtUJozKnApem7fDylUjUIo7P36ncfJW9FkUxnC3xMxf/KTcwHKNnfNeMdC1LhQWLojNN5lKAF1hSGCmp8CqlYG3Ftyewt+U/KRB5/1p9LrWJf1gCDOhFTPbameoq0FWBzCQ3ULJeGZ0v7VfCQVz7ipmbIbZzif0X6GexaXebywzpRNQyDgdUmXECP4PwKEdtT5o9kelTGS/OjzQBnL/ZBp7CNkTNtVqJlOznjk5+BWtqaicZv1knxx55PZN1fojDacwVNTbhiLAfaqpHJM14Fn5l+egDOhNydW58X68jlGReScVR9pTHxRdHsgfU zgxw5nwD a9O8UyLoeMjzrJEySEohMjaQqr93RRzHbtlOfXYx5Er6tiCnrE/GP0p8W5bMuBXQKhUA+8hUB1hIfFnp1GUyoL/thOTS1tYoAzO+q0wB2x67fgeAjvzvZVFSMLGYxzS7eeFjyWHMjycsbpl5aDPM2jLufi4lKB3rgYff/OdIMLecpdzpNPZTbwfgFfOCTuyWh0gVpIBz88BTYesqrVKr9EULKafRvAINeM3rq/Oq9kxrq+W7oDzbyTHEtqRBs7LOPR4qzujemjVtKPB/zFmWwQGP3tC2G3w0wAL9A1+5XE80XB3RO+JngI/9OLeGMLlP41bw6A9ug7A6i15g/Ff6Xh6YyajArD5xh+q5JNTv78Hx+P2kv8VVKw7p0A9X9PTzRInewQb/pA54mn9c7/NN6ciSPADyeDcuayNK08Jcn6vUEGE2VuMoFZMpOTQygFh4AqZ1lvtNiFwSO0f8bSRgWJTsrMtSYkt+BCbqc4YUhtg501i2BOyggjBKCIEswds1Y2/QuNnSIs+znz7s= 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 2d802c20a8ddfe..1c1db4ae1ba6ee 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -365,3 +365,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 (xfile_has_lost_data(inode, folio)) { + 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 Fri Jan 26 13:29:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532581 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 2E444C47DDF for ; Fri, 26 Jan 2024 13:30:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D2C96B0089; Fri, 26 Jan 2024 08:30:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 734556B0095; Fri, 26 Jan 2024 08:30:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 622C86B0096; Fri, 26 Jan 2024 08:30:25 -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 523606B0089 for ; Fri, 26 Jan 2024 08:30:25 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 23F2780F89 for ; Fri, 26 Jan 2024 13:30:25 +0000 (UTC) X-FDA: 81721546410.17.80A9026 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf01.hostedemail.com (Postfix) with ESMTP id 5070540028 for ; Fri, 26 Jan 2024 13:30:23 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=sNyn4VLF; dmarc=none; spf=none (imf01.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275823; a=rsa-sha256; cv=none; b=FKHN2G3g3ipduvmuXmRs2rMVeCdh1uaUFRJ0T1TywS49AkrTV3aSdOc5qTl1LEEm9cR/RS H8urojs2jLc2s3Tjbb6GE6DahbvmsyXXmfAMDb3BZSbJgVQbKarBe+dpR4dLgq4mNaDuKz zrvAlSIUAbZjtqYQLMfaKq1ISU9UrnY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=sNyn4VLF; dmarc=none; spf=none (imf01.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275823; 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=ttua2B3ihRJuVM+5WlA53cpurniY7J8xPtHp9/n1qdKBoCnb29SLJJb2rz69iMhoEbjTIK nnKv7+ubU3r5WrR4En7encr//+ikxgVjkWEwrD3TloQb1KdXE8KhnktD5I5TbkjbU8qQiM mc88YSODBcDOQ1RygeSCevyneUdFrsM= 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=sNyn4VLFKK7KKN6xXdNVh+Gfrs YBZlvjHMYwgFA+xKWQrZF1xEy98zlVXD3oWPI4rdiDn9jHVZVBojX4ktb8ro0huk+/Rtbvq+3aHEL o3EGv5vggwpFIXq8rztl0TM014nJRnm8iHWkaejOlbiCKE+5Ph0d+SwuGkIfUQmxAqMiulNZzZJcn EZCy8mEVpGPIJ2DWHMcl7+3xIyLOq3Ujt5AAIFOL1ypE70AZQ7RtPkXdwJ8/il5RKfyYfW+59dNJn qIsySAjobSf/eQAHXDf0Jttu575b5KGI33DUnN7B6fjakfL/PLC0nqI1LgytJWT2es+JJQHy2oQld kWF9qCAQ==; 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 1rTMHk-00000004Cwj-3jOh; Fri, 26 Jan 2024 13:30:21 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 18/21] xfs: remove xfarray_sortinfo.page_kaddr Date: Fri, 26 Jan 2024 14:29:00 +0100 Message-Id: <20240126132903.2700077-19-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 5070540028 X-Stat-Signature: i3zz39xf6c11nxzqujq8necst7kbijd7 X-HE-Tag: 1706275823-558412 X-HE-Meta: U2FsdGVkX19qk0SgH+c+eSMMCrKNtFUDV8v465q2bMYa/pZH/N3aK30C1qVSNN6hBLBelpK66/rYAKpOCEE9wC/TbTe0ogZBD2R+8kU3TkHe2uTfD7HWTGsDM7FWhE+FOfVpz5HyC2p/1T0ArWEwgdH8LEbXj/+YVhVZUb8S/3jrMwFjiJGgJH5doeQBfOnzAdm8LVgj5L1oWvmYOKWkMsCzFXjKn8tudMpcX6ZElQxgZf2KqYbDIaeFjwg47fEBKrjB9r0Qc1EU2Ni/HsL4SwZXZHFQbR4EXUn7qGjNhh5dTwtWdxa2BAofx/fZHlteRlNwq7tJW44XpHbp5BoAbNj9u8F1YtiZuKxO/i/U4+Rb2eOveT0c8D+MQzd7uut5xuIG+nfWky7V+rjckQ16Za+2/AfFcGRcbvPO4io/XFGGav8LbtBZelV4z27SaHIget7P99dxs8IwjM9Wp4zbL3gieefVfn0+WHGwftgTcg4hGkojuuvZaNRVBVuwWPM2VCT21BvzVtlYLrJETf5OpGsPU+87SpDF6pITilh17X9p4Uh1AERPBye8xUgtHDvj+w7tJ+K8B3+xc8uZiKF79fPgvwYqCNI1JnDm2RIF96dqucVCa20avFXn1qWCvgCLra+VGHFZp0usxmVk+HipPlOFJwaGNUyHZ9z57pfL9Lh3xlG12mT1xs0CJLUuA6Fn4E5lrgMXqjzniIaiB1JYCG7hqOZ2ule/nBjRGeN7RQlgN12wxaiD3q+n/+YH0mgZ41C5HAmJu3X9HFF6Qc5JQvFPOjfqDLEJ2TiaaTvcTss34ymX9mcAaOT8CUdSdRyaf6hWE7REubmTUqNaNydG9QjrJAgvFm8pfVa8VMtGPs/Hq08eRWviCjrj5yho9AmiNESzp/AhrGNTqyNKv8TXDlzz1664OE003/QyDJq9pTeQ6wXdm0oGf8lgO4Mm1Nd3RoUSg7ZjEfEEWcHdGea krzTA4cZ obvrjuK7xYjXCMcj0v60xbUfBl7Ni1uJIU1sttmaYQrq3p6SrKxOsr9U8LmfqozE6F921k4GfR33yCzEX/uNtWaBt01xWGbDL9RQiJp9amQ7U1+w6Kx9oU+A9e8VvFOr5fVBXm4NMZCoqm/tUF09CeI/btodRZUnBPoIE4dxp5nQwrNSyM0vG0roTukGb3tpNtoh9OX+wBxRS9J8hq3tZn6q8U/spquLHNkMKo5Gjc8s5mvStfY25WZZLEGI13qz4/ve2fDp8kltRDWnkt1LKTAveLABpVs1sr1AFW6cO2CMMVZ98jdqZNpoeDKvjxs3gRZprGeiRaCGd/b5TdND1tZAmcvPmxFRdjQFxv0jwgofK5Vro04qOowDIeXBvXGKCugkqW8hETgaaQ/LserchVyuiMtYIb3KKiIlSisrYKG5Wefe8aWAJ47tOZCEshgzFHxu5mwnXYIV0pjqp6ydPGNfvCVkM2D+bkgfZNLkX6xJmZosx/0eJryyoudxHOkQVT/dwMKqh2+FZPMg= 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 Fri Jan 26 13:29:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532582 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 B397CC47422 for ; Fri, 26 Jan 2024 13:30:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 428AD6B0095; Fri, 26 Jan 2024 08:30:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B3736B0096; Fri, 26 Jan 2024 08:30:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A09D6B0098; Fri, 26 Jan 2024 08:30:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 179D66B0095 for ; Fri, 26 Jan 2024 08:30:28 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D8BED40F5D for ; Fri, 26 Jan 2024 13:30:27 +0000 (UTC) X-FDA: 81721546494.10.D35B878 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf11.hostedemail.com (Postfix) with ESMTP id 21CAD40018 for ; Fri, 26 Jan 2024 13:30:25 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=bq6TXgEG; dmarc=none; spf=none (imf11.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275826; a=rsa-sha256; cv=none; b=i73fXN74x/iP3P2bp4ZRlPcKpOe2bNhCUsPmRyJyCVBSTJkGc0+6fF/9U1mMqKruqYaQ9r 5bjTxj59ZTuDUGpfP3wEI4D0omleR3esT0qOF0I7MOezosSKngSJxWB1N0lxmStag1Smix JqsCdcKYFDxJvcA+UcSn+jIGwq3WjqY= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=bq6TXgEG; dmarc=none; spf=none (imf11.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275826; 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=l+YInNfMva/lG+c/PYeR+AR5MBjafAbR9eqa6hIjSTPZzZFRS3LsXLKBZQYDU6HfepxB+g KKs6w6A9PCFrOFivsRPudrs8hAr6M+iSDLs9o+MqKyYdpwVd7WX1BMzDbGpyCth9P+x6By UQfjzNbakb8r0k/58iVTSzNp/+fbOzY= 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=bq6TXgEGS6m0Rgq3y08f1yk9dZ sWghYBKjyHZrySsSTo2ZBOh+osK2S0jThJamBFx7T/lIARm1bQTWEbkOiS+hFgOGtSGaFwfjvQpL+ 6GIC1zfxbFWhb9cF15qiQFfa5NVyWeVQBvkOSDjGajaJNqHWFGHxXB3H0t9R4jfU4IBmqydNV5e5H h6v7nHwhjYJrFNBOKE2vTdjDNuaFlKn9OPt/PowxxVggaEqekThbYbPQv3Y065Ue9050wEhNtq5lK YFs9OuXCq+LLLyyIuU8B1l4aDtBV+QnIiUV0s5jQCkglg6RIalaPO82SnNjlDjqtb8YcvQJHBn9jC Qv1QNZEw==; 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 1rTMHn-00000004CyD-2bM2; Fri, 26 Jan 2024 13:30:23 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 19/21] xfs: fix a comment in xfarray.c Date: Fri, 26 Jan 2024 14:29:01 +0100 Message-Id: <20240126132903.2700077-20-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 21CAD40018 X-Stat-Signature: i5oru6jtj5sttdt91xaw1qzffusuum87 X-HE-Tag: 1706275825-54140 X-HE-Meta: U2FsdGVkX19yIuulVhqpeiPtBdCnnbvHCBbsO2PBTm5TZFspWeem1iyMMp8xl6I69/y2l0JG5HYcob3mS8EVj+bP0FC9Ke9/qukFCVH7HTBsbKEbCtA3A2Det1FKWofiHY3fU4YxN4Ff0pu23QFhQeLMmTt3XUg/ZCZLvl+1UIhX+Y1mkVFoC9cVX5XLilyHDRO4Z+nC4tWLrrzN/uI4SP9fvk+4lpZKVqCnJ687o6dGHnZVwm8BGkjCOkphOlezYeDLSg8gWtUamtEX1rOo2HGkGx8e857tsZmCu6LFKowfe9QDPCaQoH32j8Vqxi1OP1EsyaDCX1IK2kLK3KK0chTDQRjpGAXJ71LlZXgeMCBPG+yR2EEGv6y/K7EtunOLm1+A2PNM5ARaL7/Mw4SstVVwejf6haWrD1Xyj+imAteDKKVA++6JfDJaYBuxrql62G4rgk1ijvjJmWFo4kiA8afq6rV+Mz2jNCC98iE8tgFHrirr601kTK9Xdv1oM6U7y2ru6N8lEBCxgzFCrU3mfVDaViPqPYqLnnnFFIY/wRIPv4rzbLDrhzKa3740RiqryGo3OzdDjE/biEK9z93teimg7FjSlP44kGwRBDiyISzhmf2WSaf9OzMdGyUuLNQAyuML1jEe/7cEulO1W4uoHKXElndQl3tu39AlgTQGzqR9TNO4du3T9H1Qys7spvMdiqoFV7CgdF73V9K4nWL54BbQGiaQ7JjJND2wfMif0zEQCDJVse6cmAtPX/Hz0nuldyaPlukYa1Va5qhsHC1/VsF2EfpW0rpCAQjOTlJVHITNIRQkeX7WuEzEFenhEGRKR5wFO2ylvJnNda+28rYKAuauZJveVvlEqKOQCY8Kh+NCUKBC4795MEX9HYfHwmBcBA0mlcamcg/Cskp7SLxam7/Gu8KTMFG+IQYIdSOyUbBW5nL9/THW37vdvsS4s8YBQNTw39eS/nveVYbIEXi 85dYlx0f OuCG8Zg/a+t3gfHSH8TucZhOWCFjJjU3uY3IbK8XNaBXDKlvFC0HxBp22WuGyQbEOWXAMow61FZMfVdIUm+yrxe4OCdFCYNjzLpisocOi/C6Q8nb0k1Zr4zmw3o1AdUIvthNW3C5xjN9NGmVJTuz9IVZ5LoudckFQUpr+ruLuUzQfVSJaONGzy4jsGTjK1nO/NdFNTiH5r1dMIrYTjW3VSXA2ZDy4Lh8icOzHLRPAi2ZYgawKfMhP9RV8ArQ4O191pARu9Vo2PJDKU06blQv0bfVnDJ1KxOx/TiUrpj5dQbIjWCMmDhollbwv/WkaiA5pq7UzhRaHpDg1IX1Wn9g5rZ4OTICG3JI54Vaf3iGOWRYxonYG8K5Zq+Hxu0FAd7gpLTyVadl/ngFhCAFvCwFjNfxCHLDXPbXSupsZ4Aw0++jW74dDZ4KMnL5LP5BRB7Yr9Tdgve7l+AEE5fveD2Ahm8USqqVr7xcI+ClDivGnKHQ1mBIL6ELnU25BRQ== 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 Fri Jan 26 13:29:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532583 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 32AFFC47DDF for ; Fri, 26 Jan 2024 13:30:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7D856B0096; Fri, 26 Jan 2024 08:30:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADEE76B0098; Fri, 26 Jan 2024 08:30:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9306B6B0099; Fri, 26 Jan 2024 08:30:31 -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 80C6F6B0096 for ; Fri, 26 Jan 2024 08:30:31 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 59F74C073E for ; Fri, 26 Jan 2024 13:30:31 +0000 (UTC) X-FDA: 81721546662.20.100E8DB Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id 9DF10140019 for ; Fri, 26 Jan 2024 13:30:29 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=teotdbtZ; dmarc=none; spf=none (imf23.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275829; 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=R65vFoRwXEcbpDPh9sk2joksz0b+qXxKQPYH8JdojnY=; b=20TgwgtJ5i8KLdm5JRveP1BQDHK5jUdPdMAxZTgfHCHm4ONmO+lQWHgeYzaj7Ulf4hg44Y +bidXYA0DEUaSjltj1TwRkT41yNF1COblPL5N5b1T2tbyTOoklz3WKpT7gu4TTEICUvVH+ ka8gt6lVmhSkuZf4Y0MkEbvGZJD6hlg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=teotdbtZ; dmarc=none; spf=none (imf23.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275829; a=rsa-sha256; cv=none; b=Gt7BhsqaoJh+Fe8c8swssgtURv7GZhFJclZu5bI6WKvZ18k3W8PZKUyfgTapIKuQqGhFWf 4ILKgDixUqBuCjP4zdzdkFmOlzwRTG40gKVCyS3I+yOOVjaNJQTpC9t9oyCCSeDUjrwzDM vIPCM1IIpRH5dQvSvW74OOImSiDifgI= 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=R65vFoRwXEcbpDPh9sk2joksz0b+qXxKQPYH8JdojnY=; b=teotdbtZ3zhU9LE56kgDgixM/1 A5j31X1bYN9n/qobJsPEBAw4kLlLRWVtxijErFpO6jCBuoVtZBvUwayCJiojz+r492ZmlmOcizxWF QtXk0ir5sPVD+4CTcmisar6jYiNoFIn25ypY7OQW9mmelkhur/mabcYPDlgTRESfUxj0Hzt/4HKY8 my8EkmTVdLD6/qfP+RMzHHazrgZvm4hO/ZaqWx0C+CWnJZcXDPYfISHMmPQKvHKIPCgWXVMcjDit2 18yAaKw/KY5FNOkQbQQZBbmEYEZxUAJQXbbMZeLrylPm42i2swKTgNJZr2calu6A0O8b4WhGPBgRJ s3YzbtvQ==; 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 1rTMHq-00000004Czt-0kpA; Fri, 26 Jan 2024 13:30:26 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 20/21] xfs: convert xfarray_pagesort to deal with large folios Date: Fri, 26 Jan 2024 14:29:02 +0100 Message-Id: <20240126132903.2700077-21-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: 9DF10140019 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 85hfkygapyx6rgxrrhqzqjrhzmkby4io X-HE-Tag: 1706275829-739874 X-HE-Meta: U2FsdGVkX19wmdIdIUrQFOid6nSd9JuKAP5rxkQ8VOxd0j96UgJuY643ph/fq58pcAfqtAjeVnHd6BoPgdWFI+EbTQBa2JOGgdbDqAdTTzM6uMXM+HMj2aNvL3G2/7LU/Zbx8dr+uWlTmVHFTkuNtHR+uZTRzsWkknro9KqSbhlDmplrtfnE8CX++psN+jUJQTWhYSWGA/B+1tTbifRPWn8DNTwO2kvoAEAMI7X6m2594z+a//XsnQeMhIOpHy0H8+XK5TBlhbLrOxSg26BPfbScJmXeUdF6b7jaWpexs7dP2hUEIX99Gb7NS3LAAOf7BpvN9FMLo+z7KIkbPFGv5Tz7g+AgTQLNHbpMyH15D3BgMaI6WKpT4PVo1S4UHUYSoeYOWvrvK8crEb0E7UC1sGDxI2AOGaSN9jlk+j5EKZTicwHTQmgX/YMOBItTK+/XLbl6TVnTz/0akDb16dsAiBPXBxc2/lSsfDyyhCXFp5I9a6bgp2qkg8yqieHzhM+TaPWQAzHGK1sEXVZM9Xx1G1beqJGO5dPSETH7XrvQHfnHCpbIS7bzrXwgcqR1W85ZnVryPLmueC/ldXgWz1xFd3TqnDlrhENJAVbLEyVBnhTAXjA+1rDJ3LqdLKkZ9bT/ifRnx9bTCHegknb0H2hYkoeKGXvhigT1WDfGjPnHsIkKPRGRP0oc5MCmoIjJ9wwRYUwptENRRiRjpJ7yAvFqXZJchbsVg63rqYWkpFS+Zigh2Aj9D/Snam9sg04LT1qB5ONdsmUKRI/V8ftveHshOP1ciIqtO6GSnjx95z45jcXLndjz+45Qsb8iKYGoBMkY8ZjOkJGtF2Q5V1WZB+EuS04I+QKxtgylda/eb/lUD4WCjCHCf4to2ivLcwA0qAIajDkL93aljHIQuIIocjt+lbrkLgkPkN4FcYDvWuVBD2Mrq/CquA6DV1fFYrxbrudkhen2M+CD2Jt/BjwnX+u 5gImafOp QWYZELD5jvqly9NHfQgFOcu6xcuC/qIUWvDVW4PV5vQDqXGiIxrra7ZvCKHcoyENlMyb0K/sRZH2SN0ITYfAMkzsWAoflYQt9QfO4vQgt6Re5cviWr+KL4i1nZp7PEZFCnuX1YxHhhOhL/5A2AzRf0bQXWe+tRDHg+/XUQ783GG6Dp42cDC2GYZ+nU8wBrhiw7CVtaFieAdESB4i1SyIQ60InXnFp1n3JD3TBe+kahSY80vGhirCGlJ2Fbk8ajDq//iy3rfeqT40qNTvqPfe9ReT63RL53+5QZJxLT49DMk/AmrzaSA3lp62iC/TVJjiU4OiVowKHwmQOcbajyJwU+S0n2jLRkMG4k91d0W0ItkQtEQpw1XmLKyjOTF0/EADXdgY02LdXgjFu6X9xNPpw605960mDLFEsJIKjeOVgPW62dR23lZ0ILpBktseFU8IyewhqvDNM+o02t5P8jJBfRMI0PjE9I0kVbn5TNK4g/fPRE8mO+xXQRYnggxQvRW+gxcfN2snF9LVOvZ8= 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 Fri Jan 26 13:29:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532584 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 D888BC47422 for ; Fri, 26 Jan 2024 13:30:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 629FA6B0098; Fri, 26 Jan 2024 08:30:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 539876B0099; Fri, 26 Jan 2024 08:30:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C85F6B009A; Fri, 26 Jan 2024 08:30:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 178E96B0098 for ; Fri, 26 Jan 2024 08:30:34 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E7129A1C56 for ; Fri, 26 Jan 2024 13:30:33 +0000 (UTC) X-FDA: 81721546746.06.C6DC604 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf20.hostedemail.com (Postfix) with ESMTP id BF3B21C000E for ; Fri, 26 Jan 2024 13:30:31 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=jE2JcShB; spf=none (imf20.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275831; a=rsa-sha256; cv=none; b=e1fQUPZkWsqs+C/Xdqdtc8tnck/iYu89WgkyJ7+5t9+61VsoZKVcg6URGezy1PWtKqrb0p lvQLX7W6iUfgZnOHEZHBHwvfI6x79P9llTKzfZpf8OuJ4yOpPNdUVgwH4LEroaRP2Gf2M0 uWgK8osn2/34OsBoWwsDC6TW/oif4QU= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=jE2JcShB; spf=none (imf20.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275831; 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=EdPHxaJrEpvYS47DuOpNsvgoqsMU5pwpvkiGViTUEi4=; b=gtGian7jWJ8+s4vHaelCoFlHIR8WRO1gBO9wdqG7KlFgq1RuvzVFmnnDzXVdi1Mq2XjAqL MpTQIvO7AuOkS2vDQHTWhDACX1GhdQXt5RHateBsjdNqGplHUvECTGtwwt4QY3E/ek94Tb I47IVP9COtbbWgfp+bF+I6PObTsjFhw= 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=EdPHxaJrEpvYS47DuOpNsvgoqsMU5pwpvkiGViTUEi4=; b=jE2JcShBkBsKdkG4zAj+XG0TWn bVotbjajo3zPhODcubukD0IKcBJBOCq66GvCGgnP+AGbvTL/LT6v+++oAZJCtDmDiFZURVYUemGRg bZY+G0Mioo6vC9v9/43BlufjMoSD3C18eDlh4WfsuMg1jUvRVgkdgFDeeUNW552gK570hMFU5XLgI +7O1UlXMWW84ZWpP+OE3XC45AJdHnavYBWzW/Rd9NJyuK8v5HEJ10Z3DrPde5EMog8LgmTwTFR9bU aHSYusDAO1/X1X/iOTGNpCTLYWkG655EisiHFy2zrOkmqF1sYtpKpv4P0FipL7fhJQI4iSCbHP1Gc xpIXsuZQ==; 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 1rTMHt-00000004D0q-0NUM; Fri, 26 Jan 2024 13:30:29 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 21/21] xfs: remove xfile_{get,put}_page Date: Fri, 26 Jan 2024 14:29:03 +0100 Message-Id: <20240126132903.2700077-22-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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: BF3B21C000E X-Stat-Signature: 4qe4dbrtngztgocfrunpc79rhksj4n6o X-Rspam-User: X-HE-Tag: 1706275831-248681 X-HE-Meta: U2FsdGVkX1/41BqKbNdUzm0INcP6IOwB/S44txwHM94vbrMciG0LjgfRuvAyABKxNg+biVfvk3ymPoi/HvIW0pW/2tVFdQJoeajgDwN3Gddb8nSa/JRoFC+sbgjVRC/EMyq0OKBfu0wrhTv5+bgCgl1oK2BVA84WQucQ78QVgPWbciQ7pL1pQNHg1ApNQygVmh6obTujR6dKQX5MHA+Naquo6ACv+2in18SLJ/iDTj2Th2S7JoCTJ94FeNhsAovs7GX6GdEyWKQd4BnyAjIlEYD8HIzHMkI8djONH9zxQ+lunJY7youomjw2ccAwcBG3GQH0KNCUJh5YTE/6CzPvJCf8FRs0CPIRS8SeIbbY2uy43KFlxtZc5Bx5AqSSe2xFKMPp+N7cXIJeaeGzOuC8cNCEEaXt5Rs/GkYz6Lj5/ihouinJ//adjRdow/5BGO29udMOTABITn+QOesCjUBqiG1hNqxICmkLj7gEMNfJitJ7esa6KCdmBJs8SMuWZyh8JNF7aIFdT+e8ngb6VBCUf0BiBS9NsMP2JU8H1VjTEOZuKDUsVHWf8/MikWuBYKafq1i0DDjsvz5DH4M2LX+w9ZCPpW47QbOUFBJ54fo4aHteHB1BvubZ5J3Snk149DhUvCvxrMlNVuar7595U4WHhBo0f2+WsNUp7KT727XLeXy3ByZHRHWd0MIC8VfX/id/FfMFNFcNQ2LYSI7fKKQ8SHUWs/hx1q8x0ANnQLj9qxOF4Zg8E16QZH2CYqyhQ9AdmybcVx24tRRrSlY6rikp/0mwxnw/tHvH+zdUX6p8xhPR/jYJeqdISdr9/Ft4gBBO9OcI1Xdk8m0r91obEhnQKjwnT82S2+BcrDG8y3p3KfEAqZMxEwkaRnVQ73tH7hFBtu07fyb4qHksGkK4Te0Q74vOO57iIcfwfUic8p8tNxu735ThR4fL2SBO7SnhYTlaZLAOq+lbpuUgYC3RkuJ HKLkf2Lu ZaLU4baYGoGF5OWHxUiWlmhWaR/ieZXeSnXPdMjpSiOBzqjQtksyrgoxzsk8Zi1wZWPz/uSwE8rv8E+cnIEp2KFB7yYfDoLNotd2qWZYSAK83JUfRRWMtQ2Cqw5psysnL922wENIBh8/OkTP4Zx6aeYGZ5FaO2cA4IesseE+wwS746KwfluCAOr5YUkiZCrKoOo2TwbJRsiJ5b4ZVbxTEj//s649xnHDCWRMYzeS+30CQw+wGKzU5KkGf/0NIf7PyFpbLRz9kCWt1CMKlRmggl1Eu0o4Y42GEMPmG4aupRAFaaFRGSjQRUKFCOMsEzG3n0ALsHBDeJ3hsx7kVvBr4ACpATwiSuz30+UiYSBTBY4sDjU+dHZJ8EUKhTvi+YXAUfJ2P4ZYpMDSWK26gUb8l66W0MQKrbyp1U0q3ZFgfEZCdDoCA2vYlb+qZsaI9T7dOBLaCTNkkmQ1Xfq28s3zfcperlozjv2iwzXyc8+GIyZX8+Bj+Gf4+f3ncheTP6PbL+ITJpY97AQC7i8o= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Darrick J. Wong" These functions aren't used anymore, so get rid of them. Signed-off-by: Darrick J. Wong Signed-off-by: Christoph Hellwig --- .../xfs/xfs-online-fsck-design.rst | 2 +- fs/xfs/scrub/trace.h | 2 - fs/xfs/scrub/xfile.c | 104 ------------------ fs/xfs/scrub/xfile.h | 20 ---- 4 files changed, 1 insertion(+), 127 deletions(-) diff --git a/Documentation/filesystems/xfs/xfs-online-fsck-design.rst b/Documentation/filesystems/xfs/xfs-online-fsck-design.rst index 324d5ec921e8e5..6d91b68dd23b71 100644 --- a/Documentation/filesystems/xfs/xfs-online-fsck-design.rst +++ b/Documentation/filesystems/xfs/xfs-online-fsck-design.rst @@ -1941,7 +1941,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 1c1db4ae1ba6ee..341d0b55ddfdfc 100644 --- a/fs/xfs/scrub/xfile.c +++ b/fs/xfs/scrub/xfile.c @@ -262,110 +262,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 */