From patchwork Thu Apr 25 11:37:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13643178 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 53545C19F4F for ; Thu, 25 Apr 2024 11:38:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C790F6B0083; Thu, 25 Apr 2024 07:38:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C28B36B0085; Thu, 25 Apr 2024 07:38:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC9776B0087; Thu, 25 Apr 2024 07:38:01 -0400 (EDT) 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 92D8D6B0083 for ; Thu, 25 Apr 2024 07:38:01 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 39611161149 for ; Thu, 25 Apr 2024 11:38:01 +0000 (UTC) X-FDA: 82047855162.03.F17FF15 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by imf06.hostedemail.com (Postfix) with ESMTP id 90360180024 for ; Thu, 25 Apr 2024 11:37:59 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=cQcJGDBL; spf=pass (imf06.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714045079; 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=fe/EkxT/4tbsQ0E/aktsfNPPVKoCmEm9S5NSTYBj3tk=; b=j91Y+5ZE3bk7HM4zo6XYWLDTIGLpyXJWSLok7vB01iY/k9PVHRjzs4XCyAhTzAj+2mgCQD mb1WzGx24d1bxXN4HB+nXGI28LhC+YO3hb8fgXHwjYJ1xbubCdYEQhUqHge5uxhNAwi7fJ d3ja15MFkZ+Tc1wVMyruuiDyDyTPvP4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714045079; a=rsa-sha256; cv=none; b=LqQcG4qxd/j2jrC1l/nz11AkWg11Ho+XnZA3OFlQPkxWt2T2FVgzyhu/SDP7aZ9U8NJHmP zfCOLrsukCg+eBokw1K7pxGI2XQ5upv654Q6a5e7dnAFpbuVZU0At8mpk15FcL+zP5e8xs 3MBzzpixTLGWbLQ8sDDe9poZnXDsTiw= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=cQcJGDBL; spf=pass (imf06.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4VQDPJ23mVz9sPv; Thu, 25 Apr 2024 13:37:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714045076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fe/EkxT/4tbsQ0E/aktsfNPPVKoCmEm9S5NSTYBj3tk=; b=cQcJGDBLAl1dtJxy2kvDsF3al40H5eNmF+KJhBHUl9EJFN42VOJQ+eT0kKwRT7JcFsKb93 X650sGma4M8zKkqAEZvRZSU/z8fEza1NcUiq8h6r+Lw2TlOS/Al7Uxk92R+ziwxPd8KTFr 8GwuqK1plMMpyev89NoAiITarFI/PiKOaT5bsa4J8u4QrCVuK/6Db1KadTwqtE7ZGCU69j SEkRtAo4DoUk3WNvBQgnHOsP+o/CSH7V/HAZ1szftyz1TLk8iQuaVgBdm524Lhsrr4fBuD hDmfrjD8Lai7/Ufz7ZtNtkaGft4Ejr4EMY/v2vMTfonhZKN0sPYlHF5tSw8ctg== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: [PATCH v4 01/11] readahead: rework loop in page_cache_ra_unbounded() Date: Thu, 25 Apr 2024 13:37:36 +0200 Message-Id: <20240425113746.335530-2-kernel@pankajraghav.com> In-Reply-To: <20240425113746.335530-1-kernel@pankajraghav.com> References: <20240425113746.335530-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 90360180024 X-Stat-Signature: pd61pqeprf1nxtkwj9u9n18of4yrtwqh X-HE-Tag: 1714045079-807621 X-HE-Meta: U2FsdGVkX18A+x6OJCefEGOPh+D1ES1VP/CXxTZCjrF9RQe0yCvRxWAb0WX59TrEJXgBTqXS5gByzjlmLcKQJeazzIUEHdI13S/2TePWgYonxranBaAReRFjArlASrxfKEPKxpImFyxv1AoOmakmrXrx4oC2irPpkI+/ZhUdroytvXN1/bAKXVMasQ1Wjlz3Pw9dPA/G6TcJKt1YQEa3G/3NiYq5qOAZ4WBwToPjU1o/NrokUtYQQ7oprIYNJWtA3LWbwekc23Nrr8OHaD5euMTHYtwR/FpFMqlKB4+ePml5fGZwCamHDjzA8PivyH/7YSLuVsUul0/+AiHTV1NKQJy6+MYP1ffdLaM3Y3SBUVww+81ajcOYndMIHQri0AW7S7oDjoZiaKLVreb2+tEByG3RS9Mx4+Tng6UDX9v3ed16wUjgFveqis4/kKdg5kDO+a4K6I9pzXcbOqU4CP71k8WwAsEvJdE3h0ajwCLw6VHABTc7sE8SkUVsIFmYnKUJTPMN3VgrRIPe/k4dtDSaBlO2ZOAauHdS0GAyOgA9XW3aBY2rHvk3i9fD7BlnCoCBPFnT89rcQq64qS1bsdH/7ITRIstL1ZHIgmnGsXuCxsRmBgbz99NNL6FE71AfRy1knrW1H3UY2bvztBF70HV547o6nwSDtUQMOYgSO+fOqEooD6PXUwelPy56V9+ftgMtmqxlBdg8TFch3SMFj7cZktjzu0GZicR8m/YWUmophv2qOHzE0c+M8WLU5t602/mw7WIJGUrUigw94qR+Z4zbFKc2oewNWgToMj/xT2N3ulEjSxui9+t2B9rx5qeK2bnwndnZPWjhbvwYIMQe2EOQo1KsEVp63bctbbJJ2xSPnnBvrW0oDhjiiDcJZWs4sfoinKen+sAEXtbhQcSLJHv0/nUnT6k08TYfdGAfbGKK/GcZ5UFquk6zdO8QFyAZMYkrhQSOqlc3ohWilWHtKyA ubWvbg+n k3RE9RQx0vRqnpJB194eZoYQ+WAJ6UwMZ11YCgkBuiswe1NrNvr+CnejeNoP65QHnkmUd2X+oNY2TjAh+9D90bb7xdAuAh+I5QwcPy64zU46PoZ/nZ216jAuytItxQhwnSBwgOMN3Y/qkfjz7r6DoEdd6wOCtAviPi8t337zMxndT/MaTVgaFCY4NJC9ul7rcvZEg35GavH4vg3wHCDRtuDpue1RynwUAtEcNDMCSkLS8mlBt+xULZHFU9oeoRNQA2TPyprKIlz2Ybybi3qQKFK/o/T/AZb1h/Y9ANOGNQrjOHpkbnCZdgufBaw== 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: Hannes Reinecke Rework the loop in page_cache_ra_unbounded() to advance with the number of pages in a folio instead of just one page at a time. Note that the index is incremented by 1 if filemap_add_folio() fails because the size of the folio we are trying to add is 1 (order 0). Signed-off-by: Hannes Reinecke Co-developed-by: Pankaj Raghav Signed-off-by: Pankaj Raghav Acked-by: Darrick J. Wong --- mm/readahead.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 130c0e7df99f..2361634a84fd 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -208,7 +208,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, struct address_space *mapping = ractl->mapping; unsigned long index = readahead_index(ractl); gfp_t gfp_mask = readahead_gfp_mask(mapping); - unsigned long i; + unsigned long i = 0; /* * Partway through the readahead operation, we will have added @@ -226,7 +226,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, /* * Preallocate as many pages as we will need. */ - for (i = 0; i < nr_to_read; i++) { + while (i < nr_to_read) { struct folio *folio = xa_load(&mapping->i_pages, index + i); if (folio && !xa_is_value(folio)) { @@ -239,8 +239,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, * not worth getting one just for that. */ read_pages(ractl); - ractl->_index++; - i = ractl->_index + ractl->_nr_pages - index - 1; + ractl->_index += folio_nr_pages(folio); + i = ractl->_index + ractl->_nr_pages - index; continue; } @@ -252,13 +252,14 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, folio_put(folio); read_pages(ractl); ractl->_index++; - i = ractl->_index + ractl->_nr_pages - index - 1; + i = ractl->_index + ractl->_nr_pages - index; continue; } if (i == nr_to_read - lookahead_size) folio_set_readahead(folio); ractl->_workingset |= folio_test_workingset(folio); - ractl->_nr_pages++; + ractl->_nr_pages += folio_nr_pages(folio); + i += folio_nr_pages(folio); } /* From patchwork Thu Apr 25 11:37:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13643179 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 B4CD8C4345F for ; Thu, 25 Apr 2024 11:38:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4172F6B0085; Thu, 25 Apr 2024 07:38:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39D0C6B0088; Thu, 25 Apr 2024 07:38:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 217586B008A; Thu, 25 Apr 2024 07:38:05 -0400 (EDT) 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 0583C6B0085 for ; Thu, 25 Apr 2024 07:38:04 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B89CF140240 for ; Thu, 25 Apr 2024 11:38:04 +0000 (UTC) X-FDA: 82047855288.07.54B9AD7 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by imf24.hostedemail.com (Postfix) with ESMTP id E8AFD180003 for ; Thu, 25 Apr 2024 11:38:02 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=pWAvZZwL; dmarc=pass (policy=quarantine) header.from=pankajraghav.com; spf=pass (imf24.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714045083; 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=jwJiip//T+O8iHQnA8gIdy4HYh6WY6jnyehEbs5RfBY=; b=mjz2qfDsJnI33wEPImkTVUixzxFF+ogJmPWmIU+lrs1PpvVMnRF5dK+HVLo6Rs/y1ct5pt kXVfkuytyyWyb3Tl24VkmhfMami+/T1qmV4ssgPPzUPAcKNWuj5NqwNDH0j8Wr+A0d5JzR xngb/ZNqElhabT9Kfsw4KWqwne5Ph18= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=pWAvZZwL; dmarc=pass (policy=quarantine) header.from=pankajraghav.com; spf=pass (imf24.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714045083; a=rsa-sha256; cv=none; b=alpGn192r+eMo1/5ExhXW+AFsHR1FxtgA7K7466PkH9MF2PelhHmY+MGOC1YUjhgtYF7NZ hxwHYlF02orMaOoltZqrqxk5Qt/NRmj4m8dMKeAG9/tZo/IlWPHSN337e1mJqLzMQTHrhc xOPa96GVorvZYn7vnpcnzgBqpRXMda4= Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4VQDPM5z88z9sqH; Thu, 25 Apr 2024 13:37:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714045079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jwJiip//T+O8iHQnA8gIdy4HYh6WY6jnyehEbs5RfBY=; b=pWAvZZwLeRk248TadAtN1GDZWGqpWPg8DxfyFHbfGEdom2wHzQIoOrmK+RQpww2eBjxVN/ NlABjkXV9Gjpd+TpwlZSMoEAu05F6/Mw4VOD8OXl16gp7AVgZDmbn+3JirgO4gTNK7Qe97 at1vhk5t49j7z4wFdFwJ/Dldj6xrKudEaXOAuO4oLHfIb9yVzFAL0V+XZQJgUZJ9H6r0qy FxHC6gBCJyRluZh7j4XHD5DtA2ibCeDlVPUZUmymb4Uc4Trh/a0cO91qysuPW5S6GYYYdF XWAd/YEqQ4QNgruuoeC/0NDR0mnB2XMeaVxFPNnWkok5yOpWkSpxnlMjW1Xs5A== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: [PATCH v4 02/11] fs: Allow fine-grained control of folio sizes Date: Thu, 25 Apr 2024 13:37:37 +0200 Message-Id: <20240425113746.335530-3-kernel@pankajraghav.com> In-Reply-To: <20240425113746.335530-1-kernel@pankajraghav.com> References: <20240425113746.335530-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E8AFD180003 X-Stat-Signature: 6swhhju6yz8wcwaakz81o8ss4mi5oth1 X-HE-Tag: 1714045082-707404 X-HE-Meta: U2FsdGVkX18XE04UZaEmpys9e7bYEmrU+LmM0l5SfVUUhm86kXx2G8LH0tBtn9LQ49DYA2EeSBcQDi5Z0LwUQQV5tgNlqqcb+jjq+0pzQxDr1NC61Uhx95Bz+WVy7gBOIXcRnUcsGHlrL9iKNVZfBP7Ae/QXb0n1cmltI1OMeN3YjeAAmq2o61zhWzBwehxIaCz2D6jAFhSkMxyYJLhXVvLbqMVLoSkf03Ln93bRkXieitUp25oe280aGOMC+SyJNOcn2hS50TnbOEEBSoKwgS5PCZLaWUY+KpY2hNaIb8XI65C6v5GcUMaKuAbJwfWSkB9Alrnv/c3//kubUHTWIVCwW7ZMr5wtfugMVj/4wLEJLMqaTEqERCyP9qUwBNpa4fFWuGfAwcb7+PxqV75R6wLYxHUFetmC/IltChhxcIDVvbTJByZ6L0eWTdn2FC3XCC6wMrQ74cC8y+ndQ6JTceL4N+7gWxGHZkvWOhTa2+fdRDObbKLZ/mg0Cp1Q/WGL0uEVy0YKoMV4JeKNBjVWxnlZf1BuBLrg9MmOkUla49jsDHbDC6LgCYq2oXH97PCgFSZumHhuWQWNtfGJKzLEIENN4JQgQ6dDibK6ZpIgJ3e9H5OXpZMy7P0cLJfucY4Z9JuRsYlMeo+XYYv7nmcwxblruxDc4NWeOv7dwFBsYLLN2nF/D0ez7Kfg5jUzR6uegiN1Twl/lCr6x7KSYrrLY+kNFWqkhfa8rvSZOFdxokACrerMXO/IopM9dQLXopXELIMVRUF8Xdx2bTBFY1/ziYquyneYeNlmIAqky2b7PpfJ9QN1F+merb6sxAVbw1eeTw0+XF2cclRiLNVsw9Vq3l/yAIQj/7+66L5wp9MauvznHzMaQKLryQzaAVaxYe+14FkYkcicoESmN3YleLD+SohOQi+EczgnXxGi2eaaRX9VvGGOCuPJsz/D41gDMQ4wD7VO9+rzDS0HOBFRnlQ MZgPpAJl 0sFQoIrCW0LKyJZFLv5LOMv8UNPTG4Jn3dh12EWcMlz0P0e/NiUG0E4SwwpaSfEnNmywkWADhMux3ibs2wGjeVgmaIqklAiNgBjCWsYaHEG8sC0UGpOBIjzoJqHu8OHXR0RDD2QdEhcqmSTlC0n3F0bjveaKAJJiHSQ6GjX2yNuLidijqrkcm5ZB8qYdHh+IJZ6Tau/zpSmi84kvKP+PXnGqJOkOvDO8y1lYW9cEHEa5Vlapdm6KWRtmclocJHD7D1ip8SmbPfMSmq/NHawo/O1u+Q394U8TYrCBdp+EBYy95JNdSn92ZdmsBdQ== 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: "Matthew Wilcox (Oracle)" Some filesystems want to be able to ensure that folios that are added to the page cache are at least a certain size. Add mapping_set_folio_min_order() to allow this level of control. Signed-off-by: Matthew Wilcox (Oracle) Co-developed-by: Pankaj Raghav Signed-off-by: Pankaj Raghav Signed-off-by: Luis Chamberlain Reviewed-by: Hannes Reinecke Reviewed-by: Darrick J. Wong --- include/linux/pagemap.h | 116 +++++++++++++++++++++++++++++++++------- 1 file changed, 96 insertions(+), 20 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 2df35e65557d..2e5612de1749 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -202,13 +202,18 @@ enum mapping_flags { AS_EXITING = 4, /* final truncate in progress */ /* writeback related tags are not used */ AS_NO_WRITEBACK_TAGS = 5, - AS_LARGE_FOLIO_SUPPORT = 6, - AS_RELEASE_ALWAYS, /* Call ->release_folio(), even if no private data */ - AS_STABLE_WRITES, /* must wait for writeback before modifying + AS_RELEASE_ALWAYS = 6, /* Call ->release_folio(), even if no private data */ + AS_STABLE_WRITES = 7, /* must wait for writeback before modifying folio contents */ - AS_UNMOVABLE, /* The mapping cannot be moved, ever */ + AS_FOLIO_ORDER_MIN = 8, + AS_FOLIO_ORDER_MAX = 13, /* Bit 8-17 are used for FOLIO_ORDER */ + AS_UNMOVABLE = 18, /* The mapping cannot be moved, ever */ }; +#define AS_FOLIO_ORDER_MIN_MASK 0x00001f00 +#define AS_FOLIO_ORDER_MAX_MASK 0x0003e000 +#define AS_FOLIO_ORDER_MASK (AS_FOLIO_ORDER_MIN_MASK | AS_FOLIO_ORDER_MAX_MASK) + /** * mapping_set_error - record a writeback error in the address_space * @mapping: the mapping in which an error should be set @@ -344,9 +349,63 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) m->gfp_mask = mask; } +/* + * There are some parts of the kernel which assume that PMD entries + * are exactly HPAGE_PMD_ORDER. Those should be fixed, but until then, + * limit the maximum allocation order to PMD size. I'm not aware of any + * assumptions about maximum order if THP are disabled, but 8 seems like + * a good order (that's 1MB if you're using 4kB pages) + */ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#define MAX_PAGECACHE_ORDER HPAGE_PMD_ORDER +#else +#define MAX_PAGECACHE_ORDER 8 +#endif + +/* + * mapping_set_folio_order_range() - Set the folio order range + * @mapping: The address_space. + * @min: Minimum folio order (between 0-MAX_PAGECACHE_ORDER inclusive). + * @max: Maximum folio order (between @min-MAX_PAGECACHE_ORDER inclusive). + * + * The filesystem should call this function in its inode constructor to + * indicate which base size (min) and maximum size (max) of folio the VFS + * can use to cache the contents of the file. This should only be used + * if the filesystem needs special handling of folio sizes (ie there is + * something the core cannot know). + * Do not tune it based on, eg, i_size. + * + * Context: This should not be called while the inode is active as it + * is non-atomic. + */ +static inline void mapping_set_folio_order_range(struct address_space *mapping, + unsigned int min_order, + unsigned int max_order) +{ + if (min_order > MAX_PAGECACHE_ORDER) + min_order = MAX_PAGECACHE_ORDER; + + if (max_order > MAX_PAGECACHE_ORDER) + max_order = MAX_PAGECACHE_ORDER; + + max_order = max(max_order, min_order); + /* + * TODO: max_order is not yet supported in filemap. + */ + mapping->flags = (mapping->flags & ~AS_FOLIO_ORDER_MASK) | + (min_order << AS_FOLIO_ORDER_MIN) | + (max_order << AS_FOLIO_ORDER_MAX); +} + +static inline void mapping_set_folio_min_order(struct address_space *mapping, + unsigned int min) +{ + mapping_set_folio_order_range(mapping, min, MAX_PAGECACHE_ORDER); +} + /** * mapping_set_large_folios() - Indicate the file supports large folios. - * @mapping: The file. + * @mapping: The address_space. * * The filesystem should call this function in its inode constructor to * indicate that the VFS can use large folios to cache the contents of @@ -357,7 +416,37 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) */ static inline void mapping_set_large_folios(struct address_space *mapping) { - __set_bit(AS_LARGE_FOLIO_SUPPORT, &mapping->flags); + mapping_set_folio_order_range(mapping, 0, MAX_PAGECACHE_ORDER); +} + +static inline unsigned int mapping_max_folio_order(struct address_space *mapping) +{ + return (mapping->flags & AS_FOLIO_ORDER_MAX_MASK) >> AS_FOLIO_ORDER_MAX; +} + +static inline unsigned int mapping_min_folio_order(struct address_space *mapping) +{ + return (mapping->flags & AS_FOLIO_ORDER_MIN_MASK) >> AS_FOLIO_ORDER_MIN; +} + +static inline unsigned long mapping_min_folio_nrpages(struct address_space *mapping) +{ + return 1UL << mapping_min_folio_order(mapping); +} + +/** + * mapping_align_start_index() - Align starting index based on the min + * folio order of the page cache. + * @mapping: The address_space. + * + * Ensure the index used is aligned to the minimum folio order when adding + * new folios to the page cache by rounding down to the nearest minimum + * folio number of pages. + */ +static inline pgoff_t mapping_align_start_index(struct address_space *mapping, + pgoff_t index) +{ + return round_down(index, mapping_min_folio_nrpages(mapping)); } /* @@ -367,7 +456,7 @@ static inline void mapping_set_large_folios(struct address_space *mapping) static inline bool mapping_large_folio_support(struct address_space *mapping) { return IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && - test_bit(AS_LARGE_FOLIO_SUPPORT, &mapping->flags); + (mapping_max_folio_order(mapping) > 0); } static inline int filemap_nr_thps(struct address_space *mapping) @@ -528,19 +617,6 @@ static inline void *detach_page_private(struct page *page) return folio_detach_private(page_folio(page)); } -/* - * There are some parts of the kernel which assume that PMD entries - * are exactly HPAGE_PMD_ORDER. Those should be fixed, but until then, - * limit the maximum allocation order to PMD size. I'm not aware of any - * assumptions about maximum order if THP are disabled, but 8 seems like - * a good order (that's 1MB if you're using 4kB pages) - */ -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#define MAX_PAGECACHE_ORDER HPAGE_PMD_ORDER -#else -#define MAX_PAGECACHE_ORDER 8 -#endif - #ifdef CONFIG_NUMA struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order); #else From patchwork Thu Apr 25 11:37:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13643180 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 105F7C41513 for ; Thu, 25 Apr 2024 11:38:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BFB76B008C; Thu, 25 Apr 2024 07:38:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76F996B0092; Thu, 25 Apr 2024 07:38:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6191A6B0093; Thu, 25 Apr 2024 07:38:09 -0400 (EDT) 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 3F8966B008C for ; Thu, 25 Apr 2024 07:38:09 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 536B3C110B for ; Thu, 25 Apr 2024 11:38:08 +0000 (UTC) X-FDA: 82047855456.27.0802BC7 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf12.hostedemail.com (Postfix) with ESMTP id 8215440020 for ; Thu, 25 Apr 2024 11:38:06 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=IbZsSndT; spf=pass (imf12.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714045086; 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=T9CNQJJ+RDd4FbmtOqOiANGvF7RbcOwG9CdTM2mS7kM=; b=4/LOTd3xg+j2SASGckN8FVpcLYmkOLkQOaRc4jUsSw3m+eVeAobAaVLPnCaGgxNDq91/jE YiLr+S4Yrj3wCs+FhSQLxWE558X1l5rLsoiA4IlC7LyUx7+FziVcaNXylGmq22ZtcXj+GO qHJ8L4Q8dyqgdz8NNxaVXY7di7iihbY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714045086; a=rsa-sha256; cv=none; b=1dMxmAfirzmJe2Igh222e5w7G2QfstW9LXfnhLxY0gvBqqsgNAIDPQq4lwpOS5iLDogO2U sj1L6pdRQyL9sg1EBeuvvfLNw19Ixk2o2NZfbjW/nsOGnYCLqjXfrsPUNSP045B1/BVczh Knf//L1UlRrhW4FVvDBmaCryveYpDeg= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=IbZsSndT; spf=pass (imf12.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4VQDPQ5Ddmz9sq8; Thu, 25 Apr 2024 13:38:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714045082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T9CNQJJ+RDd4FbmtOqOiANGvF7RbcOwG9CdTM2mS7kM=; b=IbZsSndTyjSN9Xvee5cogqDuOzoH7J5rrFIQ6UKdtFgvT8kfUaS4NCsKR6pdUflcFhY+IL rdR3OapoPksLXIHK3tNiyZpOyqiEqtWGnbaswUp+WAiMm1rFPbaE5zURR9DfVAMKc++bDw 4o57Fmk7KHpUiaO2T2bLAqVgmEzDdPoI8pL2hJvt5q/tGrx7uunvyav8xgHW4Vg4WuF/e0 qTjTR04yN8FJACQx/f2zQahXWeVheOqgl5as1hKzkWgJEk7b07HGDk5I35ENUwaKwIW5fK 3jrQnR4geUlY588+NJV3eRUG/y67FNc5roYN3PobZqp1uroWXTQQySDk+MEHyA== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: [PATCH v4 03/11] filemap: allocate mapping_min_order folios in the page cache Date: Thu, 25 Apr 2024 13:37:38 +0200 Message-Id: <20240425113746.335530-4-kernel@pankajraghav.com> In-Reply-To: <20240425113746.335530-1-kernel@pankajraghav.com> References: <20240425113746.335530-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8215440020 X-Rspam-User: X-Stat-Signature: heopefeph1kksu3dihg9yhddcmy4gn84 X-HE-Tag: 1714045086-456603 X-HE-Meta: U2FsdGVkX1/UAq3YvZuH2dsizh4Ws7DZSxamAPiUvsJYUzTLzYYkgFRp8hMAd9Biq2DaJPIx4k2sPjK6M8ZvL13/K2MYTA1KYiwGITnT+XIK4/GeSMf+NksoS73gp+CeHiknVaUOlr/uFirkQCYgrLcQPLJd1ZgS//8l9+5yC0N1oL5Z9o2WVrUyIao1tR3LRNJw5jRVL8x5X0YdfD99n07f7kgC5lTh4qcnN2Inl2UR/aqFtZmm3seIimu8F9M/dxlOzWcOuwKvYhAoM1WB3FKg4DYsOkRdmY2cHPAjV4ptKxYYQnErvQzvNMzPi8ErzfoLi/p+ok79QYrmZcS/OCg9bQL9Azwin7VqIuWbjSh8S9YLhy3VO92Q/+c8nJ0AI+bNAOhbMR744dI+PL4s+437IqGIWeVFXDTyiEYKI9buMjm8PrvsxJih8mJYnpzxC4LitUeUD8DtLmOT9KNR80FFXR8nWY8rPlD/OtAVa9ONR6k+yozQRNiky2BCoeft0hhlb3zFbJ5vGfTjbYDMW6PZic6ofn6tOGsWLOJSbbxzvtvXT2ITyvuESRKtCM7YNpT8zCJ/JHfXDbYYLA21iW4fgHXakQlcj8+m7yuigq2rIkB+s8iymZi92lWnpxuBWk9JdmjRashVONNSeZB5hffNaWCZfKQJ95/KFuUX1Si2qjcSk0rGHXBjgjgt5uQCUrzuRdfW0AZvaFMNIauxAzQ9Wn4rBFKD7bzbV6+o9fyUe19oW984M15OHKor2+rNlHUct+KdT/lG5+EDTtKzJ15/BbBBdbXAF/8xp1DQ8aeqUW0uSUg9FJpeR2QimFdMG5accWdIesD6eaLprIafMJS/6zAlCNKJP8InyFfpb01++K7vDJeKRxylDDJugQW6bCt78b8RYYB3sjuPjoxXulO6oXKHleRlmXOEZVo6E8scnJUyap1q5xE4wNPGxHN1kI0LzWZqIFjxw+fVrZp rB+1ljSh VC4x7C++Ez4RNNVeg2mJ+safm9QnJdGCbUtFWMnl/95YyL3nnYJB+xm4wPXkW+L6Wz0Moyn8lmBolwf4kLbQ1dLpZEStio7TL4jFKHDlMXgS3Bj4bpOLjNKpdQD+tIYkj5hI/hR73SLSxs2n7kgqd2OQoFcBud4fHJsp/n/j5/P1PL9eYqVNsUin0pumwhdSSJ4d8ct9geYvd3J8pM4zTHvXQhBdWDdKgy+xIyqye0unUO2P9A7Z9/eEvZshoQcm5wNwRf0gtPp+FJY7nQTZuBYXokSg6pDVjfVi7rFeuSHEYcM/oNEHycNA4tg== 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: Luis Chamberlain filemap_create_folio() and do_read_cache_folio() were always allocating folio of order 0. __filemap_get_folio was trying to allocate higher order folios when fgp_flags had higher order hint set but it will default to order 0 folio if higher order memory allocation fails. Supporting mapping_min_order implies that we guarantee each folio in the page cache has at least an order of mapping_min_order. When adding new folios to the page cache we must also ensure the index used is aligned to the mapping_min_order as the page cache requires the index to be aligned to the order of the folio. Signed-off-by: Luis Chamberlain Co-developed-by: Pankaj Raghav Signed-off-by: Pankaj Raghav Reviewed-by: Hannes Reinecke Reviewed-by: Darrick J. Wong --- mm/filemap.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 30de18c4fd28..f0c0cfbbd134 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -858,6 +858,8 @@ noinline int __filemap_add_folio(struct address_space *mapping, VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); VM_BUG_ON_FOLIO(folio_test_swapbacked(folio), folio); + VM_BUG_ON_FOLIO(folio_order(folio) < mapping_min_folio_order(mapping), + folio); mapping_set_update(&xas, mapping); if (!huge) { @@ -1895,8 +1897,10 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, folio_wait_stable(folio); no_page: if (!folio && (fgp_flags & FGP_CREAT)) { - unsigned order = FGF_GET_ORDER(fgp_flags); + unsigned int min_order = mapping_min_folio_order(mapping); + unsigned int order = max(min_order, FGF_GET_ORDER(fgp_flags)); int err; + index = mapping_align_start_index(mapping, index); if ((fgp_flags & FGP_WRITE) && mapping_can_writeback(mapping)) gfp |= __GFP_WRITE; @@ -1936,7 +1940,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, break; folio_put(folio); folio = NULL; - } while (order-- > 0); + } while (order-- > min_order); if (err == -EEXIST) goto repeat; @@ -2425,13 +2429,16 @@ static int filemap_update_page(struct kiocb *iocb, } static int filemap_create_folio(struct file *file, - struct address_space *mapping, pgoff_t index, + struct address_space *mapping, loff_t pos, struct folio_batch *fbatch) { struct folio *folio; int error; + unsigned int min_order = mapping_min_folio_order(mapping); + pgoff_t index; - folio = filemap_alloc_folio(mapping_gfp_mask(mapping), 0); + folio = filemap_alloc_folio(mapping_gfp_mask(mapping), + min_order); if (!folio) return -ENOMEM; @@ -2449,6 +2456,8 @@ static int filemap_create_folio(struct file *file, * well to keep locking rules simple. */ filemap_invalidate_lock_shared(mapping); + /* index in PAGE units but aligned to min_order number of pages. */ + index = (pos >> (PAGE_SHIFT + min_order)) << min_order; error = filemap_add_folio(mapping, folio, index, mapping_gfp_constraint(mapping, GFP_KERNEL)); if (error == -EEXIST) @@ -2509,8 +2518,7 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, if (!folio_batch_count(fbatch)) { if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) return -EAGAIN; - err = filemap_create_folio(filp, mapping, - iocb->ki_pos >> PAGE_SHIFT, fbatch); + err = filemap_create_folio(filp, mapping, iocb->ki_pos, fbatch); if (err == AOP_TRUNCATED_PAGE) goto retry; return err; @@ -3708,9 +3716,11 @@ static struct folio *do_read_cache_folio(struct address_space *mapping, repeat: folio = filemap_get_folio(mapping, index); if (IS_ERR(folio)) { - folio = filemap_alloc_folio(gfp, 0); + folio = filemap_alloc_folio(gfp, + mapping_min_folio_order(mapping)); if (!folio) return ERR_PTR(-ENOMEM); + index = mapping_align_start_index(mapping, index); err = filemap_add_folio(mapping, folio, index, gfp); if (unlikely(err)) { folio_put(folio); From patchwork Thu Apr 25 11:37:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13643181 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 8D4D7C4345F for ; Thu, 25 Apr 2024 11:38:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B2396B0092; Thu, 25 Apr 2024 07:38:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12CC76B0095; Thu, 25 Apr 2024 07:38:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0271A6B0092; Thu, 25 Apr 2024 07:38:12 -0400 (EDT) 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 D4EE96B0092 for ; Thu, 25 Apr 2024 07:38:12 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8AC28161274 for ; Thu, 25 Apr 2024 11:38:11 +0000 (UTC) X-FDA: 82047855582.05.19560BC Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf02.hostedemail.com (Postfix) with ESMTP id C317280008 for ; Thu, 25 Apr 2024 11:38:09 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=fj653PzC; spf=pass (imf02.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714045090; a=rsa-sha256; cv=none; b=acoqyZFcygYuzktDW6FO4syxWA2MGMTvQcmk2fmdKtL+hD93heedZCiHHC1vgzWm8oUmgx K0ZdnZI8KaD3gmGcsF2bWdk4dJU9s5Ci4adO9l5sm1i+xCToOFiJNCkUsaVJHLQMqPj4Wm lZ3oBTOulfu5otPCRpJaDaf1Dm7RjSE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=fj653PzC; spf=pass (imf02.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714045090; 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=LAt6S24Vjnx4CNZrkFkZzKX+VLk83S8Eni5970rjRTI=; b=reiqjI1ZMTBg2n5SqDRY5NFkPWIP7EqZoPrctdIhNm8S2XD7Z6q2jIXgs7Xvqdz3NSpeQq wGwQZgoSHoApXf//Uq3KReyLUjS/Hr3EmXv+Iyh0xgCy77FSBI486oZ6FyoW6YFI6PIhQG VqF7rL4UTzzFoU21c4W4Lmu1d9eBBLo= Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4VQDPV4k9xz9stY; Thu, 25 Apr 2024 13:38:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714045086; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LAt6S24Vjnx4CNZrkFkZzKX+VLk83S8Eni5970rjRTI=; b=fj653PzCK3e+p9Gi6sS7fVwaC7HJREI+ZN7gDJ8DRp9GQn4/iRpUudp5IQ089pQcYJxbz1 /EDDC9NEgIhX4pJKl/ADI6wPB9avUNHefq7wQXCJ9yT/RlO7eAjBoTreh+PB0qjrpKKZN7 Kza+MpB2PJDkPo92dEM/1ObNcT2ZPWI3utuH1dYkToN/RrciSCPpWGNsu6D2hNbtvn0oV8 5PUcrDOmGnzm9Gzb6T79Z/FKgYLW0dLx1qET3cD9aCqt4l+O66qvBSEvKLIor7Qe2t3Yvz jK3OfPI3H9Uf+NKG0Rtt0XNtzzIDTgwBCe3M98OHPaeeWPPV6hVHPVKjoO3tsA== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: [PATCH v4 04/11] readahead: allocate folios with mapping_min_order in readahead Date: Thu, 25 Apr 2024 13:37:39 +0200 Message-Id: <20240425113746.335530-5-kernel@pankajraghav.com> In-Reply-To: <20240425113746.335530-1-kernel@pankajraghav.com> References: <20240425113746.335530-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C317280008 X-Stat-Signature: 7wxcoq8f7zx6j9kz8j3c7xoxpas4ipi4 X-Rspam-User: X-HE-Tag: 1714045089-382782 X-HE-Meta: U2FsdGVkX1/xI+CCINpjyViz9loRJgvwFMb9rKQOff8sMVDEp7hTaYgHsgPVleeGejgIhm3h+8ZZBNLMK2+TPLU8csBaPLN3beoGYhCfBrdvR6UKsAkaAtOVNlzMkBRGvMTqD2MZ/sukEsKI+oUgwDJxv6EU1e7A6D/47VF6Lfag3uoKaKP9/EpTH+/rFlb1apL1qAAXafjto7WmtyZMqJycb0uRS60NvCX1KhiMDzyuPh4BxfZ5sqhk12Y25TZxrwMJDxmFqbrBZip5JzcgN+KvluySeinRhhAgz7WckHiCLPvR7E4pNYCKeSyMVjj9AsLnYn0DwTQ3Y9JACpqskI0kS0IGKkvANqaiG0NLGPrsHfvD/on9o62qnG9RQOZMLRPBK2br/HG0ppu6ZiDlTHcZBOsema9+7qIeLB6XW/XepWHolS1Thh70pY/Z0GMfNORTD+klk+9FeToLNsFr1ix3dPSCMEGZ2PKtDGGu9ahQnWQbZ9lAq1uyH2uK2biwmaKZRVM/NYvIQmBW5+9Mb8jA361OrZsruGbpj/asa0bgiMLOr3BJm44aqoXbJsyBuGKeOciKUkW8p7tehBXNfv+t/PPsf/WjZ7NHiZLCXN1ebYQBeTjvE7c/XiRQcXhnvh/sctuzBPJrr15BECXfRCZzwGV6RPy2rVPOSmB/+BsN9otbXO9b/axsWrAAwXsBG0PZ2DstwMiObZ32hGh5KKEMqcHN2J1MEmp52/k8fFyB70prbOzU+EdPlFfLaKqZPkSj3yFO9xDqksQcwTJMqrOcTM2c3EeZ1i3slVz7QNqGOhRbGN3C0F4lApChNZVLnxoW9Cvvw55QggpYSEE4WYbAxxf4LZZ8143y+U7CA6u4DlVkVliPW6rnbbHlnbj1YbRBp0P/R7qhllyULKuZOVBlQRLCcIJBZ3o3amEb+ZnV3c9AD/EHP6WJBzKCxz6w38xozu13Di2PNipKSGL L2DX1+3x 133ae/0qT3+thyk9qCzs1/l2CIAYvxYC/XIrc+1Ep3Q/ZQV+9qTwcndlnOsFSIq6UfL2XwqF1Ze3Iy/e/jk1XCY76g/4kTHiGJKTYBJ1eRhtFN1+ND98ffHGOr1cwiy7z2A3SvioENH9hB3We06QzCop8j7q+SXH5r2LdxsxRVdWvdfeHS1Ijq3xbMs72AnYq3NQA4pSLtYVXO9qCPzBzqYWI3PDa/ZrQS3YVKq+wlb0QRY9/WFLwQ2XGMjLZgRBzno4IdDIHd0Xd//4= 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: Pankaj Raghav page_cache_ra_unbounded() was allocating single pages (0 order folios) if there was no folio found in an index. Allocate mapping_min_order folios as we need to guarantee the minimum order if it is set. When read_pages() is triggered and if a page is already present, check for truncation and move the ractl->_index by mapping_min_nrpages if that folio was truncated. This is done to ensure we keep the alignment requirement while adding a folio to the page cache. page_cache_ra_order() tries to allocate folio to the page cache with a higher order if the index aligns with that order. Modify it so that the order does not go below the mapping_min_order requirement of the page cache. This function will do the right thing even if the new_order passed is less than the mapping_min_order. When adding new folios to the page cache we must also ensure the index used is aligned to the mapping_min_order as the page cache requires the index to be aligned to the order of the folio. readahead_expand() is called from readahead aops to extend the range of the readahead so this function can assume ractl->_index to be aligned with min_order. Signed-off-by: Pankaj Raghav --- mm/readahead.c | 85 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 14 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 2361634a84fd..9c193185a836 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -206,9 +206,10 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, unsigned long nr_to_read, unsigned long lookahead_size) { struct address_space *mapping = ractl->mapping; - unsigned long index = readahead_index(ractl); + unsigned long index = readahead_index(ractl), ra_folio_index; gfp_t gfp_mask = readahead_gfp_mask(mapping); - unsigned long i = 0; + unsigned long i = 0, mark; + unsigned int min_nrpages = mapping_min_folio_nrpages(mapping); /* * Partway through the readahead operation, we will have added @@ -223,6 +224,22 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, unsigned int nofs = memalloc_nofs_save(); filemap_invalidate_lock_shared(mapping); + index = mapping_align_start_index(mapping, index); + + /* + * As iterator `i` is aligned to min_nrpages, round_up the + * difference between nr_to_read and lookahead_size to mark the + * index that only has lookahead or "async_region" to set the + * readahead flag. + */ + ra_folio_index = round_up(readahead_index(ractl) + nr_to_read - lookahead_size, + min_nrpages); + mark = ra_folio_index - index; + if (index != readahead_index(ractl)) { + nr_to_read += readahead_index(ractl) - index; + ractl->_index = index; + } + /* * Preallocate as many pages as we will need. */ @@ -230,6 +247,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, struct folio *folio = xa_load(&mapping->i_pages, index + i); if (folio && !xa_is_value(folio)) { + long nr_pages = folio_nr_pages(folio); + /* * Page already present? Kick off the current batch * of contiguous pages before continuing with the @@ -239,23 +258,35 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, * not worth getting one just for that. */ read_pages(ractl); - ractl->_index += folio_nr_pages(folio); + + /* + * Move the ractl->_index by at least min_pages + * if the folio got truncated to respect the + * alignment constraint in the page cache. + * + */ + if (mapping != folio->mapping) + nr_pages = min_nrpages; + + VM_BUG_ON_FOLIO(nr_pages < min_nrpages, folio); + ractl->_index += nr_pages; i = ractl->_index + ractl->_nr_pages - index; continue; } - folio = filemap_alloc_folio(gfp_mask, 0); + folio = filemap_alloc_folio(gfp_mask, + mapping_min_folio_order(mapping)); if (!folio) break; if (filemap_add_folio(mapping, folio, index + i, gfp_mask) < 0) { folio_put(folio); read_pages(ractl); - ractl->_index++; + ractl->_index += min_nrpages; i = ractl->_index + ractl->_nr_pages - index; continue; } - if (i == nr_to_read - lookahead_size) + if (i == mark) folio_set_readahead(folio); ractl->_workingset |= folio_test_workingset(folio); ractl->_nr_pages += folio_nr_pages(folio); @@ -489,12 +520,18 @@ void page_cache_ra_order(struct readahead_control *ractl, { struct address_space *mapping = ractl->mapping; pgoff_t index = readahead_index(ractl); + unsigned int min_order = mapping_min_folio_order(mapping); pgoff_t limit = (i_size_read(mapping->host) - 1) >> PAGE_SHIFT; pgoff_t mark = index + ra->size - ra->async_size; int err = 0; gfp_t gfp = readahead_gfp_mask(mapping); + unsigned int min_ra_size = max(4, mapping_min_folio_nrpages(mapping)); - if (!mapping_large_folio_support(mapping) || ra->size < 4) + /* + * Fallback when size < min_nrpages as each folio should be + * at least min_nrpages anyway. + */ + if (!mapping_large_folio_support(mapping) || ra->size < min_ra_size) goto fallback; limit = min(limit, index + ra->size - 1); @@ -503,9 +540,18 @@ void page_cache_ra_order(struct readahead_control *ractl, new_order += 2; new_order = min_t(unsigned int, MAX_PAGECACHE_ORDER, new_order); new_order = min_t(unsigned int, new_order, ilog2(ra->size)); + new_order = max(new_order, min_order); } filemap_invalidate_lock_shared(mapping); + /* + * If the new_order is greater than min_order and index is + * already aligned to new_order, then this will be noop as index + * aligned to new_order should also be aligned to min_order. + */ + ractl->_index = mapping_align_start_index(mapping, index); + index = readahead_index(ractl); + while (index <= limit) { unsigned int order = new_order; @@ -513,7 +559,7 @@ void page_cache_ra_order(struct readahead_control *ractl, if (index & ((1UL << order) - 1)) order = __ffs(index); /* Don't allocate pages past EOF */ - while (index + (1UL << order) - 1 > limit) + while (order > min_order && index + (1UL << order) - 1 > limit) order--; err = ra_alloc_folio(ractl, index, mark, order, gfp); if (err) @@ -776,8 +822,15 @@ void readahead_expand(struct readahead_control *ractl, struct file_ra_state *ra = ractl->ra; pgoff_t new_index, new_nr_pages; gfp_t gfp_mask = readahead_gfp_mask(mapping); + unsigned long min_nrpages = mapping_min_folio_nrpages(mapping); + unsigned int min_order = mapping_min_folio_order(mapping); new_index = new_start / PAGE_SIZE; + /* + * Readahead code should have aligned the ractl->_index to + * min_nrpages before calling readahead aops. + */ + VM_BUG_ON(!IS_ALIGNED(ractl->_index, min_nrpages)); /* Expand the leading edge downwards */ while (ractl->_index > new_index) { @@ -787,9 +840,11 @@ void readahead_expand(struct readahead_control *ractl, if (folio && !xa_is_value(folio)) return; /* Folio apparently present */ - folio = filemap_alloc_folio(gfp_mask, 0); + folio = filemap_alloc_folio(gfp_mask, min_order); if (!folio) return; + + index = mapping_align_start_index(mapping, index); if (filemap_add_folio(mapping, folio, index, gfp_mask) < 0) { folio_put(folio); return; @@ -799,7 +854,7 @@ void readahead_expand(struct readahead_control *ractl, ractl->_workingset = true; psi_memstall_enter(&ractl->_pflags); } - ractl->_nr_pages++; + ractl->_nr_pages += min_nrpages; ractl->_index = folio->index; } @@ -814,9 +869,11 @@ void readahead_expand(struct readahead_control *ractl, if (folio && !xa_is_value(folio)) return; /* Folio apparently present */ - folio = filemap_alloc_folio(gfp_mask, 0); + folio = filemap_alloc_folio(gfp_mask, min_order); if (!folio) return; + + index = mapping_align_start_index(mapping, index); if (filemap_add_folio(mapping, folio, index, gfp_mask) < 0) { folio_put(folio); return; @@ -826,10 +883,10 @@ void readahead_expand(struct readahead_control *ractl, ractl->_workingset = true; psi_memstall_enter(&ractl->_pflags); } - ractl->_nr_pages++; + ractl->_nr_pages += min_nrpages; if (ra) { - ra->size++; - ra->async_size++; + ra->size += min_nrpages; + ra->async_size += min_nrpages; } } } From patchwork Thu Apr 25 11:37:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13643182 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 964BAC4345F for ; Thu, 25 Apr 2024 11:38:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2688D6B0096; Thu, 25 Apr 2024 07:38:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F09D6B0098; Thu, 25 Apr 2024 07:38:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0942E6B0099; Thu, 25 Apr 2024 07:38:18 -0400 (EDT) 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 DDD526B0096 for ; Thu, 25 Apr 2024 07:38:17 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9BD351A042A for ; Thu, 25 Apr 2024 11:38:17 +0000 (UTC) X-FDA: 82047855834.05.CAAA025 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by imf14.hostedemail.com (Postfix) with ESMTP id 99551100010 for ; Thu, 25 Apr 2024 11:38:13 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=Z0huUBl7; spf=pass (imf14.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714045093; a=rsa-sha256; cv=none; b=oK1zqygLCUfCGbbCQ8UweVV+OTk47c8fXAmY+Effrf0NcFIU8T2xTnFRvzqk+j39a4UKm0 cwpwohsBrd3CGNiKqvgvsRRkLW2Y4SQ1mokgh2gueoRnRTyw7I9trck87ZXdABSSZ4VnJ3 ganEowS6RkJIK5/WZ2+qwZgprt4RN78= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=Z0huUBl7; spf=pass (imf14.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714045093; 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=4fVr4b9yY0BnR40etXyUF6I1OzhNW3adroiSkIr7JfI=; b=NrvHxbjouxFselythHYSlOCrYItfciXDrqNUeGR5lqfnS6P5LRy75ZfD+3kprS/K2rx7+c adznv92HknRLWmaB3Dp5NFTMUTJq4I30n4eAWHbEG8kvjnUeVEP29hItRdaoCK7Ej3ZLWH aXCrTW0V9ksn7QBKR1ZI8WfYrcN6/mc= Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4VQDPZ0yvLz9ssM; Thu, 25 Apr 2024 13:38:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714045090; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4fVr4b9yY0BnR40etXyUF6I1OzhNW3adroiSkIr7JfI=; b=Z0huUBl7vPYkwQXuGJvayILrp8fqw1XoWWWGfZA54Jz3eGBIbjPv2tzkb8U2hzLbN9kbzH CBVqCH1M87ltsgLZgkAJDtRtQTRwDdciiRm8HxJazZR48lp0lxZ0HZ8xH80ehB/Wf3AoJN KAh4mmedJIL72xLuMNS89gd6IW+Lksmwj+8MN4t+fBP+/YCC/PcX+i5CO1HDAW2CxtGWAG hdYShbikqRUAeOGRKvcwOevAF3K5a5ptRScXTkN4OOAADyrRpBA9eZ0HXPI8lSfNdVd5rm EGAr6TPGPpBEx6EBqTDWeGxgwBtvn53q1W5q5/KLLowSAgqffxK5VDdfhFhgcg== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: [PATCH v4 05/11] mm: do not split a folio if it has minimum folio order requirement Date: Thu, 25 Apr 2024 13:37:40 +0200 Message-Id: <20240425113746.335530-6-kernel@pankajraghav.com> In-Reply-To: <20240425113746.335530-1-kernel@pankajraghav.com> References: <20240425113746.335530-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 99551100010 X-Stat-Signature: cr7zfa9p964u8omhc17ggk95iu3ms6kc X-Rspam-User: X-HE-Tag: 1714045093-546529 X-HE-Meta: U2FsdGVkX1+FeOQG7PWEuRewOZz4Q6b7T9AqXeHgqJI7Q68FzlKvITrH+nY/yhumn34B64F4WFXD5QB4SAEZTf1GEPoAR7IHKIjs90BeX8EX1T5hSX65HxYkYMstaiK755Orid8UvcwZGMdSwk4zz/QcAHOvTfOjtTpyr6SYx5yCjD5Z2wBph30EmL111FWCBCwTwwFOq3IBlV9fkzVQKx8f3zqnwOdDK96mwVEytto/8MS3k38m3nFGh41dalonYBQoiSQq9nWRRNgrRiCfqbyKU7cRdKIgC7bLanx6oEf1fuO3KuNEBpDUtpPMWCha8PvFQiklVLng70Gl8VXTK+hCFZlx3q3pVpaNeH6Izg75vgkcy7ryV8cPxRfCPQkj3jcUj4pXo5CrJv/LeS+ippJ3K3MnhPTZjl3MpHOudcin5vTLPe9HMdMPJn3C2cQFsw0siBLUDxkoPl+te1riMiAF+JlulUhBIHgRItUb5e02wH8SNfkSHAm5GcM8gp3rzCk8VVSZl3Pr1KMMOuZ/BAqNrGMsEUpWw+5w9kC6MoF7we99TZneE60AmA/eOZ0wgTvbTXh5XTVp+5KuQ47XzkYdjikPcWlLihqsM7hx+lLOh3S3JlA5dffgdAIQIVOg2YaAPvQKvhrxs/eNKvuz/nmh17n78hY9xCiCe0LgBMjzEvZuNDY2ThYLLDQhHBPosy+kY/NB6Jl74wzNzpdNrwrjhRQXG9qzmPcMjT654t+OBpKvumV0GRhCRkRqRNaXj8xLCvgHvQFVvf6DnajJTVPlJGVc5zKatklBGemeJuIx8efZsGGniHKrkVKHZRbgzg8/xIidsS4xsYOoM6Z5q2zX6FU4qd+NjqH2s+upQ17LRRtj036s9ptRiL+6UwGXqrEBSFgvGK7u1Smx/hShWvUK54k4m4HJzoIoae3OspB7qG9r/NsEJTKn5lNn5JCb/hqfy6YR86wDYufVYJG QTAXpEh5 4gkVc81Q1kLfRAUT8sVT9t4OIy7y8GjCf8Gox8HDSZRvwXUD8RLfbIefDv8Q7i/9Y/0HQAP5A/Vqxr/AOlqA5SS9dx+ELHYVG3RmIA5sj5qnjSRmZr5YO+ye9A8kaWrW5nwbSsXkD/WBgUbAsJN511OAPN73rMd/TdfLIpimDpwy3+DB9cJshKLeuJTen6Ey989Y0J3T9Hre7Dmpj2EcWMoz30JQXyujTa3+i5Ce1XGKOGl6f67OPGmX0eLm6ibzELGiPjIywJVXEIXJcHCdElKq5J7CZjAc0f7cggPV4Ul5Ico1KlZDk5Kcb0A== 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: Pankaj Raghav Splitting a larger folio with a base order is supported using split_huge_page_to_list_to_order() API. However, using that API for LBS is resulting in an NULL ptr dereference error in the writeback path [1]. Refuse to split a folio if it has minimum folio order requirement until we can start using split_huge_page_to_list_to_order() API. Splitting the folio can be added as a later optimization. [1] https://gist.github.com/mcgrof/d12f586ec6ebe32b2472b5d634c397df Signed-off-by: Pankaj Raghav Signed-off-by: Luis Chamberlain --- mm/huge_memory.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 9859aa4f7553..dadf1e68dbdc 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3117,6 +3117,15 @@ int split_huge_page_to_list_to_order(struct page *page, struct list_head *list, goto out; } + /* + * Do not split if mapping has minimum folio order + * requirement. + */ + if (mapping_min_folio_order(mapping)) { + ret = -EINVAL; + goto out; + } + gfp = current_gfp_context(mapping_gfp_mask(mapping) & GFP_RECLAIM_MASK); From patchwork Thu Apr 25 11:37:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13643183 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 8D182C19F4F for ; Thu, 25 Apr 2024 11:38:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 574CA6B0098; Thu, 25 Apr 2024 07:38:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FD976B0099; Thu, 25 Apr 2024 07:38:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39DE56B009A; Thu, 25 Apr 2024 07:38:19 -0400 (EDT) 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 1B6946B0098 for ; Thu, 25 Apr 2024 07:38:19 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CCC7E41219 for ; Thu, 25 Apr 2024 11:38:18 +0000 (UTC) X-FDA: 82047855876.20.0102313 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by imf09.hostedemail.com (Postfix) with ESMTP id 2ABC2140023 for ; Thu, 25 Apr 2024 11:38:16 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=jCmWig6I; spf=pass (imf09.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714045097; a=rsa-sha256; cv=none; b=PQ2QUd0RKyHIQZ03vcn4NIXQKRL2m0H8v+nydq32xP+RpuHAZ2wOMW2j+5yBiG3ztt3asU 9RC7SxFjGAZW0TEzx9Cj3gT6imOzU+I0JQvKZr6I6binQYcVTvvfAqz08doksOIp7hSh+a 3SX0M2Yg3ej7gj4He+LqStmLKj7N19E= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=jCmWig6I; spf=pass (imf09.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714045097; 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=czSPhYVZqlifLCbGSVD4LN8Jicbe+9jxrg74bkE8W+M=; b=Q3oKidI7M6bFoLNj9AhBCQOw1xNuxyBp940fNRWYPasREA1ugc+KfO7w7IOvzs69SaVAHX zB8XoFmKSwudtv4Cab3NBPxEclmTH6b0UB4MsT7PIqjx50LzQBiz/V9oI4+7F1xyqqgBrY O4m3q4tZsaeIAyfXqr06upUiz4g9Sqo= Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4VQDPd5S7kz9sc2; Thu, 25 Apr 2024 13:38:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714045093; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=czSPhYVZqlifLCbGSVD4LN8Jicbe+9jxrg74bkE8W+M=; b=jCmWig6I8MmC4tVVnlqLI5vW94Wwlz9pRSUJiLooHMkOOe7ErsyVoFx2VhJY/WmdTxbbRT 3dzg1UBlN4MP4RmAdPxL20o+ed6dhEyL92yPfrr/KbjbRfO3NVL1umnag6JzyRlRB6r5zC q4tIjG3KF/flynDrsYPmLRPtC8lMuVFbc3cQXAl6p3O/gubiU3hUBvII5ArCSxnWG3PUIL SCX71g1J51gObsRKmh9vM7WMGb8WM5/CcZazYgw6T63Kl7NB5sOhnSNIvvGue/BhWjHzoo P4xXrijI969rMXgdWqBJooEzEPQorZWYJq7MfcKRzA79aD6/EfPrL4zxXw/Skw== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: [PATCH v4 06/11] filemap: cap PTE range to be created to i_size in folio_map_range() Date: Thu, 25 Apr 2024 13:37:41 +0200 Message-Id: <20240425113746.335530-7-kernel@pankajraghav.com> In-Reply-To: <20240425113746.335530-1-kernel@pankajraghav.com> References: <20240425113746.335530-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2ABC2140023 X-Stat-Signature: ugx8xt7gskhu44faes6zzqpzgwp4zukf X-Rspam-User: X-HE-Tag: 1714045096-562367 X-HE-Meta: U2FsdGVkX1+ULcJf2Arg3ZeaKBeFW8+2ThGWVSWBsgjGXQi4k5M++Qk+ZrBFj2gZeVocXoQ2bG1omDmAWQ9ThMnX+ValkjN1MoCjKhejeHYbXvzlgtcL9857p/TosChOdYTbeGriR5eOC9w9L6xrVHxxzgYTM7QkVYeSd3J7pzUur1gCGHuToqHPaJeEBDrlIxNX1JZurxpDqfnPUppVWa66JJQ7743wa52FwWHDcch9/Y9Az3LJzqdmmCSLIEt+DYcbuzsRxqYAieGUo50imqzpRDamRiIZL4IrrKzVhu7umLG6Ncb2TP3wQ0ECUdESTpJDXucTPJfBdqCLyJmf6kZtvYk5UJZTRyae7T9QNUvPCW/nZE1g/3EDyfocYOf9kbjLKbwDUk4GR725tOJjiVEaw++9OPbclNWA8MO8EO23PBYL774aCg0vxULA0P6voWup8nZxsOgnHOfWihusbuGmKDgcwnhGwQv6zX/b45Rp6P3gwwA3DJXE+cCZMAXl4U0IUJ0Fdg4xh07y2UyezmAt+tTpbvQjowCdXURdbPkUGbPX8042+QvpE7mE7dcnzqbKEaERxmrBBIB0i+InTnHJn9rkxV733KGh6BUrwJmvtT/fur2F/jeoMHZJCFF8mVrll4yYMdxjtlsKnBF4co9Z40/yt0JQ9lzGFw/oPvrI6WIN43W8wxFtzLqnn6LDrW7+pZQNzQX3d6Ob35jflxq5lxm7YZUczuQrBA5gGz03KXjol40GeQLRb/e6nrFkkvkJ5j6M92evEcG8lY5JSHziIjSlf5hh7AT+jFLer2fQSnV5+WDGg7ILBQ5t7UmlrfdMFKdGEsF5bjD8MDWEmuiDpXVqxz/CCqoc4ac/uBVVQo9kk6n8vdIX4qvOlQx70FvRLRfcEk9PLLHstQL+tPFDM/PscUSz0Jt4lO1rMQ0j/d/02BUZdscJaRLB2uD83fgWUNbBljmZ9rcYRWY VXiXm0Gy hJK4eI+ySrfZGDbqEIxVC0pdh3gSFs2BKXcmOtokwRMJU+HEZ3sPMcc6//D+or0wIoOF7oGCfEPvbYi3Lc9pnY2MEY+iMcyz/MNjdT9pWzITd251m++5WRSvEyEBm9CTGOQoJPwPSd/LZ3v3pFmhz1GHCMDMiyjovp+OaYAfb0D/g9PkXXxAJBjjSA9EanjfjskWm3FYQTA74Gobo+UGmTG4TwQinyggxC+naHhoTEcpWrR3gqzSAQxw2lEmHV8V5qnezGCWeFwfBc8N4nvfs06VZ5yS/4WqxDqqZ+KFheDFCcXw= 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: Pankaj Raghav Usually the page cache does not extend beyond the size of the inode, therefore, no PTEs are created for folios that extend beyond the size. But with LBS support, we might extend page cache beyond the size of the inode as we need to guarantee folios of minimum order. Cap the PTE range to be created for the page cache by i_size. A fstest has been created to trigger this edge case[1]. [1]https://lore.kernel.org/fstests/20240415081054.1782715-1-mcgrof@kernel.org/ Signed-off-by: Pankaj Raghav Co-Developed-by: Luis Chamberlain Signed-off-by: Luis Chamberlain --- mm/filemap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/filemap.c index f0c0cfbbd134..259531dd297b 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3600,12 +3600,15 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, } do { unsigned long end; + unsigned long i_size; addr += (xas.xa_index - last_pgoff) << PAGE_SHIFT; vmf->pte += xas.xa_index - last_pgoff; last_pgoff = xas.xa_index; end = folio_next_index(folio) - 1; - nr_pages = min(end, end_pgoff) - xas.xa_index + 1; + i_size = DIV_ROUND_UP(i_size_read(mapping->host), + PAGE_SIZE) - 1; + nr_pages = min3(end, end_pgoff, i_size) - xas.xa_index + 1; if (!folio_test_large(folio)) ret |= filemap_map_order0_folio(vmf, From patchwork Thu Apr 25 11:37:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13643184 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 326BBC4345F for ; Thu, 25 Apr 2024 11:38:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8FDF6B009A; Thu, 25 Apr 2024 07:38:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B189C6B009B; Thu, 25 Apr 2024 07:38:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B9C76B009C; Thu, 25 Apr 2024 07:38:23 -0400 (EDT) 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 7D0D06B009A for ; Thu, 25 Apr 2024 07:38:23 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0208F141224 for ; Thu, 25 Apr 2024 11:38:22 +0000 (UTC) X-FDA: 82047856086.26.3B0AED8 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by imf04.hostedemail.com (Postfix) with ESMTP id 9BEF740012 for ; Thu, 25 Apr 2024 11:38:20 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=0i4j7ORW; dmarc=pass (policy=quarantine) header.from=pankajraghav.com; spf=pass (imf04.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714045100; 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=SZEgKM6QrgoQBOd+qQrQCeNmZ9w7P0QsYqZWksJ5EHk=; b=wutpLplkrocvapDCD9RKuyz/yFeHrWz6cg3GO0Bh1DJotgMUOddSEO3cbWPfs3lRdF+0zc Eq46Z4qEnVLg6HtZwMagPlPFlfKC7b/NpBTBQWsAO7dH1LbMzUoTroebvF2D0o225+9njm 6AET1d9t/Z1gkFyxRSxaRs9IgMFm/1U= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=0i4j7ORW; dmarc=pass (policy=quarantine) header.from=pankajraghav.com; spf=pass (imf04.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714045100; a=rsa-sha256; cv=none; b=pRB9gkN2epUUZigOFZi6WhiWqGE804Bh1ThpGi0YedqqH3L4Dv75g2piNNrLhSvaQwmtwC eMKyaJmylqjePdTthftQw4OAsy9yjkLxBrvN2AFpmkCKz07m2AMf8y6i/CSJJK8O9y/TJx kkxLkpf+WXOY6j4fy2uqXaG+jUbbAhM= Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4VQDPj4W0lz9st9; Thu, 25 Apr 2024 13:38:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714045097; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SZEgKM6QrgoQBOd+qQrQCeNmZ9w7P0QsYqZWksJ5EHk=; b=0i4j7ORWzhspfs9ixeGdeOd0r1Eo3pwU4BtbEF6woZni4V5L14YKa90J2IqEZYFdXLtLwQ d095+992gOcqpTpvDmkxs9wjY7M3TnyMW+njvxML8bzJAjWem3m3XsWdSnSWuFuh+Sj2Qj CGfTbZEvR/uGNDzP9Z4zzf/tKBzDsE6Ugs0w6iwnqs2ybQsAfmPk1e45Pn0ZYURDU6HqQs gsvloW/OFuuUMDj24VJs5qlh3CmNhbyAybQzf8AuK0YnrBAsRuGirf1A4SpVy33vZBe5H0 nWRJZVwpcGRXpRVNm+x4Y29XeSpONlxWjPDS1jg0b1WOaVJEhEi9gXgIZO+4IQ== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: [PATCH v4 07/11] iomap: fix iomap_dio_zero() for fs bs > system page size Date: Thu, 25 Apr 2024 13:37:42 +0200 Message-Id: <20240425113746.335530-8-kernel@pankajraghav.com> In-Reply-To: <20240425113746.335530-1-kernel@pankajraghav.com> References: <20240425113746.335530-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 9BEF740012 X-Stat-Signature: 1ktjc414qkja1zb8oe33niqnteudg4xh X-HE-Tag: 1714045100-114117 X-HE-Meta: U2FsdGVkX19VE0jtywXO+lCmRC8oHrhqEOoIeT6hE15ICspCXAFwrDrDXv7MOBu0Cx+X/vJk1ToYsp+oYE2CBpVbJF5VbBLMRHgJYZAtAN3ttt5FP3se4uBmmWKdcazRvhHfqdAVKtyjL+Q/YY4c6QvfVgJYRc+Jt+febHRRsdbwnnq89lncUVyfpEFvuTI7NFcY7CYYAJUQkD1bo6ZvEtzPtRadpg1LxXkw84ECHzxK+F1Q6ZGWGlLP1TBjc/diYJATjIldWcziqxL97/o4OVLGXf4RGZJaD75H7QFAdrdHtocqfjT8Nk15lYk15iJZ9yK/wL9EWrK5PqwZ6IKyQvH4UXmX+LwJJEAJUeF+/fvHdn98GWzAcxhYY8umok1+SiofU+c6z9r0bw9k1mlu4LIKSd9b/kqgUcQMJDT2FGQyzthfLq0INNvxvM17D8QECGS2kl4yvUzGdBBmINh/Ft+nzUFRsm2bmJT1urVz6aDifpi6pYBCoimhX+lL1vosM6l1YB2wlkaH8SrRQNbq6OMNpe2FFXn5vXy47YGtS0twtQl7kF79IXnSYVJ2NBC7jv4GUp4w1KRh/7MqGQFkAGOaVVbSmimNGu+vSxNvXEym0nsAIBJO//i9V3cknZ0nQB49qkrkK5oeEvqqgWnltXeqsZRwa68k6dLbgPhCTCebv9p7bccXF7IKuUog5Tp3mXHwhM+TOU7r6YDFQ4nbEoiSUBJch1vCKAbOEwwQhQeTGEa0UCWg/+h7VPhxtRsz+LwbFSm2Uggis/kJIMkBRKRsr9YV7bNDZ9PoN7Xx9nG+RXwOQDUPmZWHL9taURxPIpM4dNgg5BWFtASjgWEFujeRw/wFjMO0c54MvFF6ghisWbATZxfypS6hFnkvZaDAskZDZFXdxbF+tkyNAbsIlwfBh5/djWVE2ypWaEMW0tHHU4EWuA58RFchpZRH1Ws0hhPjp5RfaPqEkz9gPFU F86PrXvB z8q/QG8Ifb4yLrMgIUaRbpPC92v8AIXwnP29NDLIAmKFobWPi1CoKd05433KxynCVOGaPqJ2aESlxb6FbaJ1UY2r57Y01268OG2k8aimEJwy82LlTswyj0tCZKfF0EOuydCm5u1YFQh35PWTTrzqQGuDZVE+1PkVmI4pFaJIGxGlXcRrYVtG+xOxDezSiDaTgNXk24yf/6ZZebvOb09fGW+jzxM5XMpfEDvwMexJXc5OUNMePbRw69deh5tCwQ9p0mVvs1/XhxIKPMityiSLcc6ksgY+pyGfdUcAX3y+LTheAsX62mcMf41SvMhHQtyNwFLa1H40mp0OgkwI= 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: Pankaj Raghav iomap_dio_zero() will pad a fs block with zeroes if the direct IO size < fs block size. iomap_dio_zero() has an implicit assumption that fs block size < page_size. This is true for most filesystems at the moment. If the block size > page size, this will send the contents of the page next to zero page(as len > PAGE_SIZE) to the underlying block device, causing FS corruption. iomap is a generic infrastructure and it should not make any assumptions about the fs block size and the page size of the system. Signed-off-by: Pankaj Raghav Reviewed-by: Darrick J. Wong --- fs/iomap/direct-io.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index f3b43d223a46..5f481068de5b 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -239,14 +239,23 @@ static void iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, struct page *page = ZERO_PAGE(0); struct bio *bio; - bio = iomap_dio_alloc_bio(iter, dio, 1, REQ_OP_WRITE | REQ_SYNC | REQ_IDLE); + WARN_ON_ONCE(len > (BIO_MAX_VECS * PAGE_SIZE)); + + bio = iomap_dio_alloc_bio(iter, dio, BIO_MAX_VECS, + REQ_OP_WRITE | REQ_SYNC | REQ_IDLE); fscrypt_set_bio_crypt_ctx(bio, inode, pos >> inode->i_blkbits, GFP_KERNEL); + bio->bi_iter.bi_sector = iomap_sector(&iter->iomap, pos); bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io; - __bio_add_page(bio, page, len, 0); + while (len) { + unsigned int io_len = min_t(unsigned int, len, PAGE_SIZE); + + __bio_add_page(bio, page, io_len, 0); + len -= io_len; + } iomap_dio_submit_bio(iter, dio, bio, pos); } From patchwork Thu Apr 25 11:37:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13643185 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 B5D92C4345F for ; Thu, 25 Apr 2024 11:38:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4629E6B009C; Thu, 25 Apr 2024 07:38:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 412AE6B009D; Thu, 25 Apr 2024 07:38:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B5C86B009E; Thu, 25 Apr 2024 07:38:27 -0400 (EDT) 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 06D976B009C for ; Thu, 25 Apr 2024 07:38:27 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B647EC0557 for ; Thu, 25 Apr 2024 11:38:26 +0000 (UTC) X-FDA: 82047856212.21.74256FC Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf20.hostedemail.com (Postfix) with ESMTP id 1FE091C0004 for ; Thu, 25 Apr 2024 11:38:24 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=g9o+YhGp; spf=pass (imf20.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714045105; 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=Mzy+vEt0Ou46AF43fFmIy+ZUX/Zt6Oz29cAtMC3yZgg=; b=7hfx1J4H+OqyNZZAqHYU489geY91kaSAvnY/I48OxnuYj1XjZiiR+n+aclYo7peJWcp+Q5 yRMMOx3wnchRws55IJjD64znywnjBZtaD8eE+Gt+aTTPLmvuteUfcvosj7pZrLUsSjnxCY hGSw4r9zM8y1RRDqvfzketQKUqBn4Wc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714045105; a=rsa-sha256; cv=none; b=lQc1CukfcHz5z9A3/GJCZAOYJpQ8qrdXn8RrONqO/4Ba3pzwJP1KJhttEepxGEioxhNlFq JuMWMjLq55dYSr56DCafW6fETOvucmt89kEqgUBwovmqJq/DuQsesEIfrBBYXGDdMVFX66 X6IGU2dk7Qxm7bHvPj0A68zQA7y2T2c= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=g9o+YhGp; spf=pass (imf20.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4VQDPp0xnmz9sr0; Thu, 25 Apr 2024 13:38:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714045102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mzy+vEt0Ou46AF43fFmIy+ZUX/Zt6Oz29cAtMC3yZgg=; b=g9o+YhGpTLj38QjSXu/Tp0pXNF/qKronl8zsmBk9FkPmf9vVsVSiPEVWMfOvqnCEtNXw+f PSDAyEbeKSf+kyuVgLJ1j/NDoHynyYlnQpFGy6f0GhcljYB2b58Nk5wlujtpQ5FhNOMzZE Gx2hdcj8rhy2Z9hXo2ZF/0j8EWTN9h+B4R/r+RXFBh8mcU+7HnadjM7X9nJ/Kk+3j8MHFy Wje26dj5b12Z85igfcpE4A7+6r3I6BwuyHWuM3cYbshoDp5asV6WYXJhvnn84FX8Vt7ueA 8xEsR7x8o/j2Z5cVQ/OSsdMH9yYa1Tvn+Un7hHYyN9xUUfe86hKtVt3XH0FYIw== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com, Dave Chinner , Pankaj Raghav Subject: [PATCH v4 08/11] xfs: use kvmalloc for xattr buffers Date: Thu, 25 Apr 2024 13:37:43 +0200 Message-Id: <20240425113746.335530-9-kernel@pankajraghav.com> In-Reply-To: <20240425113746.335530-1-kernel@pankajraghav.com> References: <20240425113746.335530-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Stat-Signature: 7krcwgiyar9mhaidd7zewa1wu8yczazd X-Rspamd-Queue-Id: 1FE091C0004 X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1714045104-215929 X-HE-Meta: U2FsdGVkX1/naJKj1zbfUs5ioRwxbPcDmduHKBQ8UyXt77zFapoCFb1vo3msVdAfLjEv3zYUdbnHXRTW581aodl/WVxZsYNORGXqVhDVwasQgCDOpfK54W4lrD0uE9/fwiZwzksd13LKjhmcVmURh7ju3JHeBQT2b3rhEc+jWSja+NWs4fZyqaKCpVxda6cRLiK1MdCTKJ2Uu6weOm/Odkc8d+dbB1vmNOCSxd3r0CJ24J4Dm/+F8BxLgdMiGtVm7UTHCM6yle+Qkds93nrddBGiXFzAn6uJLyBqQbpu/bAqBZoSwzEyye/bFZ5ABI8XS57YlFKDoTTf+lL19PXvl9qgwQLG+GWQhOGhha3pbI8YWqCIeWotx6YSCHTV5RL4w9sLHJmxJBpEEh7hEHoWzgmZZ7AKXmb5ctdMUUkwgVw3lPyDw1bDIjISIqOHmSvwcMQAbCM87EcrAv8MTqF5gMzbeFwVHKKHfuhe0mTVcl3kHN0q5gY9l7toGk2T2iYF0Gf9v/0llpr9nc8p5Hz3WMhTxetdUpmHjA/nXAvZi17V0JRMBjuCNtMVGU3I5wNSOXTghYClX6M0qU3wqQZzN6erP2ej/Y78ARDolOfuFpJdLSAoGiYcP0LL4CvRD2mbGK1NuAXaiweLdyuhcCjAbDmjlop5RBI00G4G683h4IjnmsYgX7sHLoAq/zY1H86C50EO8S8Om/5RAFgZOvczL4diRaBtcvOXP2wOw2eCAIG8RF3LvnGPEWD/nxaYAzlc79U/ndh9AZlNzn9RUKlTXFcXsQl5HZXuebr/nu03ssX65eakbKUlavVupDfAVNXxeyYdXy7fPJzHg1/qd7e7Yf0a0QByjE+S2mMlYE5uGC1Bn0Y3rnq4mesuxzYAKkemjbEXZ/+oJ4RHBkOIRwzEvkmMXvXzzxO0 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: Dave Chinner Pankaj Raghav reported that when filesystem block size is larger than page size, the xattr code can use kmalloc() for high order allocations. This triggers a useless warning in the allocator as it is a __GFP_NOFAIL allocation here: static inline struct page *rmqueue(struct zone *preferred_zone, struct zone *zone, unsigned int order, gfp_t gfp_flags, unsigned int alloc_flags, int migratetype) { struct page *page; /* * We most definitely don't want callers attempting to * allocate greater than order-1 page units with __GFP_NOFAIL. */ >>>> WARN_ON_ONCE((gfp_flags & __GFP_NOFAIL) && (order > 1)); ... Fix this by changing all these call sites to use kvmalloc(), which will strip the NOFAIL from the kmalloc attempt and if that fails will do a __GFP_NOFAIL vmalloc(). This is not an issue that productions systems will see as filesystems with block size > page size cannot be mounted by the kernel; Pankaj is developing this functionality right now. Reported-by: Pankaj Raghav Fixes: f078d4ea8276 ("xfs: convert kmem_alloc() to kmalloc()") Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr_leaf.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index ac904cc1a97b..969abc6efd70 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -1059,10 +1059,7 @@ xfs_attr3_leaf_to_shortform( trace_xfs_attr_leaf_to_sf(args); - tmpbuffer = kmalloc(args->geo->blksize, GFP_KERNEL | __GFP_NOFAIL); - if (!tmpbuffer) - return -ENOMEM; - + tmpbuffer = kvmalloc(args->geo->blksize, GFP_KERNEL | __GFP_NOFAIL); memcpy(tmpbuffer, bp->b_addr, args->geo->blksize); leaf = (xfs_attr_leafblock_t *)tmpbuffer; @@ -1125,7 +1122,7 @@ xfs_attr3_leaf_to_shortform( error = 0; out: - kfree(tmpbuffer); + kvfree(tmpbuffer); return error; } @@ -1533,7 +1530,7 @@ xfs_attr3_leaf_compact( trace_xfs_attr_leaf_compact(args); - tmpbuffer = kmalloc(args->geo->blksize, GFP_KERNEL | __GFP_NOFAIL); + tmpbuffer = kvmalloc(args->geo->blksize, GFP_KERNEL | __GFP_NOFAIL); memcpy(tmpbuffer, bp->b_addr, args->geo->blksize); memset(bp->b_addr, 0, args->geo->blksize); leaf_src = (xfs_attr_leafblock_t *)tmpbuffer; @@ -1571,7 +1568,7 @@ xfs_attr3_leaf_compact( */ xfs_trans_log_buf(trans, bp, 0, args->geo->blksize - 1); - kfree(tmpbuffer); + kvfree(tmpbuffer); } /* @@ -2250,7 +2247,7 @@ xfs_attr3_leaf_unbalance( struct xfs_attr_leafblock *tmp_leaf; struct xfs_attr3_icleaf_hdr tmphdr; - tmp_leaf = kzalloc(state->args->geo->blksize, + tmp_leaf = kvzalloc(state->args->geo->blksize, GFP_KERNEL | __GFP_NOFAIL); /* @@ -2291,7 +2288,7 @@ xfs_attr3_leaf_unbalance( } memcpy(save_leaf, tmp_leaf, state->args->geo->blksize); savehdr = tmphdr; /* struct copy */ - kfree(tmp_leaf); + kvfree(tmp_leaf); } xfs_attr3_leaf_hdr_to_disk(state->args->geo, save_leaf, &savehdr); From patchwork Thu Apr 25 11:37:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13643187 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 988A4C10F15 for ; Thu, 25 Apr 2024 11:38:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 304886B00A1; Thu, 25 Apr 2024 07:38:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28C666B00A2; Thu, 25 Apr 2024 07:38:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 106FF6B00A3; Thu, 25 Apr 2024 07:38:36 -0400 (EDT) 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 CEBD86B00A1 for ; Thu, 25 Apr 2024 07:38:36 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B3D86A150A for ; Thu, 25 Apr 2024 11:38:34 +0000 (UTC) X-FDA: 82047856548.14.12072BF Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by imf23.hostedemail.com (Postfix) with ESMTP id 3FAEE140017 for ; Thu, 25 Apr 2024 11:38:30 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=f7jcKlQP; spf=pass (imf23.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714045110; 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=gIfjpeeNWGR8UToHGDXkOnyh18tKvUHuNUnl0OPj7BI=; b=iTFTxCr5uVJMnMDISjp1UsUK84OHLYH7pZlG4cHHJIVKsFdzb0Y2jYvKtJuDBurpr5jtvz lMObT/wljLZFp9jXHMS9mr1dMuBul/VrpcBe9GLL+xKkxeWam6CVWWMHbw72haz5x6RPtq QNzTEWuDQ0jaruwW2+IHVDKaCn4v9fM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714045110; a=rsa-sha256; cv=none; b=hqhFBWkqtmP1K9YXJUePjZUzUNPBRx25g4IBEYTK7524vuCpEZ8PUVH8EdhLoG7fOJMzkL PnxukixTaCoET/ft9zhDMYquwe0q5QMqGoLiCIHhD/+OVPO08coMBdbKm/dBbPkIsU4pYu eQKxFWTrdbmLQBOcP+9aKow2N4/42i4= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=f7jcKlQP; spf=pass (imf23.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4VQDPt54hLz9t5C; Thu, 25 Apr 2024 13:38:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714045106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gIfjpeeNWGR8UToHGDXkOnyh18tKvUHuNUnl0OPj7BI=; b=f7jcKlQPBfdo5JDYXYUH/c0DKe3CXWPCsikhLprRpyztxc8+iqGjrFBcNznlGqrPUwXRyx YTp848BJW14DQgetVXZGZZkTeXzlZAplKzBtUVlM5VtIGjhRth78SC/bFtY5audPmOVkJT ZnH3F4hsDAVwQJnu3cR+/wI1iEVhY2fq4GhjTek/n+/rmLF4gyj4ASTvHU9Jn2eD71W8Tl UMVSJSMo0ypnXW0grvP6XvCXs78G+Mg7PewCr9m/ZBJRX7pTzCJDU8eAHNf7ZgP41ltNd4 L+QempcsCIUIXA283kl/HsUM7k9QZbYJnfMBWfcPNBW7gXkVAHZI3eypTvhWmw== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: [PATCH v4 09/11] xfs: expose block size in stat Date: Thu, 25 Apr 2024 13:37:44 +0200 Message-Id: <20240425113746.335530-10-kernel@pankajraghav.com> In-Reply-To: <20240425113746.335530-1-kernel@pankajraghav.com> References: <20240425113746.335530-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3FAEE140017 X-Rspam-User: X-Stat-Signature: sxqk5bzfrm6hap7rmd9bxoxpdbyc8j7a X-HE-Tag: 1714045110-273951 X-HE-Meta: U2FsdGVkX1/nf5WtI1ZuqfYMVgyINz7ow5Wu96WvQvCXBy0HIySPSK9Hz8An/kIWs9Ig4N7KQMC7eUUnjKPDXG8n8IBMoc60y//U01g9wTD22nGEkNbm218TqGvARPWb7KI8EQUAwFpLKdbo2tCBWbidOsZrO5aOjGN7YCwxF4k0nhYjYoXBOY7/TOZY+XST9QxHtwfuQ50qOlPJv+CKTbJZUkBdkVOE8x7fqTi85sRvJBOxrMLbSg1fk7y3tymNSpaY438ERl8aMIAwYMW98YW5wWvaC7G+rCZ+SSH9TjeQgq75smF9ycEk3la+Oxgl2E7XCDxqbKYgngWU38f2nO940E1RO8JboLyJnvsuIAEjQVifDqIgiNlfY6Msp+2U8TxnoGFz1hSjq+mhpQV96LrnZ6U9tiuIDZ1fzCvGCFqdq2fHwO7zB5J8m26vHDyo24pcFZ/HEv6PqZSmBPzooL6qJIhlzcKS1QXtKjf+za3le75vqxAU45L73GpwSVba5cA1A0MbvHr+oi+jcgkL0+hlV9XbnBTh/lztg10ORGy+A/i89+BeKARre+e0dHkfqZu8wMoUcCCATdZy3o5+azvE/yrfI4hbVSmr2jmvEoFVgn4JiHC+LDbDPp6PqMhdlO1EAN6kjrxsgH/VHzaxKz7KO8d09BU6zvhlas/JL4a2yO/X1dkXF/6/TIrZqNcv1SNbgYVShX36E+bN+Z7ilCT5wVn+GP+vOveGfNjH5QThDnRzn+EpZ+M2wz3qbFKKw/1uW6UJIj7vcxzz5NniDF7lJe/VFosfu1vXKFiXlwVllT9SqLp5yoFMZbwRvPvBLUZxjaRpjqZxUKbPO2fIfjpUJq0SLy2OuOvdCsMyhvReTn/DWe8rMbcPMwhvpogJXVzD0mr8dwPVzxY6i//P0XgJ+NSMG30TOTjIpeLvN0AyJAm8G3wioLAnqC9hCyZEnNseGy9QT+gD6cUoDXz QKr8t/1B JpF01H+FPP8t3iHGSLlq7Vgtsv3sRmxGGakxs8K7fieS3fdXFEzy5KaW+Zr5QFrFt2PzT5qfGRF+LdkqBC+6gG5Tl2z0ame8JZZoKEfTd/kaFDrUHjEC+nA/caDu/VFBPuoHhV0kvZ/dKqIWgn7hdL3j0j5ATCae14Z4Oav9hOM5gT8EquvZCDhtqA5vH/Cum3LsYPAccMpksc/MSy4ne/ExP6DbSHIGaf4ESG3bVWWOoZAU4TEfJS1tyX2WMFgmnLVYQ0PAuqaDAeA5vswmkxmsbpSb13vzVn1mz628b+GTnhpKa4CK0xuolDynitTdm4GoLTu8kM68AR7WO8F45Z8SYfY0K1SebNmMKdalG7VWL0wSuz6coEQUFbdbV1b/bAn0s 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: Pankaj Raghav For block size larger than page size, the unit of efficient IO is the block size, not the page size. Leaving stat() to report PAGE_SIZE as the block size causes test programs like fsx to issue illegal ranges for operations that require block size alignment (e.g. fallocate() insert range). Hence update the preferred IO size to reflect the block size in this case. This change is based on a patch originally from Dave Chinner.[1] [1] https://lwn.net/ml/linux-fsdevel/20181107063127.3902-16-david@fromorbit.com/ Signed-off-by: Pankaj Raghav Signed-off-by: Luis Chamberlain Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_iops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 66f8c47642e8..77b198a33aa1 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -543,7 +543,7 @@ xfs_stat_blksize( return 1U << mp->m_allocsize_log; } - return PAGE_SIZE; + return max_t(uint32_t, PAGE_SIZE, mp->m_sb.sb_blocksize); } STATIC int From patchwork Thu Apr 25 11:37:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13643186 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 EA8FEC4345F for ; Thu, 25 Apr 2024 11:38:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76FF86B009F; Thu, 25 Apr 2024 07:38:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 720A46B00A0; Thu, 25 Apr 2024 07:38:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E9576B00A1; Thu, 25 Apr 2024 07:38:35 -0400 (EDT) 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 3EFE06B009F for ; Thu, 25 Apr 2024 07:38:35 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 00C83409D4 for ; Thu, 25 Apr 2024 11:38:34 +0000 (UTC) X-FDA: 82047856590.22.D8FB662 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by imf30.hostedemail.com (Postfix) with ESMTP id 5FF7A80012 for ; Thu, 25 Apr 2024 11:38:33 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=iUOZlanZ; dmarc=pass (policy=quarantine) header.from=pankajraghav.com; spf=pass (imf30.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714045113; 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=7L6awWLepRreCjOlDARDMkw2Tlyq8BMiql1zMtjdTDw=; b=MFcySsDOtnS13jAvk28+JdHViR6mlQ8AhNuy7Kk/C9On2SMiTlYt2dAfOvyI/Sf+xUVQeQ EEl9vtBo9NMwWPNCeik4F0fOKwHBmBYun0G9DMZ+U7LyKDG3x+u9lLXkKBhyqcN0tksjxm EljgHA/6qZGxPTXR/JelfLpLwqvpAYs= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=iUOZlanZ; dmarc=pass (policy=quarantine) header.from=pankajraghav.com; spf=pass (imf30.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714045113; a=rsa-sha256; cv=none; b=t1QmUp+hAbjl7nN2Qi2zVjEQW/DbHvQVK/99Xyreqmq716U+iOEQ9Ebm1SvUUqZFBz5zaM ZzG/bfgTpCt+0kVfDGGnK2wYwhl9I5DtbsKPhsxCYlkqF8TP3goCjWn5ozUnyhSgLW+Ibi Y3gn+n/qnQCeu0S505cjd1vZcflysrg= Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4VQDPy34JRz9s7Q; Thu, 25 Apr 2024 13:38:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714045110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7L6awWLepRreCjOlDARDMkw2Tlyq8BMiql1zMtjdTDw=; b=iUOZlanZ2C3/jZz2S8ABbp1qPpO2hBWafHSyLzmGwpJXYKBBM8sP2yDLliwXN8E31p5Sm8 pXxktiBVBG9c/vnRc3jIanZQ7+QirXLJ4CE+3CC+ctJRrk5MY5schTRVXhHiQTLxJkV4RO c/tOp1e03rMQKQ/PQfLmkA1ODo58Njdtw8zsPmf0KQum0MFlRpkd6Qyf+RN49/2sImpc/b 4mMPhHbF5Z9qmwgtpMU2ltkFqJdHcPvxkiocluP7yumz76XrCgrCJcQXZtH24p6XHSkbhI hGXfFkOa6pEt/ZQyEsK/MDTurV+oXp9dwW14zJA9Q5DjnJhld/76witYmemPeg== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: [PATCH v4 10/11] xfs: make the calculation generic in xfs_sb_validate_fsb_count() Date: Thu, 25 Apr 2024 13:37:45 +0200 Message-Id: <20240425113746.335530-11-kernel@pankajraghav.com> In-Reply-To: <20240425113746.335530-1-kernel@pankajraghav.com> References: <20240425113746.335530-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5FF7A80012 X-Rspam-User: X-Stat-Signature: w6k3awye4x7z9q7xbo3sfw4mt6b4phry X-HE-Tag: 1714045113-944935 X-HE-Meta: U2FsdGVkX19at8WjQLfr/gVfjbNKt5h1JjPKDYpm1b9AYxLBlwvaMGtOqtBQ8qLwT7FPE86HbNGTVZVrzd2xUe4Ve5/E7stiIScC8AOG8tFhmfwg4Cq/K+Pv9vwBBYKK7mSZloTQ4r+tnk2hgp98Wz99MK2BaP6FUqLYTon0g3Ur/qzpagx0tJzx6mBAFjNgOMuUQAjyVPcqJqWIleyon1+P9NRb749jqwTM7h61j6HgZnVB7fuurK62gAgB1n1npll9B8ZeRWIakjLIzQrJgdkp5ZAAyjo1ctG7f55+pLObVNZEm9f/vAEeCrp1jcHYcZyD5uMsho6oILeZH9T07nGbGyqxZZ6S10lA80uCRX0uG1hHY6SLqn/JlifpguvPt427aAuLvPyIdiWT7jD/A400m39j3VCwKMRXMSBhCorOtJuoGfIsri9ibswomV2hDTRAAJXk4xwNS5vB+/mDKLPUS+496F+PGkBe1tmIbpzvarEbj6j/7r9O41yRHIqcWbIJH5y7kPrfbL8lXOsfptHQW/kvlzgSPDLoLXjZRVgJD/SXSUT0DfWOIy+RRdF/0xHeJMtYleG1ZrdrjqQSmZMfp/Oja/OKOcC86pCfEgciyBte1sdikq96aAjDytZ3n/73p+ykoSs356aPyohnoHZYwWr/8JFPaVmxqF1TGtO3yYLcHBBYnX2A9h+hXMWBnLpBCj/GtgZSZNR3Gi4xltDkSakduV8Ei6ANRF+/yYqYYLqnI4UW+LrZCDEKITmFENzkFrWR2VeEw+TUUaQ5gSj+927W/aId+FMFp/LbvbKKg0bv225IwJ895lkHSWMGCqfRJm9/H4JTWGxyzsitj3trBVZNqBynXHcvoV8hcruULBRpzKaL50Y/8LaMAqs4MxCyz82rWp0UI+YYrcDRknCwX44Wk3tZPCjyA1prDs1mFp7OeJprVZrWsE4pLbpuwTtuls2k+7N5lbyrL4p qG8OxijT lv9tFTZ6jXxVxuedPpDKcd3qaIeoLjciNsAgyNf8hzY9fLtNjAmksZBpxSFrCJkrsIcW6L17SsvBp7LBosO7yBwQ5AJ4XiD48uiK57VzIqSmQyrescCt9PDGB1qLpVRxx08HC2LyetJElp8J2NYobjvfkBTX/JmNrGtrNaim2bPRUp+hDTWFEcKA9Y8GsnnMlaJcHF9Upc8i92xx0M4YveuEVD8ca6bG3PaV/GKsPPGEZT7CmRfq9sE1lPw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000013, 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: Pankaj Raghav Instead of assuming that PAGE_SHIFT is always higher than the blocklog, make the calculation generic so that page cache count can be calculated correctly for LBS. Signed-off-by: Pankaj Raghav Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_mount.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index df370eb5dc15..56d71282972a 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -133,9 +133,16 @@ xfs_sb_validate_fsb_count( { ASSERT(PAGE_SHIFT >= sbp->sb_blocklog); ASSERT(sbp->sb_blocklog >= BBSHIFT); + uint64_t max_index; + uint64_t max_bytes; + + if (check_shl_overflow(nblocks, sbp->sb_blocklog, &max_bytes)) + return -EFBIG; /* Limited by ULONG_MAX of page cache index */ - if (nblocks >> (PAGE_SHIFT - sbp->sb_blocklog) > ULONG_MAX) + max_index = max_bytes >> PAGE_SHIFT; + + if (max_index > ULONG_MAX) return -EFBIG; return 0; } From patchwork Thu Apr 25 11:37:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13643188 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 355FFC4345F for ; Thu, 25 Apr 2024 11:38:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8E966B00A3; Thu, 25 Apr 2024 07:38:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B3FBD6B00A4; Thu, 25 Apr 2024 07:38:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E1DA6B00A5; Thu, 25 Apr 2024 07:38:44 -0400 (EDT) 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 7FE5F6B00A3 for ; Thu, 25 Apr 2024 07:38:44 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 26B2EC1196 for ; Thu, 25 Apr 2024 11:38:43 +0000 (UTC) X-FDA: 82047856926.24.4A34594 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by imf18.hostedemail.com (Postfix) with ESMTP id 48A071C0006 for ; Thu, 25 Apr 2024 11:38:36 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=qZ6LTcj4; spf=pass (imf18.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714045116; 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=Xr9yeLAhFPdiP5bQa/19/Lc9ERKBMv2dNCWngwYe54s=; b=3sJ8sVwBB2Anvh7kdLISJ2e78Joc9TcsjJb8dHMwCX97mtbqKn2WSUD0MBjX0hUxDTxaNh PnmEsdkSdqGfC3qMCIvN2xng3l6ucybwHULqKZb0tR56eGpsW1SI+zWPypNtZt0sn93U+G L4kez92ft/g6Xuk8f4syZY+urTZvYzw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=qZ6LTcj4; spf=pass (imf18.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714045116; a=rsa-sha256; cv=none; b=KSX6LftnhRHAfEGRs9Zv0JM02t0rR4j9nuqsF1cw0g/qlCcM7asi3YZl5mVccDxukyywab dSjHXuV7I1moS4KNpy25V64ZFTQJyTsStyBaO7ETlB8sXOiPIL9bHiRtQ1HFluQg0Jx8M7 VuoZOudcjpmGdoKyA7t02RyKOXHbE4M= Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4VQDQ12C01z9sWy; Thu, 25 Apr 2024 13:38:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714045113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xr9yeLAhFPdiP5bQa/19/Lc9ERKBMv2dNCWngwYe54s=; b=qZ6LTcj4Mi7kgadnj1OzMKN/Iop3ThPOJ/gYL2uMPgOTLUO+rN0Br4nAhEMODvtNkEH51Z /n9ysdoccT78ZdOJBu7ME8LXFbUx0PjzDm4A2pLgbJfNABv6x462zHw2tCKwqOSjublJXy hFZs6PTWq5pKg3FQ7khiOiJ9i+CPFke5gT5AtK3+z1abZpIl4xP4K2bXY89Y1cKWXOa4dO Jk5HGQqId3wJL5tLfFrO+lXaDZuNtELeYTUf/c7vvFqTjD0fqfVF/WuHKQa6qVyIEahElu Rr9NLaI6azL9hy8cYsmi7pUBI6xkLSihpOM3vpVRsXvWKcb4XSYC6rPNnLT/sw== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, djwong@kernel.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com Subject: [PATCH v4 11/11] xfs: enable block size larger than page size support Date: Thu, 25 Apr 2024 13:37:46 +0200 Message-Id: <20240425113746.335530-12-kernel@pankajraghav.com> In-Reply-To: <20240425113746.335530-1-kernel@pankajraghav.com> References: <20240425113746.335530-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 48A071C0006 X-Stat-Signature: aakbf86xkuq4th5cxpz7tefzs1d99udb X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1714045116-510786 X-HE-Meta: U2FsdGVkX1/6SYk2jmGlTg0iKQTEW0kqZOh7QAhgBuAVic+OQqZQmNYiSBcTvjBbUYxmCwEmhtd8MejeNCyrPNZ+zeqst12dBsNFhraFo+46BWluZD2VfHVQ7HNGSMgDQZB2lkMDPQe2FY+1ylCNZLZZyqaS7dATc7lL/dzNgxwANOaO2j8Il9Nde5k5wQ2hh2SptIyHdY6TNgqYQJtgWelfw/H/u18FQ8MMjoLUCxk1HA13a9jd5I+95enDt0T/o35QOjcE/gp85MpJ1JLxU3OVc411pv+rO1RB/nIy9drbR/0Jt+nX5bDG0zIYjmg3T2+mO0xpmqZ2MKe+ZEEevZkwkZOxh2E9hBITTjE1Q4pdYOuFhLXaq0foYosKK1OpvFI28/fGwQMDI+nwvz/9JLlFtUVZAsFOQEtEC/5L3nCmj56bYBUeEq28dLNThBOsNYgnSdT03bfzTuFMJHTNu40EZaoIAgfr8fgsXCpKDIRNCdzRzw4PoqPOWyK/drFWwEIN5ZrNm65oPbmWKS25l0jzSQOyZIhdacUwS0AWGMVmF6ZnePM58d7C16kmiJolGeqJaRaS/VA3nuFf1mgwa8ISRWFkBb2+eRnW23+ka2liemIHK7rv6x5CedF/nh8lLdb83p0sfj+KzkBzL8M5f1p1tqTm39d+m/lYVMf1T2tgGr/uJIo5J9UlMBImbd9USxEHUREOxIm14GOl0RnA3V2hSJtBPL1RXDUZPZiQKh+pp4GKyzuBkwZPD5U+G0fmJC8EFyg1tB+nHw0GMLtVNmm8jYB32duji6PCle348IkCIFuY+HbAqw8ca19wiG5ofndPc1Rcf1IjHkUIrFhjJRvOXn2eiZUoaacBACO5Zq6lf2G90dIePwsL7YXElImTzBCr8BLcadPddS0cdBqyuVQq0EjvLrHT+Yltkggco/kRIqZYyyBl7fPcLFLe1GwkuQt3YUItglCTaiKzLRh 1VkBkljU gAUufJHaW4OhrafLdIWabJNqgeL6MamnI8aQvVQ/WH3DcfAR3uRFk704BQ0eWo+5ZlBSxfvC2BzGqB2R+SkleuqmH4hrr5G06gv1QI9N3lvw2AJmR/Jc5coAN4XAS2z2Qe0jDYYIOP0F37qONArvozuj1yO6PKAkOiJDAvez+U3IIIc6z/u2vNhCwr1kjYOch6hJdLkPjwR9k7lgQ3Sz0hMpPnIwEs8IAGBMWVtkQO+rbz8Liul80MLV+Y+3ZDVhXXc0hATYtegya/96AjGN63iQ00lG6XYNE+3YQzNuCirEQfbA+9qF42z5GX/qrsIvk1NtjJWJBwIkT17fs6pWQ7iC60g== 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: Pankaj Raghav Page cache now has the ability to have a minimum order when allocating a folio which is a prerequisite to add support for block size > page size. Signed-off-by: Pankaj Raghav Signed-off-by: Luis Chamberlain Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_ialloc.c | 5 +++++ fs/xfs/libxfs/xfs_shared.h | 3 +++ fs/xfs/xfs_icache.c | 6 ++++-- fs/xfs/xfs_mount.c | 1 - fs/xfs/xfs_super.c | 10 ++-------- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index e5ac3e5430c4..60005feb0015 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -2975,6 +2975,11 @@ xfs_ialloc_setup_geometry( igeo->ialloc_align = mp->m_dalign; else igeo->ialloc_align = 0; + + if (mp->m_sb.sb_blocksize > PAGE_SIZE) + igeo->min_folio_order = mp->m_sb.sb_blocklog - PAGE_SHIFT; + else + igeo->min_folio_order = 0; } /* Compute the location of the root directory inode that is laid out by mkfs. */ diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h index dfd61fa8332e..7d3abd182322 100644 --- a/fs/xfs/libxfs/xfs_shared.h +++ b/fs/xfs/libxfs/xfs_shared.h @@ -229,6 +229,9 @@ struct xfs_ino_geometry { /* precomputed value for di_flags2 */ uint64_t new_diflags2; + /* minimum folio order of a page cache allocation */ + unsigned int min_folio_order; + }; #endif /* __XFS_SHARED_H__ */ diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 74f1812b03cb..a2629e00de41 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -89,7 +89,8 @@ xfs_inode_alloc( /* VFS doesn't initialise i_mode or i_state! */ VFS_I(ip)->i_mode = 0; VFS_I(ip)->i_state = 0; - mapping_set_large_folios(VFS_I(ip)->i_mapping); + mapping_set_folio_min_order(VFS_I(ip)->i_mapping, + M_IGEO(mp)->min_folio_order); XFS_STATS_INC(mp, vn_active); ASSERT(atomic_read(&ip->i_pincount) == 0); @@ -324,7 +325,8 @@ xfs_reinit_inode( inode->i_rdev = dev; inode->i_uid = uid; inode->i_gid = gid; - mapping_set_large_folios(inode->i_mapping); + mapping_set_folio_min_order(inode->i_mapping, + M_IGEO(mp)->min_folio_order); return error; } diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 56d71282972a..a451302aa258 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -131,7 +131,6 @@ xfs_sb_validate_fsb_count( xfs_sb_t *sbp, uint64_t nblocks) { - ASSERT(PAGE_SHIFT >= sbp->sb_blocklog); ASSERT(sbp->sb_blocklog >= BBSHIFT); uint64_t max_index; uint64_t max_bytes; diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index bce020374c5e..db3b82c2c381 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1623,16 +1623,10 @@ xfs_fs_fill_super( goto out_free_sb; } - /* - * Until this is fixed only page-sized or smaller data blocks work. - */ if (mp->m_sb.sb_blocksize > PAGE_SIZE) { xfs_warn(mp, - "File system with blocksize %d bytes. " - "Only pagesize (%ld) or less will currently work.", - mp->m_sb.sb_blocksize, PAGE_SIZE); - error = -ENOSYS; - goto out_free_sb; +"EXPERIMENTAL: Filesystem with Large Block Size (%d bytes) enabled.", + mp->m_sb.sb_blocksize); } /* Ensure this filesystem fits in the page cache limits */