From patchwork Wed Nov 2 16:10:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3821wru; Wed, 2 Nov 2022 09:11:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Z0NVT+m0L4yedi6CDdwNdnO9tOC8LtcdiqDlQpkW3xQ5iJGI5Z4JrFatv/ngR8fRCs8g8 X-Received: by 2002:a17:903:2447:b0:186:e200:6109 with SMTP id l7-20020a170903244700b00186e2006109mr25851495pls.104.1667405519167; Wed, 02 Nov 2022 09:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405519; cv=none; d=google.com; s=arc-20160816; b=d2QY+DiMdyU3ziPPGBvkqfhrYPA3MMJ/H3fi/VdgwXWGM7tDxnJDLANet0owPXwpBH CK3T2piyitwMcvHk8iJnW4STN2OZh8CbAmkFaISJENMl91Lqx54mD3+EL3OcxUaqHQwv xiKyCAp/4pNaX0XGOQ+7avD3yvOqWauNBrbfcqA2QdXM85adH0OZselcwqflP6HSSM0A H1h+8qEtrqOMu/UdgXNqH+BwFlpHlRscd/0/Jfos1tZDgyBy0b5cKrKOnCeHrPsiEnd/ NGUudf11kqquCEzP5twRkB3s+AUme+dqe23GcaaVPZPW4OR22mLfqx/wXjwGl8g5we9O 1vmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lbrAaY6idpkhBtxaaJGwUptujZ0EZql70PDCszR9xSI=; b=A2eDdfZ+1fbD+wdw/1L3Eekh0GBTAbQwE7HVqpJ4BAcf1Pcqc1NYSeyeYw8YnSqLpb eG8IAGY/E7sKodoN3i+N6gGBTf8nLKTwpiZXyY8ny6Oy+lnZzJaFeQp78ZC4xGHF2tcF GUVr1kFR0y9epFAI5LMJ/1593u8JrvscFJe/QNAVDeZtf91wC66sR1Dd85N7t4C+5UBD otPtkm154YZG1GiS9Tq2cpAUkBZinmOwYCfzylMu5uPTa/4IkPv0aZXZf+U/fcZFW/mU MFaedvgjf/4FfsZvPYTqYJXlZ/eLxLJMimPFgHH2CnRG1v6l562XckLq0083cq/qd622 YVpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b22oyujJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a170902e74c00b001782a6fbc7csi19217340plf.463.2022.11.02.09.11.40; Wed, 02 Nov 2022 09:11:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b22oyujJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbiKBQLS (ORCPT + 99 others); Wed, 2 Nov 2022 12:11:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231288AbiKBQLJ (ORCPT ); Wed, 2 Nov 2022 12:11:09 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 599DA2B1A4; Wed, 2 Nov 2022 09:11:09 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id 128so16663848pga.1; Wed, 02 Nov 2022 09:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lbrAaY6idpkhBtxaaJGwUptujZ0EZql70PDCszR9xSI=; b=b22oyujJhcmEnIoOWyXlmdwFsWtvDDEbrYWi+tTl/IKQZadCXIum/ufaWsfiuhgQWs P0ejMWAXsFFxmUJWgjcqRWL6iDvmTJOBHMdvrWNuXSDSGhujg7k49tnS+xBECZ0DDC1D QEeKOjhkuj2U1fYHa3KM1TSvYvE4FrIPOrf/CN/DjK2k7Ii76jHakZpfzft8GgAI2TOi 3dtL4HfeEfRRNgP7Mp0GAgu1ZDeKvnGqK9CY4nsrmEB3lEEy5PFMtwvBwHVV7JaSQ4Oc JqTTGwFIB+4o1Aa2ylRSznqsjRcz5BF5gANEbFRauGWLvr7/47QbInfDSn9b5QQsOYI/ 8XPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lbrAaY6idpkhBtxaaJGwUptujZ0EZql70PDCszR9xSI=; b=bZr6SYFBhkg2VMPqctbSETcwnfQl7anND/+vJLe0zdxMHOnOklnyfCxLdCly8B7WDB /JT/PmwbiTrND26z6HdJI6+4Kyn9h2gZICOkH5jmqLY4SwG1HVn8ffhEw2Xyp4C6Q8Z9 FDk5l/bVr0JdPA6T1Wg/UP3ftoieVLW9m8/xbxIlLBbqHYI4A+delvZNH7ZA8anuXLX3 C7PTnlqaHE9WqAe522eFeuqedReN6Z9+8V42oznMt/85JC2KchhRPbudbYEJ+vOZjFaO eJjYeQEPlCdsLH+PjnH3pKJWJneZuYlDfqjA5S1VsWV8OIWKJJ1PuSB6hJjYIrufDxqz BjLg== X-Gm-Message-State: ACrzQf0Hud1OdEkphoDf60hwbg9/iDjP6R0qU96/ZpL5U39kErGr4+hC ZhxNHn2Iojxd2IvFLpe/gIAF2fpiXae8uQ== X-Received: by 2002:a05:6a00:1253:b0:56d:8742:a9ff with SMTP id u19-20020a056a00125300b0056d8742a9ffmr15514058pfi.5.1667405468483; Wed, 02 Nov 2022 09:11:08 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:08 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Matthew Wilcox Subject: [PATCH v4 01/23] pagemap: Add filemap_grab_folio() Date: Wed, 2 Nov 2022 09:10:09 -0700 Message-Id: <20221102161031.5820-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401409504801967?= X-GMAIL-MSGID: =?utf-8?q?1748401409504801967?= Add function filemap_grab_folio() to grab a folio from the page cache. This function is meant to serve as a folio replacement for grab_cache_page, and is used to facilitate the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index bbccb4044222..74d87e37a142 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -547,6 +547,26 @@ static inline struct folio *filemap_lock_folio(struct address_space *mapping, return __filemap_get_folio(mapping, index, FGP_LOCK, 0); } +/** + * filemap_grab_folio - grab a folio from the page cache + * @mapping: The address space to search + * @index: The page index + * + * Looks up the page cache entry at @mapping & @index. If no folio is found, + * a new folio is created. The folio is locked, marked as accessed, and + * returned. + * + * Return: A found or created folio. NULL if no folio is found and failed to + * create a folio. + */ +static inline struct folio *filemap_grab_folio(struct address_space *mapping, + pgoff_t index) +{ + return __filemap_get_folio(mapping, index, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, + mapping_gfp_mask(mapping)); +} + /** * find_get_page - find and get a page reference * @mapping: the address_space to search From patchwork Wed Nov 2 16:10:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14330 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3828wru; Wed, 2 Nov 2022 09:12:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67s+xhi1lofIwnEc43cylqmiWaW63pizRM/WMJMT00jbDWTNp6qcyRpJf/exzbApCYQGs4 X-Received: by 2002:a17:90b:264e:b0:212:d06f:35ad with SMTP id pa14-20020a17090b264e00b00212d06f35admr27194124pjb.2.1667405520675; Wed, 02 Nov 2022 09:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405520; cv=none; d=google.com; s=arc-20160816; b=yS+1l+ajYTjsOtEv9iZ3D77nEGuffxsjdeXvvZbcF/RoBitl9LLMFazbaJ4OMdQj0w 7cd5mmOjOdrE1YYShKrYH0KGyRy6MiGxuoxkIHMoA32WC1TYOrAU3rar8KaCwFZKsZyu zvhSKM2OKqrjpAmBq6qOWs67m4zjhj86xwB2BjJGT6xUoWoGaGHZLgF+fZWCRu3AtGZv CYxApp4dB0XhI+QlOQu5HRFX3lKg2nEJyHbbR2BkrlhkcqbnpWYQaXqpldvGQqUzafD7 BpW1NgMEoBCPHoQQyn9w95m8algM1GeB3mV/igakkG1COtFZo53XsFCxz4Et8JdlFvHq P2zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ViGofEkX7yEcmkcXNm3flvqY1FjypmnwIzQ3h5+k6EI=; b=KVCd4v38nX7dh6+WEqVlLUzrqpuljZEMPYz9243W6YnTyaOWsGeezJlXKymm68z2od cGroaa/GwFIVXtTtb+tDq17n/1PZX1hkhTwtiM1l1D/4qn43OlTD1snHg48rHhmcol/o pbqLmpVnXxorXYD6wzybVG6+feQQ9GkWf5qdDLl9/E+VkOAyzRpCxTuasmdsZsP+zQMS ZRP4TM1a7uEg6x8URdxMB8lN4oZPTDh6j0lGGfUi6YfwGFayD4UPtuh58Y/UX7WE01ux USgILmR+z2aR/Cqzz3ikRKxVGsQ6iES9Pax6pL+0FT9Hj67MKesOtUHiVJ7NHQjnSS2+ Zm1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n1wMZVPJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f64-20020a636a43000000b0046f87a897b5si16092069pgc.776.2022.11.02.09.11.45; Wed, 02 Nov 2022 09:12:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n1wMZVPJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231366AbiKBQLX (ORCPT + 99 others); Wed, 2 Nov 2022 12:11:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbiKBQLL (ORCPT ); Wed, 2 Nov 2022 12:11:11 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFB862C660; Wed, 2 Nov 2022 09:11:10 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id q1-20020a17090a750100b002139ec1e999so2317701pjk.1; Wed, 02 Nov 2022 09:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ViGofEkX7yEcmkcXNm3flvqY1FjypmnwIzQ3h5+k6EI=; b=n1wMZVPJgGAZfgmD3ZkM/SCD642n1Mc4Zn6+qTmFZdbiwhyj7wS8pZ8SFI+liwrQ2r jRtU/zEufgYnUSRmaPQbqmHP5jt+qqrNY2eB+O1n3FUDftvsWT7jdtVrRY3CCZiGe3K8 A4WNFuGywv6YgnSjp3gkRLGNT2bhdMiVnpZ6tPSRX71fvkRoyEtYetGSXc69oJ1O1mWz KZNpeejY8S04w/0+Biv+H5A7Zb8g5E/3r8QLYAtAdy+fJFIPdJKL3md+xbL3oUEKqTZx /4olLVxViCwqQAaoUx8z7sEV7+rlEHas4BS4I6u0JIigVObca1ahPMhG3dFM4vj2Miz6 v6jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ViGofEkX7yEcmkcXNm3flvqY1FjypmnwIzQ3h5+k6EI=; b=aU80nxKEyEiUsQljEDiGIQl/CU980UZFaipwxsXMRVlmsnZuqkdSa7xabKuOaAZea7 zl4KZGQs0R8bKzCs81cijDbQHoYuVnYml0iMUlVnAu0GS62Kvy2buNSeNaYwXC0NioHC JAlUWF+XvJgPIN8nw0G6Inq56PbfISUxrfEBX5kiLKqNienurgE685jjgv/aAYo2GXMo Ro34fcOnKKXnQkRB7Pw14HlDHJaT2xQFFmm0O0B1e4ElcHUDzKqdRNT0bdm69FBwi0IP w/9HqR/R1er3hNKgazNelBwFsWKNHsoUm+0W8ubQsaBWpBcztMC5wA1XvszKTaF6zlDY WfCA== X-Gm-Message-State: ACrzQf1ewufpOXV5hJP1UjLZo9laJnyNu7B3mTgyfXCYf2hf2p9w9bEp gq2z8Xd9NqPyqUDjVTGX0zOGjNq8P0YKRQ== X-Received: by 2002:a17:90b:2248:b0:210:10dc:a314 with SMTP id hk8-20020a17090b224800b0021010dca314mr42536562pjb.15.1667405470077; Wed, 02 Nov 2022 09:11:10 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:09 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Matthew Wilcow Subject: [PATCH v4 02/23] filemap: Added filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:10 -0700 Message-Id: <20221102161031.5820-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401411035652261?= X-GMAIL-MSGID: =?utf-8?q?1748401411035652261?= This is the equivalent of find_get_pages_range_tag(), except for folios instead of pages. One noteable difference is filemap_get_folios_tag() does not take in a maximum pages argument. It instead tries to fill a folio batch and stops either once full (15 folios) or reaching the end of the search range. The new function supports large folios, the initial function did not since all callers don't use large folios. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcow (Oracle) --- include/linux/pagemap.h | 2 ++ mm/filemap.c | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 74d87e37a142..28275eecb949 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -740,6 +740,8 @@ unsigned filemap_get_folios(struct address_space *mapping, pgoff_t *start, pgoff_t end, struct folio_batch *fbatch); unsigned filemap_get_folios_contig(struct address_space *mapping, pgoff_t *start, pgoff_t end, struct folio_batch *fbatch); +unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, + pgoff_t end, xa_mark_t tag, struct folio_batch *fbatch); unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index, pgoff_t end, xa_mark_t tag, unsigned int nr_pages, struct page **pages); diff --git a/mm/filemap.c b/mm/filemap.c index 08341616ae7a..9be22672ce1a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2262,6 +2262,60 @@ unsigned filemap_get_folios_contig(struct address_space *mapping, } EXPORT_SYMBOL(filemap_get_folios_contig); +/** + * filemap_get_folios_tag - Get a batch of folios matching @tag + * @mapping: The address_space to search + * @start: The starting page index + * @end: The final page index (inclusive) + * @tag: The tag index + * @fbatch: The batch to fill + * + * Same as filemap_get_folios(), but only returning folios tagged with @tag. + * + * Return: The number of folios found. + * Also update @start to index the next folio for traversal. + */ +unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, + pgoff_t end, xa_mark_t tag, struct folio_batch *fbatch) +{ + XA_STATE(xas, &mapping->i_pages, *start); + struct folio *folio; + + rcu_read_lock(); + while ((folio = find_get_entry(&xas, end, tag)) != NULL) { + /* + * Shadow entries should never be tagged, but this iteration + * is lockless so there is a window for page reclaim to evict + * a page we saw tagged. Skip over it. + */ + if (xa_is_value(folio)) + continue; + if (!folio_batch_add(fbatch, folio)) { + unsigned long nr = folio_nr_pages(folio); + + if (folio_test_hugetlb(folio)) + nr = 1; + *start = folio->index + nr; + goto out; + } + } + /* + * We come here when there is no page beyond @end. We take care to not + * overflow the index @start as it confuses some of the callers. This + * breaks the iteration when there is a page at index -1 but that is + * already broke anyway. + */ + if (end == (pgoff_t)-1) + *start = (pgoff_t)-1; + else + *start = end + 1; +out: + rcu_read_unlock(); + + return folio_batch_count(fbatch); +} +EXPORT_SYMBOL(filemap_get_folios_tag); + /** * find_get_pages_range_tag - Find and return head pages matching @tag. * @mapping: the address_space to search From patchwork Wed Nov 2 16:10:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14333 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp4318wru; Wed, 2 Nov 2022 09:12:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74UIvkTzD8tELNrcn0Tak8Z2SlU8Z8B/pO1F1x9btWraRBpZz2gmksHBNVuhFbptvMRcrs X-Received: by 2002:aa7:c648:0:b0:461:d9b4:687e with SMTP id z8-20020aa7c648000000b00461d9b4687emr24965621edr.91.1667405579111; Wed, 02 Nov 2022 09:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405579; cv=none; d=google.com; s=arc-20160816; b=BeX370u/F9S9x0Co/1S/Pc/1SzpL4Pe868BUK9KNOsFNP/TGH5AYHWtTrfvQYpcrtj /p+MhBf0xWJrb4k3CjvVqrYYVa7Zk0PQalsEZ+hOuazFrfb+nrYAhDmC5QuDOZzunEyE oReYYQTR3qxYv9BsLoQC8IoFJswiqRFs2lXR/teCA+7RdlYFtZM9FHlxdgvKC1KmdD51 YOQMPacYkUvZMWG3/MVeN6qhobqEezPWaGiWMMlHDxPfkQLOb9RrM+lqfVs5d35269zy 2zoaKV9IzueJjwGnQgr5JeG+vXezXBu3kaJbrFrSaG8qU7hI1/IFDMN6qhPxH/3GXc9i Uz0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=D7ILOV7uCBW9G56cPuCyE+xwJ/LPVQUTk1i899caTl0=; b=pBakaibezRd9ctCWnr+x1yg0R4nuctqnaPZf23pQbfvhHoEcfbaX3Dp0USv8Ytj+LG cUmAU1fWRQ6ihzY5PV3jioJ5FRQhEAsmdgWru8OUQg/PlVaotjlMDsWkR+uduY6EA/IU fNOv2AR8FBlzagiHj9HEMdJ5jEOs9PJREcyngy2I+Ba9ICiCTzQbHRlcU1AtjOJiIkPN 4WY30Gh4FSbDJhJIcGboxcsAAx7LmpT34HQfjyKv7zuv6zjzjaZ8oJMCd5LPIgECytlm tXeZ31tbjF8AYbGGnw041THgfoMYR2wrIlK54L0YU81FS/IzczukuLZNR3uP+hX01wgT Oddg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WlFYPEeV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh12-20020a1709076e8c00b00783de095de7si16116559ejc.847.2022.11.02.09.12.35; Wed, 02 Nov 2022 09:12:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WlFYPEeV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231513AbiKBQLr (ORCPT + 99 others); Wed, 2 Nov 2022 12:11:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbiKBQLN (ORCPT ); Wed, 2 Nov 2022 12:11:13 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68B042CC8A; Wed, 2 Nov 2022 09:11:12 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d10so16819373pfh.6; Wed, 02 Nov 2022 09:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D7ILOV7uCBW9G56cPuCyE+xwJ/LPVQUTk1i899caTl0=; b=WlFYPEeV3wf0VfK6pqbhv5Egc4h8KVjel140fCaMDBK3FcDDdSMrAwC2RRkCV1yrTw g5UfIoUTA56HrpjtwUHlbxxIl2+2XVj36Necvjw2qtsGVhSk3MpYNUz5lqUeXoe9rcG+ rSIhTCQW2xVo9vVWdW8xlqvFvN174oq7e9hBFs8SL0eQTkE9h9BtGOiyq5hrX0X03ARZ +PjKQOimzK0w0ph8uxMDYryUYErs4i2YihTAv+8viAcID4R9rEgIXHWoL0tVB1NY/fCF Zz7LVoKY7ZVpgl83UNZSArBIZLGwCRqsreKwNZaIOWeZgiKqm4whhefGhGSMZzVBzGt+ R1hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D7ILOV7uCBW9G56cPuCyE+xwJ/LPVQUTk1i899caTl0=; b=buqyy+g7jRAOyFTqOIq4ETWySYeXVTw427m23k0YK4iJoCE/pwR0/jUxv47NgncKoT 1Lpme2krn43LJwMYTIzx5Z7xqUqY9zp4rCxPtJD263+q4aTMl/7fGRCPNKlPH/o8xEd6 SKcbgnkXQQms55EYrbyvuHxxIWZv6WuDr4ilYeXQHeg71aMYCtYABF2YigLwCOMXutmZ GOon3qAMerfyqBE0k4Y+enNUTMAb7Mcr3wGjtDw2a0ub7rCTDCZETXG3Baie3vHKsEua H4Ui6KlZvjT5iQcK2t5yOBi6iODEh6SQ9nfv3LVuOtst4ojEs7Rn6gOpu6N9/if7DlSm /hiw== X-Gm-Message-State: ACrzQf158A733GJDo3ojWlICd3DK5PHZ3dzRorGqjrTR/nhIivLCNEQN jTFtIHt6dpIZIcse9/BMUbs3e1bP8nmDfQ== X-Received: by 2002:a05:6a00:1a10:b0:56d:5266:56aa with SMTP id g16-20020a056a001a1000b0056d526656aamr19077451pfv.61.1667405471611; Wed, 02 Nov 2022 09:11:11 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:11 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Matthew Wilcow Subject: [PATCH v4 03/23] filemap: Convert __filemap_fdatawait_range() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:11 -0700 Message-Id: <20221102161031.5820-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401472492907605?= X-GMAIL-MSGID: =?utf-8?q?1748401472492907605?= Converted function to use folios. This is in preparation for the removal of find_get_pages_range_tag(). This change removes 2 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcow (Oracle) --- mm/filemap.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 9be22672ce1a..cc4be51eae5b 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -503,28 +503,30 @@ static void __filemap_fdatawait_range(struct address_space *mapping, { pgoff_t index = start_byte >> PAGE_SHIFT; pgoff_t end = end_byte >> PAGE_SHIFT; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + unsigned nr_folios; if (end_byte < start_byte) return; - pagevec_init(&pvec); + folio_batch_init(&fbatch); + while (index <= end) { unsigned i; - nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, - end, PAGECACHE_TAG_WRITEBACK); - if (!nr_pages) + nr_folios = filemap_get_folios_tag(mapping, &index, end, + PAGECACHE_TAG_WRITEBACK, &fbatch); + + if (!nr_folios) break; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; - wait_on_page_writeback(page); - ClearPageError(page); + folio_wait_writeback(folio); + folio_clear_error(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Wed Nov 2 16:10:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp4361wru; Wed, 2 Nov 2022 09:13:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7jtVus30UsDqDW9mUm1j3kfguFDvQJjRX5wMhnjUOJz1YuHv7tpr1j5wT1ioMdipRFZ7pI X-Received: by 2002:a05:6402:1d86:b0:457:e84:f0e with SMTP id dk6-20020a0564021d8600b004570e840f0emr25352880edb.241.1667405584080; Wed, 02 Nov 2022 09:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405584; cv=none; d=google.com; s=arc-20160816; b=Z6WtpwKaAuRJ8rXrChpb5vgwKfUYTccWgeGN/G1hC5o/KvN0TONfYp2q2UwUfIWgov 4FPgLryZGvuSt2R1uXG7tSUsKluXTOhesnu1jivRVcig171DKay1exMeEowTUuDmsJHD BTnfsLisfhzQIxB3HtMKPTSV16GH+v3XUY4AV15pPm5cBSpw07UVU7whAA+xdn09JB/x d/b1nLaMdzlnSqcE3Jn58YGv1idUjI7konA+pSlczNqCFAcsySza7vfYhYJiHRRHo1Cu KK5pmXswxa4wVq3Pn1gVVP3ab1qMlf561ggJmLC1LTtrVBw0WMSNgHYlvOSAN6k3hCT5 axzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UvlibGQjIurNf1opibXHL1DiqttY5CNVP0rYORWfAjI=; b=comRvzp1Hfh+AXDaLxFZRANbkygYpnF+Dk/Ce4obxNU4GCGAV/Z951B396PAbGMj3P TBqpV1PTwe/i9pM4CODGv9HilFIMdQORn+8Ms5dYq14wfQyva+YR6AT3+m4umvzmO/EK 4T2PPhIGk6XvyS2TgT6NM8DdlE9nPVPn3Be2Y2TZ+l++sau4fsn6ZLkwZ4rM60/DP1bh g2SGTfdmvok/Y5onoaG79GlJF2VcNbaT5dp9jDISyRZeM0nJN2wiLFAq1eb0ttpq5oLd L3B918Py3h7RYvckBYIih8I0NwxmqRtoJW6k1UziRoGvwUD8c3OHQql2/CIX/Eks0tFq j5WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Gia/2xQt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn15-20020a1709070d0f00b0078db70cc9b8si17970596ejc.606.2022.11.02.09.12.40; Wed, 02 Nov 2022 09:13:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Gia/2xQt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231527AbiKBQLv (ORCPT + 99 others); Wed, 2 Nov 2022 12:11:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231328AbiKBQLO (ORCPT ); Wed, 2 Nov 2022 12:11:14 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFA422CDCD; Wed, 2 Nov 2022 09:11:13 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id 4so17056307pli.0; Wed, 02 Nov 2022 09:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UvlibGQjIurNf1opibXHL1DiqttY5CNVP0rYORWfAjI=; b=Gia/2xQtP1i9ycPtinKOiQgjpYF1J9ACaFpAh075vwzsAAhLNjNjwXPx2+vTDRXHUZ bZE7LvXvcDHVHatbKpXZr47x9Hs9Q1h4xbF6TvxceMrMsSveweURXYIlV+R88gCZYv6h OGEJsEMDJZXdIqsZtg4BoAUnUIyyXd4KPqoF9+M3lG4fab9IdnhxaNtEY8oPI7ibVacD ytnjCKB0xNJmaRpuLXjDt8ASUH4+yIxaxOUP0/7p0CNQH+PRkBqmasgPL+jnoVzH3Fpb kUPkQn8no5XnSuKHBdcn1wPdHmAGeK2tyKCUjMCDEJu+yG2BBKFd+VDxMe7qKyNYVM+a EXOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UvlibGQjIurNf1opibXHL1DiqttY5CNVP0rYORWfAjI=; b=ZlQ4t5/QOZm+dHx+4xXW9AUNWcabo3i/IimAEKfav6I8nChDI17VLP0LyAF+AdiNAF zCPhT7NZj60GimamTR77OG+xnwVdib1XyDHu2w5g6Gz5HcK/2eqrb4fe5TN7Z+CNRTTS /coXbNElp0XMq9N/+YWePSGDYOMOgbh0S1JnDanEeMh8JM3UooejScUxAVOvlmbD6kYD Uo78Dh7Brwp07/7Sz03PSevMnzQyHnaIWXQQ3tF+QN0AtXPtAle+8JEOhQElo6b2QV/q 9FsRIXN5JMq8XkqKYktpqMPRXGweKEd3k8QQNlU19+yYG/a1VvJso6QEkJOv/e4J8u21 Z+7Q== X-Gm-Message-State: ACrzQf2jrMJ/zrmtgusgJl2qkrGd6Sa8J4vwpOvaGW9eo5QAeImu9pkL CYzjGwkjjBXN3z54n9iEeRNk1PqAvZYU5Q== X-Received: by 2002:a17:903:2cb:b0:171:4f0d:beb6 with SMTP id s11-20020a17090302cb00b001714f0dbeb6mr25037165plk.53.1667405473165; Wed, 02 Nov 2022 09:11:13 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:12 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Matthew Wilcow Subject: [PATCH v4 04/23] page-writeback: Convert write_cache_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:12 -0700 Message-Id: <20221102161031.5820-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401478009774714?= X-GMAIL-MSGID: =?utf-8?q?1748401478009774714?= Converted function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). This change removes 8 calls to compound_head(), and the function now supports large folios. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcow (Oracle) --- mm/page-writeback.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 7e9d8d857ecc..aeec8b196232 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2286,15 +2286,15 @@ int write_cache_pages(struct address_space *mapping, int ret = 0; int done = 0; int error; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; int range_whole = 0; xa_mark_t tag; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { index = mapping->writeback_index; /* prev offset */ end = -1; @@ -2314,17 +2314,18 @@ int write_cache_pages(struct address_space *mapping, while (!done && (index <= end)) { int i; - nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end, - tag); - if (nr_pages == 0) + nr_folios = filemap_get_folios_tag(mapping, &index, end, + tag, &fbatch); + + if (nr_folios == 0) break; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; - done_index = page->index; + done_index = folio->index; - lock_page(page); + folio_lock(folio); /* * Page truncated or invalidated. We can freely skip it @@ -2334,30 +2335,30 @@ int write_cache_pages(struct address_space *mapping, * even if there is now a new, dirty page at the same * pagecache address. */ - if (unlikely(page->mapping != mapping)) { + if (unlikely(folio->mapping != mapping)) { continue_unlock: - unlock_page(page); + folio_unlock(folio); continue; } - if (!PageDirty(page)) { + if (!folio_test_dirty(folio)) { /* someone wrote it for us */ goto continue_unlock; } - if (PageWriteback(page)) { + if (folio_test_writeback(folio)) { if (wbc->sync_mode != WB_SYNC_NONE) - wait_on_page_writeback(page); + folio_wait_writeback(folio); else goto continue_unlock; } - BUG_ON(PageWriteback(page)); - if (!clear_page_dirty_for_io(page)) + BUG_ON(folio_test_writeback(folio)); + if (!folio_clear_dirty_for_io(folio)) goto continue_unlock; trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); - error = (*writepage)(page, wbc, data); + error = writepage(&folio->page, wbc, data); if (unlikely(error)) { /* * Handle errors according to the type of @@ -2372,11 +2373,12 @@ int write_cache_pages(struct address_space *mapping, * the first error. */ if (error == AOP_WRITEPAGE_ACTIVATE) { - unlock_page(page); + folio_unlock(folio); error = 0; } else if (wbc->sync_mode != WB_SYNC_ALL) { ret = error; - done_index = page->index + 1; + done_index = folio->index + + folio_nr_pages(folio); done = 1; break; } @@ -2396,7 +2398,7 @@ int write_cache_pages(struct address_space *mapping, break; } } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } From patchwork Wed Nov 2 16:10:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14331 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp4216wru; Wed, 2 Nov 2022 09:12:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5A4YZpK47hxP9yDpEpr3LJXJOG5BIrnCOdD3WvRbWuqzUpl3xP7txNTqzMf+8Sobwmhcxm X-Received: by 2002:a17:907:608f:b0:78e:1b60:60e2 with SMTP id ht15-20020a170907608f00b0078e1b6060e2mr24961514ejc.382.1667405564936; Wed, 02 Nov 2022 09:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405564; cv=none; d=google.com; s=arc-20160816; b=1BysmWeGiqzuS1hwRMshiZM/i8mUpr6pGedRevgg2tJeViJcS0vMpu6ePqcRNJ2sxr /egLs3ANN0I8URrWlTGd1BS+7NC1Nzru1G1WfCOU7KAIko4oYDtW6gQS3G/0dIreDwd0 xoVE8YMi4+sdEOK7WDLmQMc0yuy9e0nfNMLR//SBA4NXVU98M4gTn8qR+CtvZs8CzMeZ 66sq/XpRdVpsbfIiwQRwqDdeLl5Fk1al1q8nuozMKyyUhuF5C8aT83eNPtYyomdF/x3p x1KROpBKYEnATFetJUm2sRmlThe3v0/UEr/W1GZ60xrDPhHrZV3YiXmwu/FFG34UatiX UkTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YTHpQKfAdnCJ3tKTn7AZCAQU2IaISjA9jjwi546elPg=; b=wgPWbkDe3v8Te6XVcBSyUd5884KbmTKQcdsF56FGN/RR2IVMz9k8p/zlOeWQHG20+k KbWSjz1VZ/cwoX6trirCZ/MHnTtzbbq3aADrdcQfBrb4RIlUbRoM01imJ68J14wFQeXB LezFJLYUSJN1bmGNr2OAC1SxSs92fniDdpwaCWYeDkM/G7TN6iAV5dYp8pJfK2Rjj4TZ 9FHrdpcxovHU8Mzzyt1VQm37wQIBQsylxsHEl41lP3U3r74XBR0/nVuGb7wyp0AYP3i8 4tZmDlJsjbVh5PsNqYxrGvMuV7cvEHTXNQvu6dUy5myUhuxlhwh5QJHiERNFgipOzZi9 wW0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gQ3c0LdS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k14-20020a170906a38e00b0077f3a9c58e2si11635324ejz.6.2022.11.02.09.12.20; Wed, 02 Nov 2022 09:12:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gQ3c0LdS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231467AbiKBQLk (ORCPT + 99 others); Wed, 2 Nov 2022 12:11:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231352AbiKBQLR (ORCPT ); Wed, 2 Nov 2022 12:11:17 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 319672C673; Wed, 2 Nov 2022 09:11:15 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id q1-20020a17090a750100b002139ec1e999so2317866pjk.1; Wed, 02 Nov 2022 09:11:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YTHpQKfAdnCJ3tKTn7AZCAQU2IaISjA9jjwi546elPg=; b=gQ3c0LdSBzFsK6fT4uYZJxPUXMrdMM/2nflC2cV7sYS3HEKaVakZmlZZyIEpcZLCrr azMVA0h0qEnPsHGSm1uNBpGCmLBetfTgOoRBq7HJ7OpluFtNBV6TRmNaUymXPL4NO53x lV7bQH7FkCayUIB1xUHmwk2uJBSE9FRd8QFcDG1446fcGXg2qwAnFc+AlpWK5Cx2HX0S xCa3bp5qXy30W+m2Z/irS788yBZSG1RzSQVRi5h5sfXIGSOxdwStdFlzSx8gSm/dxXkf XwSTeb0E/a4dtZhGU0fFLS5W23VlDnYw64tpG9lcaa2Y8R4gzUGbc7YB4qrZvGdJ5FAN uKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YTHpQKfAdnCJ3tKTn7AZCAQU2IaISjA9jjwi546elPg=; b=5kuXesB/ilhbx+DTt/Jf6SyrWgb2vH8lPx6SIF6h/D+fcSs2CCnwLblJd5FPfDEWVP Bnc/gKeGsqLLWAiGd/F1UO3xWBSXHX1d3ZYGaYg10QVCqMZUB1pqfWlSWd//c5niO6Bp Wq/97B73B5/jfKl8RDrss34FarUGSpDkV0HX5cvMNqyadicMlLM7+78pjpu5VPn/2lbn 4wFbeI7Z0s5siQ8azVwaTYRBonedO+tfDaCY3gqYPnAkdkjTr9dUBgK+5r2cybp9Gb8l K+uCI7rv2IzsCZnCYtK1q+FfC6izqcrgHnFFRPeQM6MPlgKd2mwYW2K5wo3QDkBAkB4W V/2A== X-Gm-Message-State: ACrzQf09vXB4QTxb44cE7IOjgO29zGj6kxsM9+Y5bjeEQOyiQA69Q92+ iuHEpewkjbuS0kkc6++gY4JQ3FSHhepuEQ== X-Received: by 2002:a17:90b:1bd2:b0:213:2d7:3162 with SMTP id oa18-20020a17090b1bd200b0021302d73162mr25853750pjb.91.1667405474612; Wed, 02 Nov 2022 09:11:14 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:14 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , David Howells Subject: [PATCH v4 05/23] afs: Convert afs_writepages_region() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:13 -0700 Message-Id: <20221102161031.5820-6-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401457561725685?= X-GMAIL-MSGID: =?utf-8?q?1748401457561725685?= Convert to use folios throughout. This function is in preparation to remove find_get_pages_range_tag(). Also modified this function to write the whole batch one at a time, rather than calling for a new set every single write. Signed-off-by: Vishal Moola (Oracle) Tested-by: David Howells --- fs/afs/write.c | 114 +++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 55 deletions(-) diff --git a/fs/afs/write.c b/fs/afs/write.c index 9ebdd36eaf2f..c17dbd82a38c 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -699,82 +699,86 @@ static int afs_writepages_region(struct address_space *mapping, loff_t start, loff_t end, loff_t *_next) { struct folio *folio; - struct page *head_page; + struct folio_batch fbatch; ssize_t ret; + unsigned int i; int n, skips = 0; _enter("%llx,%llx,", start, end); + folio_batch_init(&fbatch); do { pgoff_t index = start / PAGE_SIZE; - n = find_get_pages_range_tag(mapping, &index, end / PAGE_SIZE, - PAGECACHE_TAG_DIRTY, 1, &head_page); + n = filemap_get_folios_tag(mapping, &index, end / PAGE_SIZE, + PAGECACHE_TAG_DIRTY, &fbatch); + if (!n) break; + for (i = 0; i < n; i++) { + folio = fbatch.folios[i]; + start = folio_pos(folio); /* May regress with THPs */ - folio = page_folio(head_page); - start = folio_pos(folio); /* May regress with THPs */ - - _debug("wback %lx", folio_index(folio)); + _debug("wback %lx", folio_index(folio)); - /* At this point we hold neither the i_pages lock nor the - * page lock: the page may be truncated or invalidated - * (changing page->mapping to NULL), or even swizzled - * back from swapper_space to tmpfs file mapping - */ - if (wbc->sync_mode != WB_SYNC_NONE) { - ret = folio_lock_killable(folio); - if (ret < 0) { - folio_put(folio); - return ret; - } - } else { - if (!folio_trylock(folio)) { - folio_put(folio); - return 0; + /* At this point we hold neither the i_pages lock nor the + * page lock: the page may be truncated or invalidated + * (changing page->mapping to NULL), or even swizzled + * back from swapper_space to tmpfs file mapping + */ + if (wbc->sync_mode != WB_SYNC_NONE) { + ret = folio_lock_killable(folio); + if (ret < 0) { + folio_batch_release(&fbatch); + return ret; + } + } else { + if (!folio_trylock(folio)) + continue; } - } - if (folio_mapping(folio) != mapping || - !folio_test_dirty(folio)) { - start += folio_size(folio); - folio_unlock(folio); - folio_put(folio); - continue; - } + if (folio->mapping != mapping || + !folio_test_dirty(folio)) { + start += folio_size(folio); + folio_unlock(folio); + continue; + } - if (folio_test_writeback(folio) || - folio_test_fscache(folio)) { - folio_unlock(folio); - if (wbc->sync_mode != WB_SYNC_NONE) { - folio_wait_writeback(folio); + if (folio_test_writeback(folio) || + folio_test_fscache(folio)) { + folio_unlock(folio); + if (wbc->sync_mode != WB_SYNC_NONE) { + folio_wait_writeback(folio); #ifdef CONFIG_AFS_FSCACHE - folio_wait_fscache(folio); + folio_wait_fscache(folio); #endif - } else { - start += folio_size(folio); + } else { + start += folio_size(folio); + } + if (wbc->sync_mode == WB_SYNC_NONE) { + if (skips >= 5 || need_resched()) { + *_next = start; + _leave(" = 0 [%llx]", *_next); + return 0; + } + skips++; + } + continue; } - folio_put(folio); - if (wbc->sync_mode == WB_SYNC_NONE) { - if (skips >= 5 || need_resched()) - break; - skips++; + + if (!folio_clear_dirty_for_io(folio)) + BUG(); + ret = afs_write_back_from_locked_folio(mapping, wbc, + folio, start, end); + if (ret < 0) { + _leave(" = %zd", ret); + folio_batch_release(&fbatch); + return ret; } - continue; - } - if (!folio_clear_dirty_for_io(folio)) - BUG(); - ret = afs_write_back_from_locked_folio(mapping, wbc, folio, start, end); - folio_put(folio); - if (ret < 0) { - _leave(" = %zd", ret); - return ret; + start += ret; } - - start += ret; - + folio_batch_release(&fbatch); cond_resched(); } while (wbc->nr_to_write > 0); From patchwork Wed Nov 2 16:10:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14332 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp4217wru; Wed, 2 Nov 2022 09:12:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Z32AhvtIrXDsqOnPxbq5+sV41nmpSPLtJKU+QWfxYGePfyfu6psKt6WSFSJTyNWl0ThvW X-Received: by 2002:a17:906:8a4b:b0:7a7:3e17:7f91 with SMTP id gx11-20020a1709068a4b00b007a73e177f91mr24561303ejc.331.1667405565318; Wed, 02 Nov 2022 09:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405565; cv=none; d=google.com; s=arc-20160816; b=SjnJl/kyQdl+yA8IkLDRsUq6EkFa6jKqVHsHbHeVWzUqPw4G3J1s2h5GjKNLfkETgM NrY+MTqnxtzII7Yk1+2PUyM2iuEizQ24cB/wFQ3w8o/aWhx72kXkuOD1TxD2wyXYXhqY r7o7yiLdE4ktyOdUGuXVioj+3uA1Cs0eV4MAxAgCxr2+Q5Sm3sR7sHcfbylTiFsHSR8X KaB5cgq62t+dLaT8dhWvgvgw5kN8NX0F09fk+S13VPXST+1kGIItH93WJm2PMBNHtgwk xM3c7P2mHIRx1zLAQM1IstPJcKluCnqX/3IidBHJkivW3fkYjhiX5SQDPg+Aukivu9+o s7EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CScuk7r85wyu6F501iefg0DKwl3fyaI1fu4SBsbfBNk=; b=f9HnQMImnf3rIX5Z4gmvRz23U/H1nrGBLyCsJg2Cfza/aZq0V018aQbPfL/iXmI80s e5ItCiqzO/7DTeSv5NWa8DZcSkEEPbBvwO7ECfMRIK5/lYmFROr5Iq+dYK434zmGl18t egcQNfVjXy+c3mebihzuOO4VZ0a0JtGWq3LJNC1xxUriZZ0Ho5mT2E04hZ3/dFeMO/Ch 5DW7B1ouFtmWa6lAUbcAAi4b9NpC1JxU+g+L/nIZsiHpsLbFBSdHoeQoAhOfjBi5E8pQ R4Li4xpz/Use0rM0AA/DtHB0PmrotzWQvETv3O9CSYeobE60t7gW2Hng3EFLxQPYs6Lw L2oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=G1xj7WAm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk7-20020a1709077f8700b0077fc66b581esi16693502ejc.688.2022.11.02.09.12.20; Wed, 02 Nov 2022 09:12:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=G1xj7WAm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231482AbiKBQLo (ORCPT + 99 others); Wed, 2 Nov 2022 12:11:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231357AbiKBQLS (ORCPT ); Wed, 2 Nov 2022 12:11:18 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B059E2CCA8; Wed, 2 Nov 2022 09:11:16 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d10so16819592pfh.6; Wed, 02 Nov 2022 09:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CScuk7r85wyu6F501iefg0DKwl3fyaI1fu4SBsbfBNk=; b=G1xj7WAmIltNBsbLKuO9CkKEQ79pa0K47wkha3puJeaezV2/imAkDdcfm/KV23FIHU +KArDubzSRmx7FiH0l8qSZQuiZfGIGZFESde9F7GDr7BI0vnEKAz4OoG+/TLSnEP6lVV hEk3uS7L0RHCBIur0yh9N3EX0D7wiz8f/Tz1DOmo9UyRB6et4qwOzt9Nng+ZOsOpt5/H 9uNCUJ20VcSVqHMicFHHEq7ELqXYQFE7Mrb+NRFmYH88zfkz/DMkzuyMw0IDbt4InR+d u77NqmroP0vZczS44dmUtLli+wdv7QD3/rglQpmtqCu4rEb336yGk934JQ6ASFGIEHNx 5dKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CScuk7r85wyu6F501iefg0DKwl3fyaI1fu4SBsbfBNk=; b=rJJAI7mRb59zfjuTKxzctapCgjFwyOWjmC0VrNLX6wG0MKs6qvFXhCrUZd1bkl+1IW 8S7cGAMvkb1KWaqR4qlL+sAoGvq8/RLiXFxzT0GhqeYQlMyCbpy0BiY3tZLAluoPuabP sYZGbjrcDQScpDeLt71xZ1/OtG3Z76f1q2UfRZgnHTNA9XQyhnRWBVoCJAIr9OlcDj6t FJid/vnbgGA7hKPyEGFzTRr1eK4SDiXVzNczmyEIfG4WPuKih5jZh4l/i076S4UK/uMR Wz7yVRmT6ZSB2mIaJzoXTD3wtktUyWhLN41RxEyTj3HiOzbe27xxHZ0sMZn10goUcbj2 0q2Q== X-Gm-Message-State: ACrzQf0jLvmIa2KdaqFN8rldY9HrvRNLCpMQ66iAIxbkxVPi8nS4L+Yx 0zox3bECB3AclgbaDwdTanM6KB/22XRNPw== X-Received: by 2002:a63:4753:0:b0:462:b3f0:a984 with SMTP id w19-20020a634753000000b00462b3f0a984mr21859153pgk.501.1667405476022; Wed, 02 Nov 2022 09:11:16 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:15 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , David Sterba Subject: [PATCH v4 06/23] btrfs: Convert btree_write_cache_pages() to use filemap_get_folio_tag() Date: Wed, 2 Nov 2022 09:10:14 -0700 Message-Id: <20221102161031.5820-7-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401457868380022?= X-GMAIL-MSGID: =?utf-8?q?1748401457868380022?= Converted function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: David Sterba --- fs/btrfs/extent_io.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 4dcf22e051ff..9ae75db4d55e 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2960,14 +2960,14 @@ int btree_write_cache_pages(struct address_space *mapping, int ret = 0; int done = 0; int nr_to_write_done = 0; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + unsigned int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ int scanned = 0; xa_mark_t tag; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { index = mapping->writeback_index; /* Start from prev offset */ end = -1; @@ -2990,14 +2990,15 @@ int btree_write_cache_pages(struct address_space *mapping, if (wbc->sync_mode == WB_SYNC_ALL) tag_pages_for_writeback(mapping, index, end); while (!done && !nr_to_write_done && (index <= end) && - (nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end, - tag))) { + (nr_folios = filemap_get_folios_tag(mapping, &index, end, + tag, &fbatch))) { unsigned i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; - ret = submit_eb_page(page, wbc, &epd, &eb_context); + ret = submit_eb_page(&folio->page, wbc, &epd, + &eb_context); if (ret == 0) continue; if (ret < 0) { @@ -3012,7 +3013,7 @@ int btree_write_cache_pages(struct address_space *mapping, */ nr_to_write_done = wbc->nr_to_write <= 0; } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } if (!scanned && !done) { From patchwork Wed Nov 2 16:10:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14335 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp4420wru; Wed, 2 Nov 2022 09:13:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4s1LdWCPo7M6DhmCMupFSQd/Um+pmvUq8lWi0vD79ZBYD9H6aLWZLcDho6nCniVqPzPiWL X-Received: by 2002:a17:906:5dce:b0:78d:ec48:6a58 with SMTP id p14-20020a1709065dce00b0078dec486a58mr24609149ejv.209.1667405592842; Wed, 02 Nov 2022 09:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405592; cv=none; d=google.com; s=arc-20160816; b=GDgohmFYLVc09p7TiHDXkgHjQJ1S5Et9mpgqp2LOUP0Y0vsaRZ8goYv5dwxY+euMa0 GHwMuwK5TY0yLaKqbxsWrhyZgzT0c2wInJ138h7cTK93C72IaGzbmWxbpJ5uvieSx4bF 5vaMTZR6ivLR/1DevqSDY8OIx3Buvm+H3T5wA/ZJyUFxWPgtQ/4EWibSsJvqXPqaEbNh Dg5VA5TaSqhbX8BE/2VsnMlW7+q+JGoT/z7NdOUHfdN4ayMlGEMQHrjHBnbKIAAP2Jz7 X+dCLvcMHiiuqTAf7cgDVagKSv4TjPxa+qozyfVkRkvxHrbTTKWML2r7Eg37c3Z8ZjYF yH1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ihiS02r9sD2/Zs2Vx3FiURN5naIQGKMktV+WLRuKSks=; b=wzxO9TaUXCXqXqGb3L828NXtBUxAm3kkhNP1TLxOtuC+Io36rF7VBDfEdhBgenuiVd kh7MlrAX3sNgBv+OGhR18xJrfiEC5jTUbLaTTtiEZbREplxHqC4XXL9/79gENnXTisZ5 S98CGiLQmSKSXwiWiv8msoqd6hg09OIaUzOdbiiNMZaEAdhzzhFhx4V+rLu4osId4c49 IGNowCJBmV1qJq8jGCtgkMIHADPnYM2xcniqu+ceTb+2YzfL309vQEEaIZEbVyRwd7hd DuXxLAc5ol1kQZBg2yzN+vNg2IBYnzHe/7a3tuQo32aYwMf9gHCOJoYOKo/n9fATkxM4 HLcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SeLQ4Qu5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk37-20020a1709077fa500b0078d9be7f100si17847575ejc.852.2022.11.02.09.12.48; Wed, 02 Nov 2022 09:13:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SeLQ4Qu5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231732AbiKBQMV (ORCPT + 99 others); Wed, 2 Nov 2022 12:12:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbiKBQL1 (ORCPT ); Wed, 2 Nov 2022 12:11:27 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47BAA2C660; Wed, 2 Nov 2022 09:11:18 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id e129so16627748pgc.9; Wed, 02 Nov 2022 09:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ihiS02r9sD2/Zs2Vx3FiURN5naIQGKMktV+WLRuKSks=; b=SeLQ4Qu5//oXLNdBKVpytDwCWDO3I4G0YA52j5Knaxs6ot8nHTPxSvbYLibh2we7yp QOIy/yHsS5HNor/MIiz1/wjrknFzailQqLyUUDbncxkYbsgZJU/KhMzRQwgIl+QybVYC Rqmh80nwtQvOLrWqsNMA1En6NleAdRBSdgoag/eIey7KzBlGjcP3tZEj27YIEQECQyBF FiPgSN2IEHbjhKQ2oUVo+PWzz8cWJh20VFpEboEHH28rkzkyFMeuKzSfjD9ZDJNc3sQY DZllsnJTeZr1MOe9IOgxs+YIxX7s6esYPo/OjncN4dhR0FUlfGbp9Fqklf0gZ4+OOwoZ 8BhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ihiS02r9sD2/Zs2Vx3FiURN5naIQGKMktV+WLRuKSks=; b=GvL5GNBMw9NCEtzfUbGxfIuMzYqgsULeOjItTmoVxbYJiev25G3z9P5Pse7IwexFMw ZdtWK7IGz0hAQf8bkG1k2+NwejO2ikh99wMvI7ZrlEgZm0XGHJsaX09faIqCzKcrLlzu GovpBKN5tJ1wk3q7y1QGGNEzu/DMHiSt474YxkelWwimQtzuRb/SEju+GuXt2t5Pn4xO PK2B+xG02WY3+9eQ0YumNhemLComitvZVHAlIqpWBeuqY0JPJsXHqsOWEQ3+q9ao0S7u 9N/q+Si5TEX/FzgC11odnjz9IY/2IYCybKp9VS9W8gvDAX9jxH/35xMgt8sZtzdL4nm2 L2Aw== X-Gm-Message-State: ACrzQf1diDpmBGE0bMGpzDnBgGtnfNy2Fgl3CBpvkaaM7Ex9Yv9Xk4ym zDhRJMOTXyNf9h/DqwBtWszt/JHrHoOGvA== X-Received: by 2002:a05:6a00:a22:b0:54e:6a90:fbef with SMTP id p34-20020a056a000a2200b0054e6a90fbefmr25892086pfh.53.1667405477494; Wed, 02 Nov 2022 09:11:17 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:17 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , David Sterba Subject: [PATCH v4 07/23] btrfs: Convert extent_write_cache_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:15 -0700 Message-Id: <20221102161031.5820-8-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401486775256343?= X-GMAIL-MSGID: =?utf-8?q?1748401486775256343?= Converted function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Now also supports large folios. Signed-off-by: Vishal Moola (Oracle) Acked-by: David Sterba --- fs/btrfs/extent_io.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 9ae75db4d55e..983dde83ba93 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3088,8 +3088,8 @@ static int extent_write_cache_pages(struct address_space *mapping, int ret = 0; int done = 0; int nr_to_write_done = 0; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + unsigned int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; @@ -3109,7 +3109,7 @@ static int extent_write_cache_pages(struct address_space *mapping, if (!igrab(inode)) return 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { index = mapping->writeback_index; /* Start from prev offset */ end = -1; @@ -3147,14 +3147,14 @@ static int extent_write_cache_pages(struct address_space *mapping, tag_pages_for_writeback(mapping, index, end); done_index = index; while (!done && !nr_to_write_done && (index <= end) && - (nr_pages = pagevec_lookup_range_tag(&pvec, mapping, - &index, end, tag))) { + (nr_folios = filemap_get_folios_tag(mapping, &index, + end, tag, &fbatch))) { unsigned i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; - done_index = page->index + 1; + done_index = folio->index + folio_nr_pages(folio); /* * At this point we hold neither the i_pages lock nor * the page lock: the page may be truncated or @@ -3162,29 +3162,29 @@ static int extent_write_cache_pages(struct address_space *mapping, * or even swizzled back from swapper_space to * tmpfs file mapping */ - if (!trylock_page(page)) { + if (!folio_trylock(folio)) { submit_write_bio(epd, 0); - lock_page(page); + folio_lock(folio); } - if (unlikely(page->mapping != mapping)) { - unlock_page(page); + if (unlikely(folio->mapping != mapping)) { + folio_unlock(folio); continue; } if (wbc->sync_mode != WB_SYNC_NONE) { - if (PageWriteback(page)) + if (folio_test_writeback(folio)) submit_write_bio(epd, 0); - wait_on_page_writeback(page); + folio_wait_writeback(folio); } - if (PageWriteback(page) || - !clear_page_dirty_for_io(page)) { - unlock_page(page); + if (folio_test_writeback(folio) || + !folio_clear_dirty_for_io(folio)) { + folio_unlock(folio); continue; } - ret = __extent_writepage(page, wbc, epd); + ret = __extent_writepage(&folio->page, wbc, epd); if (ret < 0) { done = 1; break; @@ -3197,7 +3197,7 @@ static int extent_write_cache_pages(struct address_space *mapping, */ nr_to_write_done = wbc->nr_to_write <= 0; } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } if (!scanned && !done) { From patchwork Wed Nov 2 16:10:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14337 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp4684wru; Wed, 2 Nov 2022 09:13:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6fyatL9PpnDlOoVs6dNNnuhlK1zsPDDknFGaZFrHBVRZCajcL2E8cigNuulrqlX2KHEcdI X-Received: by 2002:a17:906:3406:b0:7ad:a8c3:585d with SMTP id c6-20020a170906340600b007ada8c3585dmr23741557ejb.573.1667405621537; Wed, 02 Nov 2022 09:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405621; cv=none; d=google.com; s=arc-20160816; b=Ge1M1EKJCqNnPJaEKk3+QTxaYwOIUZf5AxO96JbWdFH9GLcVQ0e1MDEZvgAi+hCGOS J6vy6MZg8pYRQwJsf0lQcy2tHywPwFNzxm/zp860tkW2GFDjRvUFjDHoUYAktK2NidyJ yMVnDfKK6wKjBMZsb/d4HrI3kQVF/THuoczKnIuSInrxbsn1RiyOyw0WJXzqBfKWNUYV hCeqI0g18FaCH2bzavTMf55o3SX4yYaPMgRonSiCf71Y+Xoa3ZJ2pgwStzXk93WWVrgh lLPtWfySWiDPZBdAiu1T0Ve1qE+/aOPgpm9W5RwPQJ83Ee3fNlC3tOzG4kaSwJ+SVUKh pdBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8a8+smKHCoqpDRc/IQj0ovDkCuBUSTOvIeDdDY+K4ig=; b=CgSDYZjVUpEHT1jn6TmJoi+fP8rkfXYRMDaw4pSCsucj9uknWidThSGkt3mfgCmc2F Z+qrOBmTKcdgKKfxKUJrAWj4dyfRNps5l7FO4IP6MPOV8fj5Fwl/Duz0mwFfeR0TL8CN cRFfAtM9UtfzY3/tYGebANTivPXKikBfOtdPDMUMb/AZOd8nTNz0QMUyQkuxciZJFypk tJgGJGvOiy9+NoVUaSNgh8G/iCMEmyW4EAyy7BX4zyDX2mFFZGJ7G1Ql4fP0pxCjKJyE ICa7V8U9N7Rdz0bK8e6ySHsdgx1CEo6G+8AlJPUmamjbyRp99o373ARpUBIqP2blqqBB Cxdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=g2BV7RNa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020aa7dbca000000b00461e63fe88fsi13050743edt.596.2022.11.02.09.13.11; Wed, 02 Nov 2022 09:13:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=g2BV7RNa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231787AbiKBQMg (ORCPT + 99 others); Wed, 2 Nov 2022 12:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbiKBQLa (ORCPT ); Wed, 2 Nov 2022 12:11:30 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 828202CDDD; Wed, 2 Nov 2022 09:11:19 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id p21so13159279plr.7; Wed, 02 Nov 2022 09:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8a8+smKHCoqpDRc/IQj0ovDkCuBUSTOvIeDdDY+K4ig=; b=g2BV7RNa287uRGJXaTiIIVA+hVR5jk23WAb5oSch87TqPTKliqdG6nz+TvKfJjQkWG wKwFiGSt2Rb1fl8eeNDFlkMtQOun4E0Gp7//G4HKGfUb3nk+G/4tSHVsMwQUdMvGOAs3 bX8lTwXqFogoudKAWmoKnMGrfcZTmnBWpzDYodcndNZUb6/dm0TMV023Fe43jCEkr7r5 Rk7e9/C8q6siu6DGaWKU8usxej+5hirj+dtoTubk2wobt1F6NAL1rswIeOZUZ4FLUvDE mSi2soPe8rx7EyvL4EOR7R78eiVnxuM8T8794ga/+RvsWTmIe4cpaJUb9HYaHpF6hnnU VRtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8a8+smKHCoqpDRc/IQj0ovDkCuBUSTOvIeDdDY+K4ig=; b=u7/8+QHwYzElwncXW1H8ZP+Gm9h9yLlNiTcbgPgC0YtB9hXnYtFTCOs1AQ3CcgQ9X2 UY9l0x7Mfx8MbLZqWlIiesOGm0QHXS/llO9xMZ0kh1kPtPp7/4clJrBKHRgBAmHmMnQr lBc2v/uxY3/2q3ZqgT0bQ/B6h299IgezNqpRWsRpJ8QrDIRV0Knt6JDZgp1Uh7Z+Tyrv b7lVFcOmy8JwcUCW3yul1zX+q+8rMS/3Fe5VGuDcYcXOtPS1FOguZlT6R7zVIzQzB3A7 hAqUZlMMDpwoDeYG/0ni+JMECuqM+vCjMAYMay3Yji1AKZMDZ/8X//UhYO7uKMF4hteE W/0w== X-Gm-Message-State: ACrzQf1b17lSmMbV4tvDLUpJAcGyNWSKVmDpk4A65E2LY1QaH9ujM6Mr peFgQBxCdVTnd7qlHU6A8P7FP2Aoks+1wA== X-Received: by 2002:a17:902:e80a:b0:187:3a52:d24e with SMTP id u10-20020a170902e80a00b001873a52d24emr8612509plg.171.1667405479107; Wed, 02 Nov 2022 09:11:19 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:18 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Jeff Layton Subject: [PATCH v4 08/23] ceph: Convert ceph_writepages_start() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:16 -0700 Message-Id: <20221102161031.5820-9-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401516774792429?= X-GMAIL-MSGID: =?utf-8?q?1748401516774792429?= Convert function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Also some minor renaming for consistency. Signed-off-by: Vishal Moola (Oracle) Acked-by: Jeff Layton --- fs/ceph/addr.c | 58 ++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index dcf701b05cc1..d2361d51db39 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -792,7 +792,7 @@ static int ceph_writepages_start(struct address_space *mapping, struct ceph_vino vino = ceph_vino(inode); pgoff_t index, start_index, end = -1; struct ceph_snap_context *snapc = NULL, *last_snapc = NULL, *pgsnapc; - struct pagevec pvec; + struct folio_batch fbatch; int rc = 0; unsigned int wsize = i_blocksize(inode); struct ceph_osd_request *req = NULL; @@ -821,7 +821,7 @@ static int ceph_writepages_start(struct address_space *mapping, if (fsc->mount_options->wsize < wsize) wsize = fsc->mount_options->wsize; - pagevec_init(&pvec); + folio_batch_init(&fbatch); start_index = wbc->range_cyclic ? mapping->writeback_index : 0; index = start_index; @@ -869,7 +869,7 @@ static int ceph_writepages_start(struct address_space *mapping, while (!done && index <= end) { int num_ops = 0, op_idx; - unsigned i, pvec_pages, max_pages, locked_pages = 0; + unsigned i, nr_folios, max_pages, locked_pages = 0; struct page **pages = NULL, **data_pages; struct page *page; pgoff_t strip_unit_end = 0; @@ -879,13 +879,13 @@ static int ceph_writepages_start(struct address_space *mapping, max_pages = wsize >> PAGE_SHIFT; get_more_pages: - pvec_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, - end, PAGECACHE_TAG_DIRTY); - dout("pagevec_lookup_range_tag got %d\n", pvec_pages); - if (!pvec_pages && !locked_pages) + nr_folios = filemap_get_folios_tag(mapping, &index, + end, PAGECACHE_TAG_DIRTY, &fbatch); + dout("pagevec_lookup_range_tag got %d\n", nr_folios); + if (!nr_folios && !locked_pages) break; - for (i = 0; i < pvec_pages && locked_pages < max_pages; i++) { - page = pvec.pages[i]; + for (i = 0; i < nr_folios && locked_pages < max_pages; i++) { + page = &fbatch.folios[i]->page; dout("? %p idx %lu\n", page, page->index); if (locked_pages == 0) lock_page(page); /* first page */ @@ -995,7 +995,7 @@ static int ceph_writepages_start(struct address_space *mapping, len = 0; } - /* note position of first page in pvec */ + /* note position of first page in fbatch */ dout("%p will write page %p idx %lu\n", inode, page, page->index); @@ -1005,30 +1005,30 @@ static int ceph_writepages_start(struct address_space *mapping, fsc->write_congested = true; pages[locked_pages++] = page; - pvec.pages[i] = NULL; + fbatch.folios[i] = NULL; len += thp_size(page); } /* did we get anything? */ if (!locked_pages) - goto release_pvec_pages; + goto release_folios; if (i) { unsigned j, n = 0; - /* shift unused page to beginning of pvec */ - for (j = 0; j < pvec_pages; j++) { - if (!pvec.pages[j]) + /* shift unused page to beginning of fbatch */ + for (j = 0; j < nr_folios; j++) { + if (!fbatch.folios[j]) continue; if (n < j) - pvec.pages[n] = pvec.pages[j]; + fbatch.folios[n] = fbatch.folios[j]; n++; } - pvec.nr = n; + fbatch.nr = n; - if (pvec_pages && i == pvec_pages && + if (nr_folios && i == nr_folios && locked_pages < max_pages) { - dout("reached end pvec, trying for more\n"); - pagevec_release(&pvec); + dout("reached end fbatch, trying for more\n"); + folio_batch_release(&fbatch); goto get_more_pages; } } @@ -1164,10 +1164,10 @@ static int ceph_writepages_start(struct address_space *mapping, if (wbc->nr_to_write <= 0 && wbc->sync_mode == WB_SYNC_NONE) done = true; -release_pvec_pages: - dout("pagevec_release on %d pages (%p)\n", (int)pvec.nr, - pvec.nr ? pvec.pages[0] : NULL); - pagevec_release(&pvec); +release_folios: + dout("folio_batch release on %d folios (%p)\n", (int)fbatch.nr, + fbatch.nr ? fbatch.folios[0] : NULL); + folio_batch_release(&fbatch); } if (should_loop && !done) { @@ -1184,15 +1184,17 @@ static int ceph_writepages_start(struct address_space *mapping, unsigned i, nr; index = 0; while ((index <= end) && - (nr = pagevec_lookup_tag(&pvec, mapping, &index, - PAGECACHE_TAG_WRITEBACK))) { + (nr = filemap_get_folios_tag(mapping, &index, + (pgoff_t)-1, + PAGECACHE_TAG_WRITEBACK, + &fbatch))) { for (i = 0; i < nr; i++) { - page = pvec.pages[i]; + page = &fbatch.folios[i]->page; if (page_snap_context(page) != snapc) continue; wait_on_page_writeback(page); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Wed Nov 2 16:10:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp4504wru; Wed, 2 Nov 2022 09:13:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5QOMTqEu8uUI6zrkiwoQXOWcP9RciRdWCPEvJxpbGGO/qFd/6N75z+Anyu4wPdQl99bJ2J X-Received: by 2002:a17:907:7e87:b0:78e:2dc3:945 with SMTP id qb7-20020a1709077e8700b0078e2dc30945mr25005766ejc.326.1667405602875; Wed, 02 Nov 2022 09:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405602; cv=none; d=google.com; s=arc-20160816; b=ePadBDqzc5DeDN54+pbzWL0lSzd5R6LnlbEgDB07cj6UGzEFy+cm6p0LbzDLTlt5Pd RYJ8arT4EIlvN6oopMOQfYQKdCZntWzhL656ICvRh/iZs+SXcqCxjA22KchrTKQY+O82 F42VxSMRjo7bmq6PSb9afq/eTdK+q6DJAgdwvDfs3wXEg0p4nd4f2mzYcDlgMaFAHgTp 8SqaIeZayV8vwyH20hgR3HGMbVdSiY5QNqOyunX9iQVrzfkmVGrwAe8IdU0XPyesKvac mh18fm9l5mcwcjRUChs6tiosJgZQZnhKU1ZkIcvBEwHgKMCw8sHNY3UjOb8K/PkltquH v+Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=K9oQGBma55+7a0HBQARXA8wNbnmnkmU7HtFBuB0SMcU=; b=do1KhU69jsN5uJqREV2GxMQUbgMePm12TFO4Lor2h+R/gRdo+L5qu+cO0SVw53HP2+ mH3lxJCsoC2v+Q7QeE/881Q+UErPZelvWiN1MOrzvjOe27/a4WzHxAMEeV4dtbbIlreB eulICQtV7kuYwx7cpr5EI94+7a0oBQhSGcg/+tD4jHA3r0dmadgm3uv1jZlHmokt0bGs 0HtF26fHDR2pUdbaIPGxg2IBeiqxbDAjFru2LAandzmQzSkyzkNaZSfqGA0pZC8WuEB4 OLqoSyXSlKiq/uuMy6bZORFjJCilb2rRML2KY7U9Q06EiOaTB6koM5694lsi2oxjdYbK k40A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lgRGvbBX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd14-20020a1709069b8e00b007ae10525573si192411ejc.671.2022.11.02.09.12.59; Wed, 02 Nov 2022 09:13:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lgRGvbBX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231755AbiKBQM1 (ORCPT + 99 others); Wed, 2 Nov 2022 12:12:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbiKBQLa (ORCPT ); Wed, 2 Nov 2022 12:11:30 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65B972CDDE; Wed, 2 Nov 2022 09:11:21 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id l6so16727794pjj.0; Wed, 02 Nov 2022 09:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K9oQGBma55+7a0HBQARXA8wNbnmnkmU7HtFBuB0SMcU=; b=lgRGvbBXfYuj04wlBtpVHwy2yZsFFIANJMcP3krdA79wzBh4OScTeSvjJg4lQ3GiI3 qzedQnIEursJo8Y8wrorW1k3nnG6uW/QS2vrVmIvXFZlg1i7O4HcsiQIkHBi6LqK3Hws /m7aEjRd4+lrOka8mBd7EHcq45xsSi/7s+3yt3h27vjVFT6859E+s3o4irrHvYyKTxlH 6KXijZ6dtNgWx/FcJ0jqINoyCdNdAJm6gC+OU2m4I7MMiT2P+IkB6xQggwX5UN9tdlUH oIy8W/ni9KIfG99ZHM5kVgqC7Om0fcn8SoY/XV7phYth7Ym2e9szQ6efXI8rxGZIQ5Qz 7ZSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K9oQGBma55+7a0HBQARXA8wNbnmnkmU7HtFBuB0SMcU=; b=MHHBZD8O7utpwysZd9uYPClYXcghq0sGBdtUDDIzwgvgu/q8LVeNH/Ic7M8D3mjxu6 9axXsIbC31xgrolgAlCGT79hvIatuwBNLg5/GxAyM8f0HU+QmRNBzSU7nNVmO32O5RGL xFh9fancZbOsXrOAoaxNzGuD1pYyylfwJCWZ68ePVtMA/UoLQX5PTh93qa9OBS+vcnAX 1IiZ95l7H1JB/qy9RuMKp7Jo0K8F6IlT6hKz/smx19oL+y1jmjFnGsCeMhPRkDZWS/rl CrjurPQraZ1SVzyoQaPTjnhfbLUvkVdT8eZxqIsaq7NeS1ffdhEfstNj5dt5T4lWyvi6 RPpg== X-Gm-Message-State: ACrzQf0Thlk5ZGu3rMb/VSCSY6cBXPiq56X0izXwvM990zbQeTe0RFCk wpvg3439EZDkTp9cc+8Y0McHU/enDGYaSw== X-Received: by 2002:a17:90a:3c8a:b0:213:8043:4b7f with SMTP id g10-20020a17090a3c8a00b0021380434b7fmr34554910pjc.99.1667405480651; Wed, 02 Nov 2022 09:11:20 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:20 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 09/23] cifs: Convert wdata_alloc_and_fillpages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:17 -0700 Message-Id: <20221102161031.5820-10-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401497531442324?= X-GMAIL-MSGID: =?utf-8?q?1748401497531442324?= This is in preparation for the removal of find_get_pages_range_tag(). Now also supports the use of large folios. Since tofind might be larger than the max number of folios in a folio_batch (15), we loop through filling in wdata->pages pulling more batches until we either reach tofind pages or run out of folios. This function may not return all pages in the last found folio before tofind pages are reached. Signed-off-by: Vishal Moola (Oracle) --- fs/cifs/file.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index f6ffee514c34..789fd0397cb4 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2520,14 +2520,40 @@ wdata_alloc_and_fillpages(pgoff_t tofind, struct address_space *mapping, unsigned int *found_pages) { struct cifs_writedata *wdata; - + struct folio_batch fbatch; + unsigned int i, idx, p, nr; wdata = cifs_writedata_alloc((unsigned int)tofind, cifs_writev_complete); if (!wdata) return NULL; - *found_pages = find_get_pages_range_tag(mapping, index, end, - PAGECACHE_TAG_DIRTY, tofind, wdata->pages); + folio_batch_init(&fbatch); + *found_pages = 0; + +again: + nr = filemap_get_folios_tag(mapping, index, end, + PAGECACHE_TAG_DIRTY, &fbatch); + if (!nr) + goto out; /* No dirty pages left in the range */ + + for (i = 0; i < nr; i++) { + struct folio *folio = fbatch.folios[i]; + + idx = 0; + p = folio_nr_pages(folio); +add_more: + wdata->pages[*found_pages] = folio_page(folio, idx); + folio_ref_inc(folio); + if (++*found_pages == tofind) { + folio_batch_release(&fbatch); + goto out; + } + if (++idx < p) + goto add_more; + } + folio_batch_release(&fbatch); + goto again; +out: return wdata; } From patchwork Wed Nov 2 16:10:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp5042wru; Wed, 2 Nov 2022 09:14:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6vgAIqe9yvcFP55luQ95IsQb5TVqKdJTZmLF7+/2JPF/2qvjisGQ069Ala4237nBwrxS3P X-Received: by 2002:a17:907:ea9:b0:7ad:de1f:9bf1 with SMTP id ho41-20020a1709070ea900b007adde1f9bf1mr14233379ejc.730.1667405659017; Wed, 02 Nov 2022 09:14:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405659; cv=none; d=google.com; s=arc-20160816; b=r2PU1i7zlNJxk4/bIxtvaEdQ8cj6BbmKIxEhXYKL2tuUpVGHACqeNbZyl7x7ZvTMn4 njQkrrGghCp5KfgT0VVV/597eZRJgPGiZ1WznkyAcWlFy0fNnFZ5AeNe7kODbNvmJDw0 qLFWR4bnbBFEznqjSS90s4Pv32g6BJyrzsn0vNrfWGj0g9hTo+Bzl1RJpZUE0XJ4AUqT Yreh/QsSTjQU/8vmt6/EV4b3lt08gHOJqFntRP4e5lJQHCNW2wmec8ivx6U3HBV3PvNv 8NmsqM1eYu2r4dFFqPKvddxmX4MkPHEprVyEU1aceQKWkTHzjIfhEqu9iVSmGSn2OglX C+ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kRHFvRATz/y8GqBUnd9mNnOud0frXSc+Rjf1hBP1wek=; b=nzZKR6ID66NnWdesTiJxXvMe6XSoa2wbnicJUUAntL9KZNLZiZkJJFnzUw8HEdXKCp 7f586AumO6/iJmBaybYz1mntA2bioPK0nFaCs8PZoru53naLIR8EKrepaF8ToZ3Wjz7X 8nCld4/ffoOPH92WCzF3lNNHHNgj/zYbTZNPEmpuR4NRrvwY9aEGjaoydd7NteR1FsQj xCpEua71pveiAgK2x2yIhMXYD5kaw2OnAzSYu3L08pNpspYFVUTHe6u/TXvvnpRQCAfN OYAkw516MsRL4AmYH0UamgxEnA3NdotrYzRSSYapPhIrUX36zkWVcpKX035Qj0MUkas3 hKww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d+XW6yxg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w7-20020a056402070700b00461f5bb2b79si14242570edx.458.2022.11.02.09.13.53; Wed, 02 Nov 2022 09:14:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d+XW6yxg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231504AbiKBQNA (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231410AbiKBQLa (ORCPT ); Wed, 2 Nov 2022 12:11:30 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 305482CC9F; Wed, 2 Nov 2022 09:11:23 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id h14so16689041pjv.4; Wed, 02 Nov 2022 09:11:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kRHFvRATz/y8GqBUnd9mNnOud0frXSc+Rjf1hBP1wek=; b=d+XW6yxgXUY/dmps54gO3wO2PqfF8X3sDq8smHylpJ6nIBM4zBsMHva2qm9I5LqFL2 QACM5WP55FNzn65wJVW4x0X2RQo6CyKMexU8FSBY8AG10ZNAulWmhqckyER1nkGiMspT ZqA37FmcbK1m4i2HkqGatmsrYga/1zR/iZHsdk5MofsLoef0pUwG1V2srcoch/HfEeq8 Y3DYJ4onfq8FUAsSEfM43oAaV9FZAb2zY7fgjbbPkp3CBRQ6fMxNaaP0LxQZ0KDfWacU QL/qfoVB6iYB21fApOEhxGO+DRiBPMI/3V1bJAvtZeXMX4jXPeFp8lCyOrD8PwuvfwWa euXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kRHFvRATz/y8GqBUnd9mNnOud0frXSc+Rjf1hBP1wek=; b=1PUFYcUREuLW4BDYiZkOddCNl+tJnM1lbEd1Isp76zMUwLB4ClSxJSfD1G/7O8IMvb EdJM7HWnkREhlNGwHx4QGHeUgDqHr0PWQSLJmDN9A+eEGEWUGTOIgpHTCoG9HoK57ru5 Zud1G1gYiGWC/MB21AXoR1ZoMqaAwJnbBPqvd5Y+W6V5xT/d5lOhkxp9zIYQzeArmlwd R5LnHTiNy5s+OI2HSCrXDO6JHOPP9qUsOMh3yT5naz1DafspYXwFMDA/i1fCz7wYcoKW D8I1b9eprnQh0/AEukQN38pRSPz/pFKKR1c+Byzd+N0vjqkQY4atWtJ9JNmggxOoEy59 B7SQ== X-Gm-Message-State: ACrzQf3P3QLbvQ2dS5gynuq1qP/pQdw3duYutznAh4DQLXjZPVwk1aZ3 2P/xbXkSLRr9I1widKppp9rm0ECVgGwrqA== X-Received: by 2002:a17:902:f786:b0:180:6f9e:23b with SMTP id q6-20020a170902f78600b001806f9e023bmr26013889pln.37.1667405482254; Wed, 02 Nov 2022 09:11:22 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:21 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 10/23] ext4: Convert mpage_prepare_extent_to_map() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:18 -0700 Message-Id: <20221102161031.5820-11-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401556417981888?= X-GMAIL-MSGID: =?utf-8?q?1748401556417981888?= Converted the function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). Now supports large folios. This change removes 10 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) --- fs/ext4/inode.c | 55 ++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 2b5ef1b64249..69a0708c8e87 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2572,8 +2572,8 @@ static int ext4_da_writepages_trans_blocks(struct inode *inode) static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) { struct address_space *mapping = mpd->inode->i_mapping; - struct pagevec pvec; - unsigned int nr_pages; + struct folio_batch fbatch; + unsigned int nr_folios; long left = mpd->wbc->nr_to_write; pgoff_t index = mpd->first_page; pgoff_t end = mpd->last_page; @@ -2587,18 +2587,17 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) tag = PAGECACHE_TAG_TOWRITE; else tag = PAGECACHE_TAG_DIRTY; - - pagevec_init(&pvec); + folio_batch_init(&fbatch); mpd->map.m_len = 0; mpd->next_page = index; while (index <= end) { - nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end, - tag); - if (nr_pages == 0) + nr_folios = filemap_get_folios_tag(mapping, &index, end, + tag, &fbatch); + if (nr_folios == 0) break; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; /* * Accumulated enough dirty pages? This doesn't apply @@ -2612,10 +2611,10 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) goto out; /* If we can't merge this page, we are done. */ - if (mpd->map.m_len > 0 && mpd->next_page != page->index) + if (mpd->map.m_len > 0 && mpd->next_page != folio->index) goto out; - lock_page(page); + folio_lock(folio); /* * If the page is no longer dirty, or its mapping no * longer corresponds to inode we are writing (which @@ -2623,16 +2622,16 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) * page is already under writeback and we are not doing * a data integrity writeback, skip the page */ - if (!PageDirty(page) || - (PageWriteback(page) && + if (!folio_test_dirty(folio) || + (folio_test_writeback(folio) && (mpd->wbc->sync_mode == WB_SYNC_NONE)) || - unlikely(page->mapping != mapping)) { - unlock_page(page); + unlikely(folio->mapping != mapping)) { + folio_unlock(folio); continue; } - wait_on_page_writeback(page); - BUG_ON(PageWriteback(page)); + folio_wait_writeback(folio); + BUG_ON(folio_test_writeback(folio)); /* * Should never happen but for buggy code in @@ -2643,33 +2642,33 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) * * [1] https://lore.kernel.org/linux-mm/20180103100430.GE4911@quack2.suse.cz */ - if (!page_has_buffers(page)) { - ext4_warning_inode(mpd->inode, "page %lu does not have buffers attached", page->index); - ClearPageDirty(page); - unlock_page(page); + if (!folio_buffers(folio)) { + ext4_warning_inode(mpd->inode, "page %lu does not have buffers attached", folio->index); + folio_clear_dirty(folio); + folio_unlock(folio); continue; } if (mpd->map.m_len == 0) - mpd->first_page = page->index; - mpd->next_page = page->index + 1; + mpd->first_page = folio->index; + mpd->next_page = folio->index + folio_nr_pages(folio); /* Add all dirty buffers to mpd */ - lblk = ((ext4_lblk_t)page->index) << + lblk = ((ext4_lblk_t)folio->index) << (PAGE_SHIFT - blkbits); - head = page_buffers(page); + head = folio_buffers(folio); err = mpage_process_page_bufs(mpd, head, head, lblk); if (err <= 0) goto out; err = 0; - left--; + left -= folio_nr_pages(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } mpd->scanned_until_end = 1; return 0; out: - pagevec_release(&pvec); + folio_batch_release(&fbatch); return err; } From patchwork Wed Nov 2 16:10:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp4898wru; Wed, 2 Nov 2022 09:14:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4OMgNb8oEECcErXw3uR9JIHEgmZEZdmiamab/39SJynFc7ODWGfWxEPTR0y22jpdCBKZ5Y X-Received: by 2002:a17:906:7212:b0:7ad:bd4b:c41f with SMTP id m18-20020a170906721200b007adbd4bc41fmr20990459ejk.659.1667405644838; Wed, 02 Nov 2022 09:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405644; cv=none; d=google.com; s=arc-20160816; b=yXu5aAeMXFuicxVyLoHEW1ArD2A2PYg3FdX/SBFXxA2k4n/ovhSXm11wFh+yrtCbbg Y2lJ4O4Z8hLDBMlYfooKk4jKPxIH0qMUjDSaBrCMnROAXZc28M8MEl8hiusanNHszQUG zOoliIrxdbY5OAF4xArO5ZwchQLGuGuSaplH5QVP8ZlxR8Sxu/NRfr4DwsXIsKhoQzBD Hzx2puzG31J79ZUq8KZojKyB6snUf2QTv1r087B1gtDStTNWUDSoS2vKNZWAKaiibTly YjSx+a1lLrLsGvzr1MFNcsNLpmQITxISI77GkJV8CqifNUPXpiNiERSdISNi74yghVYN 2JzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Xu3slT1mXNSkpn8qwZYtvOZ6o4Mg9MvjQ46v3hYxERk=; b=QhsWVfd5tBghz3nD38k20Q+yFv5kR29Sp3MXsnBLJZUnja8fI4dVvvE25XNyV0UMry 2gfh0qZjMPVXjRnJPft7o+PGnF5xpJknJG26MI99uiQ41osU5olbzA8/gUuEFYBnAucu 3olkRS+tx5UAuiKiFp/ulOXEoRLchKcq+ft2bnZZ+NEp5+kI2oM6iG5xHBtCEydHQdLz GHdTllRhJMW09+uzhYcvuWHRSg85kerr3myn1y+l0boriBxDP4JJ30VzWOyNpRo8i/FW hCg2HYtCtLUKcC5uzqa6ZdNm0npha44b+wK+97Zdf9KoNfY4Sro6Axp7W7a/SRbJUzgN 9O8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PjiE5RDJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he12-20020a1709073d8c00b0078dcd448f97si17985595ejc.801.2022.11.02.09.13.37; Wed, 02 Nov 2022 09:14:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PjiE5RDJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231889AbiKBQMu (ORCPT + 99 others); Wed, 2 Nov 2022 12:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231419AbiKBQLa (ORCPT ); Wed, 2 Nov 2022 12:11:30 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68FAD2CDD7; Wed, 2 Nov 2022 09:11:24 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id l6so16727947pjj.0; Wed, 02 Nov 2022 09:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xu3slT1mXNSkpn8qwZYtvOZ6o4Mg9MvjQ46v3hYxERk=; b=PjiE5RDJ/IhYcpSdkRRACJ+kB6nieGFRihYA8FJAb8afHr//PYuLhKMedJ3nWsns4m WHHZ7o+B5kW/fEmrnRCfh1hKfAzAMYSiot+Tf/JsHplhr3y+1cIneR2pnNTm0Xu0G5/m eXGrJg3NPWw15lzsyaW8TPQOvC7voLcYyraNuBkGyVFr9BgKbhi8dJn3bhWNj61g20i8 HxoYlQ9BOFdM1wk4SoRmch2ZbfqT7e1EAK8uxuBGxdgsBMcHv1a+OFX50FwbjOGyxYjS TKmeuA3P8SPD1RJ2IqePqBoSh63VQ7QpSMtxtOjPS+T3FcYMe+l8npdlhpiu0xfcFt+6 AsZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xu3slT1mXNSkpn8qwZYtvOZ6o4Mg9MvjQ46v3hYxERk=; b=rKBTf7MVM1O3Bb1OklQ3Px646GqxBo0IZtCD+dMBxqvZcyNcIUDUIM5Y2Rio+y6oEb DFeqpAC2dttU+GRn+4KfZ34/YT17SGAD9li239PHL+t29RP0AtZGTDBonDUJdEJ7z+TJ p7a5xGDpb9HRdFEDeJwPbEzlXoS9vnYqNGp2RtYlAfk3lsxu6TIydf6SV56rlZVOCplT BdYv5SHEjF8bmoosxTrO+8RhNKzusQa7dptC5CV3OZSE5u7pYZcHlmaBFSYJY0eUxliZ gO7RkgyWy1bKNCu1UZY0pKiJN9LtZbjbJQ7jmYU857jiJlo2ZpRCjghkDe5E/BBexbI0 9nHg== X-Gm-Message-State: ACrzQf2YwgiclNPsXIe9Ak+cHkJlNMXF5zvPQT9aEGJh6AhWLPWwyMlF rIHfPRWKByLrDp6S9w1l2cx41ctKyLZPZA== X-Received: by 2002:a17:90a:c918:b0:213:f5ea:5a60 with SMTP id v24-20020a17090ac91800b00213f5ea5a60mr14026872pjt.167.1667405483870; Wed, 02 Nov 2022 09:11:23 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:23 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Chao Yu Subject: [PATCH v4 11/23] f2fs: Convert f2fs_fsync_node_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:19 -0700 Message-Id: <20221102161031.5820-12-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401541531581434?= X-GMAIL-MSGID: =?utf-8?q?1748401541531581434?= Convert function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/node.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 983572f23896..e8b72336c096 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1728,12 +1728,12 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, unsigned int *seq_id) { pgoff_t index; - struct pagevec pvec; + struct folio_batch fbatch; int ret = 0; struct page *last_page = NULL; bool marked = false; nid_t ino = inode->i_ino; - int nr_pages; + int nr_folios; int nwritten = 0; if (atomic) { @@ -1742,20 +1742,21 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, return PTR_ERR_OR_ZERO(last_page); } retry: - pagevec_init(&pvec); + folio_batch_init(&fbatch); index = 0; - while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index, - PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &index, + (pgoff_t)-1, PAGECACHE_TAG_DIRTY, + &fbatch))) { int i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct page *page = &fbatch.folios[i]->page; bool submitted = false; if (unlikely(f2fs_cp_error(sbi))) { f2fs_put_page(last_page, 0); - pagevec_release(&pvec); + folio_batch_release(&fbatch); ret = -EIO; goto out; } @@ -1821,7 +1822,7 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, break; } } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); if (ret || marked) From patchwork Wed Nov 2 16:10:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp5041wru; Wed, 2 Nov 2022 09:14:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM47lY4VdPsTurYX81z7KwSD6gcQsvdbVTsRKplZDDoAteGpSLsk9saj/kDxDXB33DxOC5Ga X-Received: by 2002:aa7:df94:0:b0:461:aff8:d3e1 with SMTP id b20-20020aa7df94000000b00461aff8d3e1mr25695291edy.10.1667405658818; Wed, 02 Nov 2022 09:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405658; cv=none; d=google.com; s=arc-20160816; b=tBXsb/J+37wLbvIXx+rX/AwVZbDL57GsgtLQmSayKl395Baq5tm5s35sQh65leOeYf gvQk2miuwTOywDbEQZWDRe9WnNWpA68qA6qgKxF2BXqK7Iq2lUQP8PqTFcUExqr3FUkz 2l+gWuBitA9Fqsw+YD49fUFbvc7n6ZbdbX4S+NfAsH0imsbs+fh6cIv4h02v4YfCrCnB XQlD+jCA4UjU0Q8Vnp9u8dw1G4UZ/kYQEakIKc4V4uLbcUeTitKmV7TUqiu4LvF50aSw sKEZOUK64BBJMOaBD+BcelI8LIyEXmueNyG0wMaUPxNdBLMUzT8zRM+ZYyNSdJYrzaME hVrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CuuU7Td+QUT919J1WnVrpHag/XTS8dO5J3B4LUD/nEI=; b=jqRFiMwd2HVgGb1fiV/on6HTmCXYatMVk6zeFmeTXCxYJf+u8/xo3VFc52QIWK4PvY YuVpZTYrqDgh0nua0Ze3dWKwKdnmJrvlKTxTIatbs0GQzjHXiaw6aPRTNE9znk3jt7s+ BVWZgbmVDAS6xkc8znOEWda07YJdNRrEejSGYr8a5WVzcdg5JwfhFZyc+/s3w7FIxcSk FZIu8KRxhsHr9aNudPfU7jAE4ri10QcpWnctNOsdS3BlmOCAxQ4cesLALJ1uhvdS8A7V l4qZ4PKT3qeKwh4ARBNb1y3t3+OrBVJCMyXlhUH8ZegyuHIKkADv2AxPkuE43xO4sN4q 16JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=k4sYgtCT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a50eac1000000b00457263f9ee0si14971073edp.93.2022.11.02.09.13.52; Wed, 02 Nov 2022 09:14:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=k4sYgtCT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231853AbiKBQMq (ORCPT + 99 others); Wed, 2 Nov 2022 12:12:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbiKBQLk (ORCPT ); Wed, 2 Nov 2022 12:11:40 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E8A12CDE0; Wed, 2 Nov 2022 09:11:26 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id h14so16689164pjv.4; Wed, 02 Nov 2022 09:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CuuU7Td+QUT919J1WnVrpHag/XTS8dO5J3B4LUD/nEI=; b=k4sYgtCTlKF9O5eHoAATqGO6DkAOPOB+/zWzhHb+mqOGd3qF7SgoAaKFi4lLVBsht/ 0a+GahnwrfYgcXzfcqjQMfMejC34Q/m1r6UggkT5/y5BwoQUSM/Inh109I0qpOE7qiZG VHSWVTYivN2nm8doYDi4kZvX7E+qWkNiB9Lrdy/A6STUjeM0jj3okY+N0rjKA3OWtndC 3sSdr2MVpV/CijFouW4jnz6JBqF5pTNSy78wF6PfERj1jNxM0lNUypdxS+HdwVF2Q1pa vL090y+jlC31ftR9kmfoc3DT021w95uO172fFY0HeNWUC0D/N2SjsKb0ohMgGDNyRVN7 /kgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CuuU7Td+QUT919J1WnVrpHag/XTS8dO5J3B4LUD/nEI=; b=xmRApXpDGjayygp1QTQkoVCW5Mirxxcsx1G4TBsjpOLa8Ti25mrtO8hFcL6GOzF9Ck Vik//oIKqqswe/LavxKoeakpCXejCJtsWxe2l1ZSqiqsfwDA4NTTBn8O7X8QdYfsAKee ALbOqQUiT4iacoqNqFHze68d5xaBTfqKsZZ8Kfr/RsYobCHMvvtli53X5Qjt3Te+tLxE TaPv3B3TUYmRXb12XlmUO8cLBitz3tk9ayX65UFeAc8sh0io4ZCG0TNlxhjMM/YkJpkP O37zk5H7FH2oNQ0sG6JLxMNgfHVJ3hidDWusdmVR6nRQP/KN8kl8zFAsrdtP+WpHNUUO J7BA== X-Gm-Message-State: ACrzQf3OaAkKOZuRyuwZ2Gr7NUaQ00Ms4b66859ji+ilLETflqjvOOEm ratp7Q3fglj/Z5JbNER7moqt3Lq5JFW8fA== X-Received: by 2002:a17:902:aa02:b0:186:9395:4e82 with SMTP id be2-20020a170902aa0200b0018693954e82mr26138278plb.5.1667405485482; Wed, 02 Nov 2022 09:11:25 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:25 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Chao Yu Subject: [PATCH v4 12/23] f2fs: Convert f2fs_flush_inline_data() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:20 -0700 Message-Id: <20221102161031.5820-13-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401556079737387?= X-GMAIL-MSGID: =?utf-8?q?1748401556079737387?= Convert function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/node.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index e8b72336c096..a2f477cc48c7 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1887,17 +1887,18 @@ static bool flush_dirty_inode(struct page *page) void f2fs_flush_inline_data(struct f2fs_sb_info *sbi) { pgoff_t index = 0; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + int nr_folios; - pagevec_init(&pvec); + folio_batch_init(&fbatch); - while ((nr_pages = pagevec_lookup_tag(&pvec, - NODE_MAPPING(sbi), &index, PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &index, + (pgoff_t)-1, PAGECACHE_TAG_DIRTY, + &fbatch))) { int i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct page *page = &fbatch.folios[i]->page; if (!IS_DNODE(page)) continue; @@ -1924,7 +1925,7 @@ void f2fs_flush_inline_data(struct f2fs_sb_info *sbi) } unlock_page(page); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Wed Nov 2 16:10:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14341 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp5378wru; Wed, 2 Nov 2022 09:15:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+R7/s+PYdUTAIUtEZqHgUz0o1E8SQZOabKbqkNK3qZo05QL6pDX7Vc3wpA+wiqDLYSKhZ X-Received: by 2002:a17:906:7314:b0:791:a45a:bc84 with SMTP id di20-20020a170906731400b00791a45abc84mr24293790ejc.394.1667405701631; Wed, 02 Nov 2022 09:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405701; cv=none; d=google.com; s=arc-20160816; b=hd/fx4L4M3imkEtOh3fUXdmZ4vlgL6bCpVQ9ckPEBEP5QNIzktGI86Re2ABGEg9BFI 0aCgwuYt5SLnh1DDOu+e8WFhp+gxb3wn2OcaC4YOfTi3aluv606fbfLM5gHjY6prsskF +jxYB3LlAPfO73AI9Xq0FpjJYGDMHLzG8uJ2+lz154Na3NaaHogX+YPFdN9bh8pKMAOs lP5LdCKhm/2i0eO3wFY6bMtHfxUMi7Pf+VBkdJZspPDWEjkeN1UgXU0jjDfk0mSUrvhF skFaxpY4XPk1/tULBfUm3GMGWERGRc4kqIF8xdmIgaKs0/golFcXvPg+WKAe9BBOcBSX wiKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FlCTXZScWdlX0aVFB5ZBh3WOEeZ8Gy5thYVDo4sECVo=; b=Jb9lvtwSEZcWdblsYPsxT/Q40ECzzHzmPc2TVlLDa+VnijENUCO5ZbC1pR3f7tqEqS t/YRHTBp0I2raC7jlu1wB+NNWg9gJSld4K4+WpDEqxhcPXHQO8IOSntIRyhPEv+gM6Cm 8PsCVgMfYZHroKqmjYXUwutxT7mJ+mSt50MxYKIdBqP6qNYCqP8on3/x0NrWhKmtlOCF MuwxqmbROAqQoFupMUyVLc69Fybb0VHklBKL7oedvC8itHNCVjGkiRECAbFYtOZa5JNE DzCiLuQW4MJIFRUhmuMjse2oYyU4rAZrb/LrNmoxGdMiyF3m5l84X8nKTuiLN9sU6GOl AyPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Poe9rdZU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i19-20020a0564020f1300b00461237816efsi15869399eda.120.2022.11.02.09.14.36; Wed, 02 Nov 2022 09:15:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Poe9rdZU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231910AbiKBQNF (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbiKBQLl (ORCPT ); Wed, 2 Nov 2022 12:11:41 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBE0D2CCB4; Wed, 2 Nov 2022 09:11:27 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id b62so6262383pgc.0; Wed, 02 Nov 2022 09:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FlCTXZScWdlX0aVFB5ZBh3WOEeZ8Gy5thYVDo4sECVo=; b=Poe9rdZUsWmbLff7Q1y+73uQ67NvWbfBoZzK/+dTQlX7qeN0LjEz/N/rBuja3dj4uQ V58XNqhmnAdXT/u5YYVAqWdQcM7IpZGzdPiS7WJ/SuI2UpsvG2jJQJ+QAjUVQ7//El8f fQS1kK8H9mty21sekVYBC67x1RIEUTD3q3zpcHhzYIZ7P8X4Gbv+aZIdKeXKk4H9Em2r Lzi0RsgndfKDM+rr+KiKcBf1rF+xpOLsZp5o+CS+hW7qQC1gAlW/yAz9e7GEL5+HY1Ox 2g2BT9bK3F21AxzoWn7zFoPz5OORdwHo0wvIqeyqfrg05E/t6JECV9fE6vKrC2SiNIWT MocA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FlCTXZScWdlX0aVFB5ZBh3WOEeZ8Gy5thYVDo4sECVo=; b=v3M9PSO+Ge6tlLgNG+JUQotDSO/41N25NkSrpbBHxGYZeSMjaJNGFdXfNq7OzWi6YW U5H1/qS3FXstmZhXl974kGMGlJhtXLcZtePo5Nah6qPaj9qP7+4VM2DcZW+xJAgNzn5P 6n8PTgao1xwWwMyr1Ibu0hExgKdFjG5M49RzgWyPnBdKjw7A9oxQwRXqRo4OFclOunMd 2+CW2gTBv4GnzGYJObgb0UFh4D+92ZaM+o935LVCiGB2IsT/Hdb5UY17zZRH7uweHWHW osM5DXMmhv9e61SddtPPf3Y3jaKXSYeNoU8ZJ4z1v27gueCc+VtC9fyz3DeckgJLLywk sLog== X-Gm-Message-State: ACrzQf0NhQa4CUXB5ElcgmUNfJBPT4TRruMM9YovjZDx8NHD8k6nRQNU IgwcTZxlIADkYMD8sFldhEwEjQCQr5ovog== X-Received: by 2002:a05:6a00:b47:b0:56d:5266:464c with SMTP id p7-20020a056a000b4700b0056d5266464cmr18973688pfo.2.1667405486894; Wed, 02 Nov 2022 09:11:26 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:26 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Chao Yu Subject: [PATCH v4 13/23] f2fs: Convert f2fs_sync_node_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:21 -0700 Message-Id: <20221102161031.5820-14-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401600860092078?= X-GMAIL-MSGID: =?utf-8?q?1748401600860092078?= Convert function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/node.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index a2f477cc48c7..38f32b4d61dc 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1935,23 +1935,24 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi, bool do_balance, enum iostat_type io_type) { pgoff_t index; - struct pagevec pvec; + struct folio_batch fbatch; int step = 0; int nwritten = 0; int ret = 0; - int nr_pages, done = 0; + int nr_folios, done = 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); next_step: index = 0; - while (!done && (nr_pages = pagevec_lookup_tag(&pvec, - NODE_MAPPING(sbi), &index, PAGECACHE_TAG_DIRTY))) { + while (!done && (nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), + &index, (pgoff_t)-1, PAGECACHE_TAG_DIRTY, + &fbatch))) { int i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct page *page = &fbatch.folios[i]->page; bool submitted = false; /* give a priority to WB_SYNC threads */ @@ -2026,7 +2027,7 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi, if (--wbc->nr_to_write == 0) break; } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); if (wbc->nr_to_write == 0) { From patchwork Wed Nov 2 16:10:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14342 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp5411wru; Wed, 2 Nov 2022 09:15:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ZlVWOmz0s4hesK+FsN4nUF4sa9boVjrhn0QmoT3tg9rWrwT8JBRoGyJ6kWc95kumioOSF X-Received: by 2002:a17:907:3e06:b0:733:693:600e with SMTP id hp6-20020a1709073e0600b007330693600emr23142182ejc.410.1667405705799; Wed, 02 Nov 2022 09:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405705; cv=none; d=google.com; s=arc-20160816; b=F7qd0skhUpWQfeedaufTuQb1a+PIKuTJexWhlyDSkmkw3feM03x0GYCvJkliTzkkBQ O9sRf9cYp7ju+a/oFaYYhmhRfktee5YhqmNit5fF/U6KFdY72LBenTLXPi89TG0kPq9f Tbzf11IfOaFmgCXg/jF4XRg1/wwyANEJMtgAnBtI9FQBByQ7dLIOcVUh5/HyqmB/WKkw TSuEes3BpRtQi0qcusekFE2YrdxDJggElBN9+072qQKaRvkkjf+LZrte2CPA0sqRwIRc TA1diS9JAhyCa0xXhE6zvCduLBcRSKjOVxwm3sJKedDMZiTl5j0Z6T0Qx3VFFleVveqq DmNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Gop7swXAAJ8sgYyasjeCim+2hgvZWCX0xP2gQPQAoN4=; b=LIfpjOwNs+Z8ofLuEI6U0e7apAye8znKYpN9nVSkBAbd79vnvOH1OrSZQspOa0PR0O eGQffZ/U6+7y4M7GyJXA3QWwnI74Yg0uHe+83PdBIsnU/hxS3U1yBL6BSKn65PceVac/ oKY4t5K0zLUHk7xdI6QYhef2pJJg17SipNNB0sjGMlGtJnRgslGEFArqdLPCeLvfWC4f P3cNpgXd2cP7wsl6d4JUKYNmMP1t/mCKUo7B84BI7yvYD3geY3XD6HEhzgGINDwEEtvq j8nINZmFvhMeR+Bha7D/JWO8+hOFv2QUxkFS7t5uEAy7GMi9uZCzPvAuUCvaFQxygbl8 YgZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CYG7zu+Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a170906110600b007918f58458bsi11590321eja.441.2022.11.02.09.14.41; Wed, 02 Nov 2022 09:15:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CYG7zu+Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231602AbiKBQNP (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231475AbiKBQLl (ORCPT ); Wed, 2 Nov 2022 12:11:41 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A27F2CC90; Wed, 2 Nov 2022 09:11:29 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so2539073pjc.3; Wed, 02 Nov 2022 09:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gop7swXAAJ8sgYyasjeCim+2hgvZWCX0xP2gQPQAoN4=; b=CYG7zu+QxCPI4y/4OmUZ6lM2JjETOTsDWuWnK+gbIF/bo8LwhHwDiP6kyfIdUbpyX8 ab9PRWMdaUYGWhq7nY4kTV0jG0utHkrf1BbP7dErm+mKDb0+A4TEESQqpmkxzFQT+DtN JlhOn+4S24OwuKkrVD0sPxqkQVGmn/run6/9tIdNBUZ2ufh5mY9r9vOsWyRs6O01IxY5 jAHXvzsRSva4MguNXkmSvlrLJxwuOGefxKTQZM10Odu+C4tDWapwK5UUuivkGmwCYD8n SKYn5/mySUl+qAWnJeuU5HhpDCL1/6/iG5Yn4Ie4dHT4sJqWWgvPDGxn9z17ZG2JtxX9 QX+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gop7swXAAJ8sgYyasjeCim+2hgvZWCX0xP2gQPQAoN4=; b=HNXds3Bu2XdVyiX7CRWGfa8eaE0SP5lhh0ePBWslwTkKa65YbcxfdQhvtQKA1JQ1ps e/4bPZ11cAR5NTLBLeBIbTXzEgJ8x15nxVwT01bTjqYsEVptidS4in6gYoXRW0Ezf09h DJkCvPq8w9U4jejj2tmv9NM50NCsMOWFtC7OmIRjqIxVWPsVcPhmwbL9cKJBcwnS29rs B6NpjmF4ZDFwqm00+qLDQrU+SdIBHedqwamyUlnK7KTbeRCfHzdktdXFNrHzVp8g93+H PRsKMnfqm3HH6zKUks9Vs0otBJUqfgie2V+DhX+IgvxR6Jrm9CP72Q3gHCatsgIXhtbc dsbg== X-Gm-Message-State: ACrzQf0UZocjr1k1Ji0fBayZx+0ryUzJsp4Ki077owTm6y6pGc6IxMU8 /bj+1tp4F6Ug687GuB/nhhTDA5i4oPDfuw== X-Received: by 2002:a17:90a:b10b:b0:212:fbc3:e623 with SMTP id z11-20020a17090ab10b00b00212fbc3e623mr26873993pjq.5.1667405488224; Wed, 02 Nov 2022 09:11:28 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:27 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 14/23] f2fs: Convert f2fs_write_cache_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:22 -0700 Message-Id: <20221102161031.5820-15-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401605716436089?= X-GMAIL-MSGID: =?utf-8?q?1748401605716436089?= Converted the function to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). This change removes 7 calls to compound_head(). Also modified f2fs_all_cluster_page_ready to take in a folio_batch instead of pagevec. This does NOT support large folios. The function currently only utilizes folios of size 1 so this shouldn't cause any issues right now. Signed-off-by: Vishal Moola (Oracle) --- fs/f2fs/compress.c | 13 +++++---- fs/f2fs/data.c | 69 +++++++++++++++++++++++++--------------------- fs/f2fs/f2fs.h | 5 ++-- 3 files changed, 47 insertions(+), 40 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index d315c2de136f..7af6c923e0aa 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -842,10 +842,11 @@ bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index) return is_page_in_cluster(cc, index); } -bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages, - int index, int nr_pages, bool uptodate) +bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, + struct folio_batch *fbatch, + int index, int nr_folios, bool uptodate) { - unsigned long pgidx = pages[index]->index; + unsigned long pgidx = fbatch->folios[index]->index; int i = uptodate ? 0 : 1; /* @@ -855,13 +856,13 @@ bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages, if (uptodate && (pgidx % cc->cluster_size)) return false; - if (nr_pages - index < cc->cluster_size) + if (nr_folios - index < cc->cluster_size) return false; for (; i < cc->cluster_size; i++) { - if (pages[index + i]->index != pgidx + i) + if (fbatch->folios[index + i]->index != pgidx + i) return false; - if (uptodate && !PageUptodate(pages[index + i])) + if (uptodate && !folio_test_uptodate(fbatch->folios[index + i])) return false; } diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index a71e818cd67b..7511578b73c3 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2938,7 +2938,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, { int ret = 0; int done = 0, retry = 0; - struct page *pages[F2FS_ONSTACK_PAGES]; + struct folio_batch fbatch; struct f2fs_sb_info *sbi = F2FS_M_SB(mapping); struct bio *bio = NULL; sector_t last_block; @@ -2959,7 +2959,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, .private = NULL, }; #endif - int nr_pages; + int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; @@ -2969,6 +2969,8 @@ static int f2fs_write_cache_pages(struct address_space *mapping, int submitted = 0; int i; + folio_batch_init(&fbatch); + if (get_dirty_pages(mapping->host) <= SM_I(F2FS_M_SB(mapping))->min_hot_blocks) set_inode_flag(mapping->host, FI_HOT_DATA); @@ -2994,13 +2996,13 @@ static int f2fs_write_cache_pages(struct address_space *mapping, tag_pages_for_writeback(mapping, index, end); done_index = index; while (!done && !retry && (index <= end)) { - nr_pages = find_get_pages_range_tag(mapping, &index, end, - tag, F2FS_ONSTACK_PAGES, pages); - if (nr_pages == 0) + nr_folios = filemap_get_folios_tag(mapping, &index, end, + tag, &fbatch); + if (nr_folios == 0) break; - for (i = 0; i < nr_pages; i++) { - struct page *page = pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; bool need_readd; readd: need_readd = false; @@ -3017,7 +3019,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, } if (!f2fs_cluster_can_merge_page(&cc, - page->index)) { + folio->index)) { ret = f2fs_write_multi_pages(&cc, &submitted, wbc, io_type); if (!ret) @@ -3026,27 +3028,28 @@ static int f2fs_write_cache_pages(struct address_space *mapping, } if (unlikely(f2fs_cp_error(sbi))) - goto lock_page; + goto lock_folio; if (!f2fs_cluster_is_empty(&cc)) - goto lock_page; + goto lock_folio; if (f2fs_all_cluster_page_ready(&cc, - pages, i, nr_pages, true)) - goto lock_page; + &fbatch, i, nr_folios, true)) + goto lock_folio; ret2 = f2fs_prepare_compress_overwrite( inode, &pagep, - page->index, &fsdata); + folio->index, &fsdata); if (ret2 < 0) { ret = ret2; done = 1; break; } else if (ret2 && (!f2fs_compress_write_end(inode, - fsdata, page->index, 1) || + fsdata, folio->index, 1) || !f2fs_all_cluster_page_ready(&cc, - pages, i, nr_pages, false))) { + &fbatch, i, nr_folios, + false))) { retry = 1; break; } @@ -3059,46 +3062,47 @@ static int f2fs_write_cache_pages(struct address_space *mapping, break; } #ifdef CONFIG_F2FS_FS_COMPRESSION -lock_page: +lock_folio: #endif - done_index = page->index; + done_index = folio->index; retry_write: - lock_page(page); + folio_lock(folio); - if (unlikely(page->mapping != mapping)) { + if (unlikely(folio->mapping != mapping)) { continue_unlock: - unlock_page(page); + folio_unlock(folio); continue; } - if (!PageDirty(page)) { + if (!folio_test_dirty(folio)) { /* someone wrote it for us */ goto continue_unlock; } - if (PageWriteback(page)) { + if (folio_test_writeback(folio)) { if (wbc->sync_mode != WB_SYNC_NONE) - f2fs_wait_on_page_writeback(page, + f2fs_wait_on_page_writeback( + &folio->page, DATA, true, true); else goto continue_unlock; } - if (!clear_page_dirty_for_io(page)) + if (!folio_clear_dirty_for_io(folio)) goto continue_unlock; #ifdef CONFIG_F2FS_FS_COMPRESSION if (f2fs_compressed_file(inode)) { - get_page(page); - f2fs_compress_ctx_add_page(&cc, page); + folio_get(folio); + f2fs_compress_ctx_add_page(&cc, &folio->page); continue; } #endif - ret = f2fs_write_single_data_page(page, &submitted, - &bio, &last_block, wbc, io_type, - 0, true); + ret = f2fs_write_single_data_page(&folio->page, + &submitted, &bio, &last_block, + wbc, io_type, 0, true); if (ret == AOP_WRITEPAGE_ACTIVATE) - unlock_page(page); + folio_unlock(folio); #ifdef CONFIG_F2FS_FS_COMPRESSION result: #endif @@ -3122,7 +3126,8 @@ static int f2fs_write_cache_pages(struct address_space *mapping, } goto next; } - done_index = page->index + 1; + done_index = folio->index + + folio_nr_pages(folio); done = 1; break; } @@ -3136,7 +3141,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, if (need_readd) goto readd; } - release_pages(pages, nr_pages); + folio_batch_release(&fbatch); cond_resched(); } #ifdef CONFIG_F2FS_FS_COMPRESSION diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index e6355a5683b7..d7bfb88fa341 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4226,8 +4226,9 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed, block_t blkaddr, bool in_task); bool f2fs_cluster_is_empty(struct compress_ctx *cc); bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index); -bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages, - int index, int nr_pages, bool uptodate); +bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, + struct folio_batch *fbatch, int index, int nr_folios, + bool uptodate); bool f2fs_sanity_check_cluster(struct dnode_of_data *dn); void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct page *page); int f2fs_write_multi_pages(struct compress_ctx *cc, From patchwork Wed Nov 2 16:10:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14345 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp5899wru; Wed, 2 Nov 2022 09:16:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4dFx1zgnRvhNaqsYwQSVvEdWDtGCU5dty783cSrD3toX31JkBxcZJww95eX/esthJOkz3h X-Received: by 2002:a17:902:f791:b0:17c:c1dd:a3b5 with SMTP id q17-20020a170902f79100b0017cc1dda3b5mr25425524pln.141.1667405768651; Wed, 02 Nov 2022 09:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405768; cv=none; d=google.com; s=arc-20160816; b=tkVVUysBbgbwUNZ6QrhzNhyEZEGfpYdYw9ajf8mwG92ij4Z7KPkDLjb8v5pmBwa5yd cQQRXuZzBuu5ZycnLc853sP779AKle+QrvcKiabPBVF1U82M9w4mI7ef0/7kRIJ9JBvn VpJTDee/JKqykgPJXtBNkL7N0wu2XCJqZ7wIVPYOxo7gx3L7thQ9g6ar7qPbdm7XmCoT oZ2ZnXkWZccUgyxzEECs7wAliwuvECZgZJYRFJeTLj9f1jyBj/YcxvUyistm9wSmfIcR tA0kSkIwCr1YPgbtI71qbB1PSC6OVX9VDQ+NJVtaIkpCr9m2xSiZq5H1lkmqvMpw78B5 pTsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UZvXQK7eydj6IBrzU3IQ20y8xajH5CKQhE5ttfKWvGg=; b=E6ScLozMlUzueZmf90i5x89Ra02K2KUf3BoSsmeatGISIp4Z1tFx3CsBoQzY5iYEgJ InVN2IPgHXPDDLkZX3SvqtVxuY+K+ODol7LFHPW4lxUH1aI7/y5JSRsv55ffIeetqSSo 9A8/vq5IILlvCPAr00wRQUSFwXxZOD9f2RYq0O3SHl5SM2cIoLrOne/5OWAL0HEyzrTg uVpMlMkJl7l8gHrRF2aAbXRMJVOhhTdMFlDoPVlUlctvLY8DlOo6rMhsZUuSlQA5zwua meH3FSOgXV+VP4WnaHm+CCzgeEOTEkngi75lHC2fwT8JMVAJjHZJAthpTz9B2OlBBPEN fLzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=O4nbwv9c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pl18-20020a17090b269200b0021011c16872si2425314pjb.44.2022.11.02.09.15.54; Wed, 02 Nov 2022 09:16:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=O4nbwv9c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231570AbiKBQNL (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbiKBQLn (ORCPT ); Wed, 2 Nov 2022 12:11:43 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6200C2CC96; Wed, 2 Nov 2022 09:11:30 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id b5so16647484pgb.6; Wed, 02 Nov 2022 09:11:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UZvXQK7eydj6IBrzU3IQ20y8xajH5CKQhE5ttfKWvGg=; b=O4nbwv9cmBtSK1CT58yVHNsSMZiY/FKUA/O6oX43Ac0n4IX7vDCV2QLGEuoLXlUkd6 eHvyReQOL/NVjRshopa6fHkLaexjtpSCxifCTQBr0YR9yB++gFXMjIc34iHceLJdJagf WrwXLuWuCgB23v0+FXg91vjEGb1kLv6sB3PxXdVEjMmof4a7ofgr/GbDbkATXjxgH/8d +4RfUgwVsqN79UT/+0gaRpPE8h5g92Y8O3mytfBiXv715U8K+NOc/77TCeiz+rmrrP3T lHzCxF89bepNGUmoT3nYJomOxqi6w38Xq/9CrZcXJ2HzWpJvvHbi3XeAXF5vgGVoLqbr TnEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UZvXQK7eydj6IBrzU3IQ20y8xajH5CKQhE5ttfKWvGg=; b=4BiggV4ZoQnWg0pGFly2PbOPfbjBsxd1ws1TSYhKQcnQACNSTdN4ds+X+N6aGuJA6U Lm03Hpwh19b+it0UvBy2PufymZilaR16x5DRrngWoer1r5qlp4QY8axJyqdc/Agznvi7 uNLB0HUYfTeMUh2glC97e5lruh59AQ0KUIhWtQSMdatDiS5goEYyom935HEKrLBjHGY6 X9DRh+WNVOBj6/UhaL6cRL9FoNN1utgHem+swO5GIEP4l5k/GFaMdtJC1TEl7In44aWt Zn2wi9313nCpWadNL8/M4Wo3xBp4aOwUM+Vp64glr30PCiy3tjuQtVlzn+qnHtm3F+Po G+AQ== X-Gm-Message-State: ACrzQf2DLfNNYVEG4hqYQK6NfQIm71p+gsB/VcFggPIZbIMO9CkPDJVv /k5G21Lm/Jva0eDrTLL2NJXTzRpZDMGd9A== X-Received: by 2002:a05:6a00:999:b0:56c:3d0d:96fe with SMTP id u25-20020a056a00099900b0056c3d0d96femr26077443pfg.12.1667405489645; Wed, 02 Nov 2022 09:11:29 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:29 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 15/23] f2fs: Convert last_fsync_dnode() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:23 -0700 Message-Id: <20221102161031.5820-16-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401671186314632?= X-GMAIL-MSGID: =?utf-8?q?1748401671186314632?= Convert to use a folio_batch instead of pagevec. This is in preparation for the removal of find_get_pages_range_tag(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/node.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 38f32b4d61dc..3e1764960a96 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1515,23 +1515,24 @@ static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino) static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino) { pgoff_t index; - struct pagevec pvec; + struct folio_batch fbatch; struct page *last_page = NULL; - int nr_pages; + int nr_folios; - pagevec_init(&pvec); + folio_batch_init(&fbatch); index = 0; - while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index, - PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(NODE_MAPPING(sbi), &index, + (pgoff_t)-1, PAGECACHE_TAG_DIRTY, + &fbatch))) { int i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct page *page = &fbatch.folios[i]->page; if (unlikely(f2fs_cp_error(sbi))) { f2fs_put_page(last_page, 0); - pagevec_release(&pvec); + folio_batch_release(&fbatch); return ERR_PTR(-EIO); } @@ -1562,7 +1563,7 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino) last_page = page; unlock_page(page); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } return last_page; From patchwork Wed Nov 2 16:10:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp5630wru; Wed, 2 Nov 2022 09:15:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6VgBkkopCyDPiS6UhYZb0bpHSMnYpY79Nor7Ym8fJWpA5BkV4HC4TOIy+y1R2uNqZN86WJ X-Received: by 2002:a17:907:75ef:b0:7aa:3373:e7d8 with SMTP id jz15-20020a17090775ef00b007aa3373e7d8mr24952756ejc.231.1667405733741; Wed, 02 Nov 2022 09:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405733; cv=none; d=google.com; s=arc-20160816; b=BlgVoeeSR7D+dDqQlktz7wVtpMnkb1Q/Gjn5yaCQPb99Z6VO9btdL5Yn4bAW5DW+fM MwtD/eoT67XBiDZsdf9Zf39DX1ejtxcx8gOtut0NVzMfr8kDjCfbb8Oq1B1DYT1oJoDf FgJK/X6yGM/b3mW47hSwPugRpV3Gm2oiLbXeMtFkBrG7PbfOoCZHtA9UxePWPaFFxlXA 9e/iw9XyP46XSLQ+Hq/kHAiQ1qyW+HY05215NIHBfQ+L4QyEDku2R8sNiW9ptdEGPsXx xlQefTkkzQHVNOYg9G2kbKCqTVwzMk6vVdhMRF8D8E3PGxLnundBBJ/IuhTyD3StQwTs zhUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EUT3qCxHFf0C7hMc68kHG0lMsaO7BNxBnXOmjml9he8=; b=ZDigJluS/ntMnAeuS+wRgqw1/J1e7AUg6sKztSQhW2nmw/zenSj3bngBNUJcoNHLfE cL5k+rl4lQ8i95+sOqE6N7K4RIG32DOtH50BD78fuLYCBhgqQ+JA2j6BP86RGQ7BEufc JdGH2RiqvoBw7D4xxGkCcHdSbfvWtKJEzYuy5wx+aNzR2B6/9/UlbHc1CE+YkZoHJZxB 4rajzxW1PykRDU1f0nTjsJ414vchJgGyStRwZSpqE1tQCPcpHgT+hySFuc2ARRpVWSHe vur2MrgTBHmbDfF1zYmn16DRZAf5Vq8cQKoLFXNEolT3HKwETuTvgpjGfuri7ey0Ejg9 cX8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PTvyn3BE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a26-20020a1709065f9a00b0078dd7383ed8si12291870eju.414.2022.11.02.09.15.09; Wed, 02 Nov 2022 09:15:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PTvyn3BE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231670AbiKBQNV (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231492AbiKBQLq (ORCPT ); Wed, 2 Nov 2022 12:11:46 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D70A02CCB8; Wed, 2 Nov 2022 09:11:31 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id q1-20020a17090a750100b002139ec1e999so2318479pjk.1; Wed, 02 Nov 2022 09:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EUT3qCxHFf0C7hMc68kHG0lMsaO7BNxBnXOmjml9he8=; b=PTvyn3BEaAs9RE30oauDngZDkx0CdMxC8DfQHIIIl4jF6IO3gFQO/Hyq/HeBqHT04f Z6twx314UNMcXHGrTZulZS0YtVydCDj24T8M8fgfqpffbv6vl6jpy6+GiLGtpaRUnwjt hC9HVmZD06nQprUNjNlM4T7UE9IHxY7Kko6W6wvGb0GZeNyCB67/gGzrNo2P9nhFi2Jx wgZ0J9jcHXMv4ieTAzz3i1oJACiGkx9zlPc4v370bEV7YTt8vmW2WrJHjufczTQd6zL/ 8uZHmRqae+I/FnHCriK61BXAV9r2auhv6iVffm9aBrKd0N0Nv8qSUlpZf9PtTZLD1gi1 UHFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EUT3qCxHFf0C7hMc68kHG0lMsaO7BNxBnXOmjml9he8=; b=Oa/Jx11e3NWld2JZNaZ3JHLiUqXFehOV2BekTsKk1crgSYcuu7CJm7bDk3bKpqypvl qzxKr0O/abRYsDv/w/+6OQLLJH0+hSDG98GmYvTN4zwZIQCQw1OstbEeERUD/sk6XgeQ chMekHG5/xviAW2oO/H1mPSTcb+ReXGQepRQOyNGz7YSIj4ykowOWMCZsG2AHNnNt74f Ayu8OpNbL7EfFIekebW/WcKpLdMZWs9AbVYfcbLjNFXuUNXNgDsfDArNKKWCzfo04nBB OydLlUPDaPy5JBSVvAktyzmK0JbU62NkeQtHK4eN0T669HDINFXdbWv8ahmfKmoZ/XIm QKrQ== X-Gm-Message-State: ACrzQf1GPibSsQfjYL/WWQa4YuTCdqCU+i7WBYeUyCeBOF9hyD0zgjt6 5Jam8FDfciSZvDK9lDTPZXnCJnyiCd8QUA== X-Received: by 2002:a17:90b:2705:b0:20a:b4fa:f624 with SMTP id px5-20020a17090b270500b0020ab4faf624mr26339614pjb.124.1667405491123; Wed, 02 Nov 2022 09:11:31 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:30 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 16/23] f2fs: Convert f2fs_sync_meta_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:24 -0700 Message-Id: <20221102161031.5820-17-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401634385304025?= X-GMAIL-MSGID: =?utf-8?q?1748401634385304025?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). This change removes 5 calls to compound_head(). Initially the function was checking if the previous page index is truly the previous page i.e. 1 index behind the current page. To convert to folios and maintain this check we need to make the check folio->index != prev + folio_nr_pages(previous folio) since we don't know how many pages are in a folio. At index i == 0 the check is guaranteed to succeed, so to workaround indexing bounds we can simply ignore the check for that specific index. This makes the initial assignment of prev trivial, so I removed that as well. Also modified a comment in commit_checkpoint for consistency. Signed-off-by: Vishal Moola (Oracle) Acked-by: Chao Yu --- fs/f2fs/checkpoint.c | 49 +++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 0c82dae082aa..82eb26f471c5 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -390,59 +390,62 @@ long f2fs_sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type, { struct address_space *mapping = META_MAPPING(sbi); pgoff_t index = 0, prev = ULONG_MAX; - struct pagevec pvec; + struct folio_batch fbatch; long nwritten = 0; - int nr_pages; + int nr_folios; struct writeback_control wbc = { .for_reclaim = 0, }; struct blk_plug plug; - pagevec_init(&pvec); + folio_batch_init(&fbatch); blk_start_plug(&plug); - while ((nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, - PAGECACHE_TAG_DIRTY))) { + while ((nr_folios = filemap_get_folios_tag(mapping, &index, + (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch))) { int i; - for (i = 0; i < nr_pages; i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch.folios[i]; - if (prev == ULONG_MAX) - prev = page->index - 1; - if (nr_to_write != LONG_MAX && page->index != prev + 1) { - pagevec_release(&pvec); + if (nr_to_write != LONG_MAX && i != 0 && + folio->index != prev + + folio_nr_pages(fbatch.folios[i-1])) { + folio_batch_release(&fbatch); goto stop; } - lock_page(page); + folio_lock(folio); - if (unlikely(page->mapping != mapping)) { + if (unlikely(folio->mapping != mapping)) { continue_unlock: - unlock_page(page); + folio_unlock(folio); continue; } - if (!PageDirty(page)) { + if (!folio_test_dirty(folio)) { /* someone wrote it for us */ goto continue_unlock; } - f2fs_wait_on_page_writeback(page, META, true, true); + f2fs_wait_on_page_writeback(&folio->page, META, + true, true); - if (!clear_page_dirty_for_io(page)) + if (!folio_clear_dirty_for_io(folio)) goto continue_unlock; - if (__f2fs_write_meta_page(page, &wbc, io_type)) { - unlock_page(page); + if (__f2fs_write_meta_page(&folio->page, &wbc, + io_type)) { + folio_unlock(folio); break; } - nwritten++; - prev = page->index; + nwritten += folio_nr_pages(folio); + prev = folio->index; if (unlikely(nwritten >= nr_to_write)) break; } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } stop: @@ -1398,7 +1401,7 @@ static void commit_checkpoint(struct f2fs_sb_info *sbi, }; /* - * pagevec_lookup_tag and lock_page again will take + * filemap_get_folios_tag and lock_page again will take * some extra time. Therefore, f2fs_update_meta_pages and * f2fs_sync_meta_pages are combined in this function. */ From patchwork Wed Nov 2 16:10:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14344 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp5788wru; Wed, 2 Nov 2022 09:15:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Ixw2WRbDJI5GmD/FLrBCgYofFH7W1mV2KjzkjHTGZhjpfkvqCV1wH/G8aldZKkR68Qtzx X-Received: by 2002:a17:906:c44:b0:7ae:749:1659 with SMTP id t4-20020a1709060c4400b007ae07491659mr3259073ejf.759.1667405756409; Wed, 02 Nov 2022 09:15:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405756; cv=none; d=google.com; s=arc-20160816; b=eT0ws6Yecjle8u8ShHcsw4VZwkMTm+IvWTUPwH9cpo8NqmaVgoYLD5dGDqDv+rwG+a r6wrnsOCj7JyFOi8zB/15k9eNECNsEzbvPokz3g5kL9IXwCF6XwSpIYSDOL3fN/yHNGv LzRiSO6Io+ia+uP4eOGSvCxAmjMnyxfvO5rWOmD4PqWj9vo1fKwsJpkWgQd1Kxmw4jm2 yqnH9xlJ6qpvrHC6G+p2ehsZbMUdLgPWG3fsA4rLCPTAswdAabZrv58Fybokv81fBUsN Sh18oBz+93wL7buXBFd6XZfFw3LWi19A/T6oXmfsyTn/H8rvMu1Mb6qHhTIopy7jSliE 8Vnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IqHxjBdA8jMvvrIwM6GshEvbrekvDWb2O2+Yqn7ktYo=; b=LQUMP8O9WzYBpY3MFxtRIjmDlUm0vGj2Mw0wJ1UhQ54oIk5jWTPwMP9hP1lB/j9dW1 SMogZzQPa1jIDsiOaTRe78MqIHN5shgariKg6vl9jtnI8xjYTn61pmmBDyNVoNLSv7ES E9/uRRrAZoKRjrbh7W0U0VpIaI/vANib+PYLfPFgqmo8yEBU7Csk8P0nZBd4OHRPFu1Y 2gBhbTCNujrqeDzgB1fsxt1eY3wNAVHq216opyMavXooSsv8SVbUt3SpaiOFfjVgmInm +Zx1ja8M/junsxLuKI1EU2z8/J9nWRyIbABKsKYis9r/BwvTMVVkAFpfZGWKeiAhLB4r 0IJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cTecwnbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e2-20020a056402148200b00458ab54baa5si12935249edv.503.2022.11.02.09.15.32; Wed, 02 Nov 2022 09:15:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cTecwnbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231643AbiKBQNZ (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231501AbiKBQLr (ORCPT ); Wed, 2 Nov 2022 12:11:47 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E49A2CDE6; Wed, 2 Nov 2022 09:11:33 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id m6so16863162pfb.0; Wed, 02 Nov 2022 09:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IqHxjBdA8jMvvrIwM6GshEvbrekvDWb2O2+Yqn7ktYo=; b=cTecwnbK8PfqHVHi0WLzmJq5zHb6BfWLvopq1hm1TOLxAWNlw5daE69Z/irCx8vo3O +j5BiGarvjiwsPmZP/06ta3WKfAa7bLlp5GSyrFN7qWmbz83Oc5hawPd1UTNg0s2PZAv O3vAIVJb5OmP+FFcYDPLT6ikM0eWsinoDywLeN4mz4rb82IRK0N2HYPUHSO0dnJmyy+s pVW+NRgOBM3n6NZLyoGBLNofHn6niNZ92OuAFdUincydrQODix9rTdWA8NhNp3XFimI6 wZb5v/V31zd8j5yUJ7OTOcZFH5KYs0zkoeZLLC19M5UH0KcOZhcY02srDFlin9WNSxWB UHFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IqHxjBdA8jMvvrIwM6GshEvbrekvDWb2O2+Yqn7ktYo=; b=hONwdtP6jaeYdNvGQdkYGHCrgxuSEODs9Alv4wc4jJhG0A6mK3En5Z02Ixtu5XMEVb +KtjGSqfTDETue7A2eCNnahcaBv5bcGnUAKFzQajzSjP4a4FCyuq8IiQpoa8rOg82sJO vkjBvfgNDLrNNZxxOogxtoU3i7VdMYyN3h8q7yveL/sq7ci/0anvdzeTgc1Gqt7Cz6DL k7ZrqPHchMhLIEoBow25TbGtmeWn5ZsuKQIUC2IseCWhCeHHiVKrdflhmuednpMGdl12 qjyAWz6HTs4lkSRouvii5gOBQaygzWVRBUQtsgmd/LyctIJOgo9AQmVtR1tYvfv1rZyf +IeQ== X-Gm-Message-State: ACrzQf2DDvYKrZ3KOwXn3PQv4V0y9s+UFVAP7Q3OHnBB9KmR4ifITJFe zMu+v+RbNVI3FykC0JDJDBPSPcLRGcqlXg== X-Received: by 2002:aa7:951d:0:b0:56b:9937:c749 with SMTP id b29-20020aa7951d000000b0056b9937c749mr26032693pfp.78.1667405492550; Wed, 02 Nov 2022 09:11:32 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:32 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 17/23] gfs2: Convert gfs2_write_cache_jdata() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:25 -0700 Message-Id: <20221102161031.5820-18-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401658248710618?= X-GMAIL-MSGID: =?utf-8?q?1748401658248710618?= Converted function to use folios throughout. This is in preparation for the removal of find_get_pgaes_range_tag(). This change removes 8 calls to compound_head(). Also had to modify and rename gfs2_write_jdata_pagevec() to take in and utilize folio_batch rather than pagevec and use folios rather than pages. gfs2_write_jdata_batch() now supports large folios. Signed-off-by: Vishal Moola (Oracle) --- fs/gfs2/aops.c | 64 +++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index 05bee80ac7de..8f87c2551a3d 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c @@ -195,67 +195,71 @@ static int gfs2_writepages(struct address_space *mapping, } /** - * gfs2_write_jdata_pagevec - Write back a pagevec's worth of pages + * gfs2_write_jdata_batch - Write back a folio batch's worth of folios * @mapping: The mapping * @wbc: The writeback control - * @pvec: The vector of pages - * @nr_pages: The number of pages to write + * @fbatch: The batch of folios * @done_index: Page index * * Returns: non-zero if loop should terminate, zero otherwise */ -static int gfs2_write_jdata_pagevec(struct address_space *mapping, +static int gfs2_write_jdata_batch(struct address_space *mapping, struct writeback_control *wbc, - struct pagevec *pvec, - int nr_pages, + struct folio_batch *fbatch, pgoff_t *done_index) { struct inode *inode = mapping->host; struct gfs2_sbd *sdp = GFS2_SB(inode); - unsigned nrblocks = nr_pages * (PAGE_SIZE >> inode->i_blkbits); + unsigned nrblocks; int i; int ret; + int nr_pages = 0; + int nr_folios = folio_batch_count(fbatch); + + for (i = 0; i < nr_folios; i++) + nr_pages += folio_nr_pages(fbatch->folios[i]); + nrblocks = nr_pages * (PAGE_SIZE >> inode->i_blkbits); ret = gfs2_trans_begin(sdp, nrblocks, nrblocks); if (ret < 0) return ret; - for(i = 0; i < nr_pages; i++) { - struct page *page = pvec->pages[i]; + for (i = 0; i < nr_folios; i++) { + struct folio *folio = fbatch->folios[i]; - *done_index = page->index; + *done_index = folio->index; - lock_page(page); + folio_lock(folio); - if (unlikely(page->mapping != mapping)) { + if (unlikely(folio->mapping != mapping)) { continue_unlock: - unlock_page(page); + folio_unlock(folio); continue; } - if (!PageDirty(page)) { + if (!folio_test_dirty(folio)) { /* someone wrote it for us */ goto continue_unlock; } - if (PageWriteback(page)) { + if (folio_test_writeback(folio)) { if (wbc->sync_mode != WB_SYNC_NONE) - wait_on_page_writeback(page); + folio_wait_writeback(folio); else goto continue_unlock; } - BUG_ON(PageWriteback(page)); - if (!clear_page_dirty_for_io(page)) + BUG_ON(folio_test_writeback(folio)); + if (!folio_clear_dirty_for_io(folio)) goto continue_unlock; trace_wbc_writepage(wbc, inode_to_bdi(inode)); - ret = __gfs2_jdata_writepage(page, wbc); + ret = __gfs2_jdata_writepage(&folio->page, wbc); if (unlikely(ret)) { if (ret == AOP_WRITEPAGE_ACTIVATE) { - unlock_page(page); + folio_unlock(folio); ret = 0; } else { @@ -268,7 +272,8 @@ static int gfs2_write_jdata_pagevec(struct address_space *mapping, * not be suitable for data integrity * writeout). */ - *done_index = page->index + 1; + *done_index = folio->index + + folio_nr_pages(folio); ret = 1; break; } @@ -305,8 +310,8 @@ static int gfs2_write_cache_jdata(struct address_space *mapping, { int ret = 0; int done = 0; - struct pagevec pvec; - int nr_pages; + struct folio_batch fbatch; + int nr_folios; pgoff_t writeback_index; pgoff_t index; pgoff_t end; @@ -315,7 +320,7 @@ static int gfs2_write_cache_jdata(struct address_space *mapping, int range_whole = 0; xa_mark_t tag; - pagevec_init(&pvec); + folio_batch_init(&fbatch); if (wbc->range_cyclic) { writeback_index = mapping->writeback_index; /* prev offset */ index = writeback_index; @@ -341,17 +346,18 @@ static int gfs2_write_cache_jdata(struct address_space *mapping, tag_pages_for_writeback(mapping, index, end); done_index = index; while (!done && (index <= end)) { - nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end, - tag); - if (nr_pages == 0) + nr_folios = filemap_get_folios_tag(mapping, &index, end, + tag, &fbatch); + if (nr_folios == 0) break; - ret = gfs2_write_jdata_pagevec(mapping, wbc, &pvec, nr_pages, &done_index); + ret = gfs2_write_jdata_batch(mapping, wbc, &fbatch, + &done_index); if (ret) done = 1; if (ret > 0) ret = 0; - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } From patchwork Wed Nov 2 16:10:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp5923wru; Wed, 2 Nov 2022 09:16:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qD6r2ImXzZXaUi7Bd+ptg9slHTmfZ/nFSy/7HSA49rBtnjEWVd+2qn0CGVwnZFd7ijnNB X-Received: by 2002:a63:e007:0:b0:46f:d715:3704 with SMTP id e7-20020a63e007000000b0046fd7153704mr11098301pgh.108.1667405773870; Wed, 02 Nov 2022 09:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405773; cv=none; d=google.com; s=arc-20160816; b=WBK/rGGJpXmyr9utm9zQIGyLLCZ3SLiaWAw9aDAXgSK4sI4H6UCbIgU3CnLtCTHlR2 gC5gsWo5ZPuLHdAnLjNEHXne0VGx45X2EbpC2dYXhO2SKYAbLrKj1WwrE9GysnZTGa4J XQp2QYtzVm79s7bTk/ZavuMU8mKZ1etEdcXYfAEiaAmVU0+tD+SJSFIXY2fwaxae24Xh leWpcTHEH+bySlJsJPQeMZgenZGLOLCbKu+mrWG7al4Rw7NrQj4rhN7RA8bgFa6yjR4n Ef4HaYCdPAbsAAr6o/rfZm3OYGv2BhZzba0EGLyGxIWBem/Bk318j2Z3g1n6rwJK5xxS Kvqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M6ro/4uwbCPgnPQoXYfWSXb0BSYdAvQsNHB7i1qmjGk=; b=orSl9VD2d/JvN12LOU5tKEVhRtB3TK3Bj80OpUGNWDcN1zh5u/nw77zaupUhtnxvx7 Ueq9WGSlu+cNSauyIjlWy/v8iRSZQ+KVtpznXQxbMdG8SaBzJ6mM4KSJLFh1ynU5jJRR RLBXw+cFh5rNeS8OuuIF3lp9aezExOz8Sw+ijJwAreuaTF3ZTjcDl7xwVpM84Szh4tJ7 7IC3zrng+ByWrTfoVspWOZChvo2+s0hZXLmamPI827tqBLsQG2f/Z07cIhyiMDUQGSdQ m9/rCfRQO4IN2db8G5sD8Qoh3erBrdo37xJ05lefeT//WzPS6iP8A46gCtKXwqAML+/z 7eqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=q3y86Mqj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g14-20020a63564e000000b0043c9fcccbd9si18618293pgm.685.2022.11.02.09.15.59; Wed, 02 Nov 2022 09:16:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=q3y86Mqj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231689AbiKBQN2 (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231571AbiKBQME (ORCPT ); Wed, 2 Nov 2022 12:12:04 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA6E82CDCD; Wed, 2 Nov 2022 09:11:34 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id h14so16689559pjv.4; Wed, 02 Nov 2022 09:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M6ro/4uwbCPgnPQoXYfWSXb0BSYdAvQsNHB7i1qmjGk=; b=q3y86Mqj0DeZyISqm/NEreuCkcVJdcqf1I2PppLIxLtCQkHnGzMeBPNGgV0nSBjZzo fx/DTafrePXLwXBlWJcD2VH7Lg0Z1T54Sz66MqXxFSFX63QD/buYFZb6ZlrEHmgkrvOG 6wPPcdqdE3EZlG/p2W7Gyv6nIhwzWc745dpabg6QvsjYd3Xg4Tk5BqwdQJX7kCgd5AvR dfK69VeuJCj+LO3ABeT4hrA0BZJDXiABX+2axHpLqvGhX3vsUKYQ7PHDjkGX3xzT+y95 L/VuMNGLM9kCQA0VEnLWnHg1PrMv390+X0DAi/s+IP/duC+XZLqgE8qsknuv46zXcBvg WCSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M6ro/4uwbCPgnPQoXYfWSXb0BSYdAvQsNHB7i1qmjGk=; b=aRsQtJlX4l1WRXl1jOE4P83gVlgD+slY1nRG72K4x9/3bI4mv9Iid8f+13rnVasi8G eiV2v0uPccODH/+qeAUftqiPMW8WikQspETzYborkUUwXFlOeuGUjypiB6uN8MDAroja HFMFg3O6d+rqOUulzZ5Pi6vhiUnuwORpyxT9khXmgpahh2alaZlxjDk2j40D3GjCeCpM 62PnvA29wbT9HjVTi/QQacdm5RwEZxY6B1+B/7d7TIWBUBKnpFaU/XCvdguJXW0++UPI ArIvLIYBvyfaBvWeUDKqsTMjIXZ+f7NWjQoiFDveS5hYkPO2uekrVPcODXiF144q9+8U 1OGA== X-Gm-Message-State: ACrzQf2vLcsjzQ2HtpJsSNPuOhDUVO+dn0pQQFLSBQ5po0IaUaBvF3YF z5/OECT2yzZWkJTE/0l09ySnGIQwehvwFA== X-Received: by 2002:a17:902:b18d:b0:186:9bb5:a92 with SMTP id s13-20020a170902b18d00b001869bb50a92mr25445634plr.11.1667405494098; Wed, 02 Nov 2022 09:11:34 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:33 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Ryusuke Konishi Subject: [PATCH v4 18/23] nilfs2: Convert nilfs_lookup_dirty_data_buffers() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:26 -0700 Message-Id: <20221102161031.5820-19-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401677066136603?= X-GMAIL-MSGID: =?utf-8?q?1748401677066136603?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). This change removes 4 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/segment.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index b4cebad21b48..2183e1698f8e 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -680,7 +680,7 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, loff_t start, loff_t end) { struct address_space *mapping = inode->i_mapping; - struct pagevec pvec; + struct folio_batch fbatch; pgoff_t index = 0, last = ULONG_MAX; size_t ndirties = 0; int i; @@ -694,23 +694,26 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, index = start >> PAGE_SHIFT; last = end >> PAGE_SHIFT; } - pagevec_init(&pvec); + folio_batch_init(&fbatch); repeat: if (unlikely(index > last) || - !pagevec_lookup_range_tag(&pvec, mapping, &index, last, - PAGECACHE_TAG_DIRTY)) + !filemap_get_folios_tag(mapping, &index, last, + PAGECACHE_TAG_DIRTY, &fbatch)) return ndirties; - for (i = 0; i < pagevec_count(&pvec); i++) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { struct buffer_head *bh, *head; - struct page *page = pvec.pages[i]; + struct folio *folio = fbatch.folios[i]; - lock_page(page); - if (!page_has_buffers(page)) - create_empty_buffers(page, i_blocksize(inode), 0); - unlock_page(page); + folio_lock(folio); + head = folio_buffers(folio); + if (!head) { + create_empty_buffers(&folio->page, i_blocksize(inode), 0); + head = folio_buffers(folio); + } + folio_unlock(folio); - bh = head = page_buffers(page); + bh = head; do { if (!buffer_dirty(bh) || buffer_async_write(bh)) continue; @@ -718,13 +721,13 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode, list_add_tail(&bh->b_assoc_buffers, listp); ndirties++; if (unlikely(ndirties >= nlimit)) { - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); return ndirties; } } while (bh = bh->b_this_page, bh != head); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); goto repeat; } From patchwork Wed Nov 2 16:10:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14351 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp6615wru; Wed, 2 Nov 2022 09:18:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7xSIjnODwcAIlxsv4KIywyuYvW8a3bpUxDh4fW/0M++4V2Rm2p1LoFfeLx0XNrjF0s8H+s X-Received: by 2002:a05:6402:a47:b0:462:a70e:31a6 with SMTP id bt7-20020a0564020a4700b00462a70e31a6mr25232014edb.233.1667405882215; Wed, 02 Nov 2022 09:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405882; cv=none; d=google.com; s=arc-20160816; b=ZjKZv1GSBMbMnZEmODux3UtHdYK1LPQCEtcYC84lrYjs3uNI6I7p7SUgvUf18WELym mq5hA3Kj9kCyfXgoS5yyEaNzJtuhExx5ZvbL3+GpfRTY6JDF01wUVaHYcu1sMCt0ZUiQ u5q0oNNkZ3L/3N9d8Pb7ZH/bNyy8rkqMjgt2TsupF16J49xB+KGhSD8JrAZFzZPKkTyC 9voI6RLpJT6t2a0h45dBlTErYqudyo50/+xgFTyK0syiEKJEVXPlZccowhYzQqqIC2Er FZFwfrPCsgy2a7GE0trunWc2VX6hBHeGIh49zfgUTUDqzaeH3pWWiT38xoKBcYT6WDs7 8Brw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KDRTYxfyvxtJ8nlExLPdZpgWJ/su4BLXKUXaNb8lkhE=; b=XKJcT/+CVZtlBdeJFM406Vkgz9tyx846mpAJxUhdj273q5THju+N2h4KEAYMTtxRjq WDNFneZVSoOy/YwEohtHcYGBZp8eNTp5NO0GgsFwWzEsI60CA7ZA5vfekIXnpcX16Gk0 QaJTV/JeMzIk/pHwJvkvrJpzrb3M9ILxWv3JaCQIzRHQE9ISFnpWJal2SOmryk4ySP/b W8ckHwjM9z7Nj1SZ3nME4+MF1fpwaoYFrNDvNITBriX0a/JYB9Ocod+vFCjVQDmC1FwO lmI0c/9LcGqy4KE52Eb7QFDWHCyEqoztzbKlIeirugHerxPIRg5o4ykMx6S6NXwfB8W2 2mCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LzbfvJ+o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go44-20020a1709070dac00b00730a4246dd0si19236557ejc.593.2022.11.02.09.17.35; Wed, 02 Nov 2022 09:18:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LzbfvJ+o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbiKBQNi (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231587AbiKBQMF (ORCPT ); Wed, 2 Nov 2022 12:12:05 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BD222CDFC; Wed, 2 Nov 2022 09:11:36 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id b1-20020a17090a7ac100b00213fde52d49so2314597pjl.3; Wed, 02 Nov 2022 09:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KDRTYxfyvxtJ8nlExLPdZpgWJ/su4BLXKUXaNb8lkhE=; b=LzbfvJ+o7+PPEWAo4w8AKJBmrzmPbRkBu3ORC/K7IBEBc4H7+EY6jlr3kPMKdC+kLo AmeRyK5Dh8JnM5M6037m8XCwwaveHP3T1zWfXQL5PNN2l8Ar7mvAlRUfGrHxX9l4CAlx lo3QVGXXrSxrr9dWf3dkPnZsG+uP9YkyrIkUspxdhnyIO5H9xO3I2khrWtyjrsb3beRJ 4OTNnGP/tYO4gLRsXwP7dLPwn1T8Eyszj0QvmzUxq1RtDQ9iIk0vaxsCgNdXJmRDiqCT sM3lyaFW63RiGf2IUhiE4Hi5Q9YJbodgMXUOnMDzbZK/PBDDWhOYiUrWWg5ys/RBXgc/ FTLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KDRTYxfyvxtJ8nlExLPdZpgWJ/su4BLXKUXaNb8lkhE=; b=W2+Z41ZtdW8kROKbKYrIwMkBJx+Dyr8rM5jodneFYxJdLa5gEJFg/i8+OBX1XWoQQW howLvnl8d0uCFy2aqQ25mtJ6905RQfll8tdQBU1iEMLlGl5+BymWsVZcAybqGvgFuT90 QgkqyfQh2B7KVU8JhhbDDNHS1iATYXfz+oZlVsdprwZLu1EDNiCBamiHJIcDE7Mgcv5H 9TWDGG0L05/lUH14a+0I5DPH6PLWWVM7klVy+DvmihfzSw1iqjE8SCsAXYuA0T8NigSW 6eRewBKtvWaq4rb1INvwT2OPcR4Jxy7MaebDdVRV6zxlQqTh+kUConKuGW2UrChAXXGm lKWg== X-Gm-Message-State: ACrzQf3V3SRmir4XxPJXpodxiJnwmUYR9otpxVjThACxKjhMWrixqAjC RX52Tu5OPyBgFQNMJDxR2ksP2ntxKfru5w== X-Received: by 2002:a17:902:e5cb:b0:187:2d8c:a4fa with SMTP id u11-20020a170902e5cb00b001872d8ca4famr12910612plf.151.1667405495543; Wed, 02 Nov 2022 09:11:35 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:35 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Ryusuke Konishi Subject: [PATCH v4 19/23] nilfs2: Convert nilfs_lookup_dirty_node_buffers() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:27 -0700 Message-Id: <20221102161031.5820-20-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401790497375198?= X-GMAIL-MSGID: =?utf-8?q?1748401790497375198?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). This change removes 1 call to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/segment.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 2183e1698f8e..fe984def1b1c 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -737,20 +737,19 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode, { struct nilfs_inode_info *ii = NILFS_I(inode); struct inode *btnc_inode = ii->i_assoc_inode; - struct pagevec pvec; + struct folio_batch fbatch; struct buffer_head *bh, *head; unsigned int i; pgoff_t index = 0; if (!btnc_inode) return; + folio_batch_init(&fbatch); - pagevec_init(&pvec); - - while (pagevec_lookup_tag(&pvec, btnc_inode->i_mapping, &index, - PAGECACHE_TAG_DIRTY)) { - for (i = 0; i < pagevec_count(&pvec); i++) { - bh = head = page_buffers(pvec.pages[i]); + while (filemap_get_folios_tag(btnc_inode->i_mapping, &index, + (pgoff_t)-1, PAGECACHE_TAG_DIRTY, &fbatch)) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { + bh = head = folio_buffers(fbatch.folios[i]); do { if (buffer_dirty(bh) && !buffer_async_write(bh)) { @@ -761,7 +760,7 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode, bh = bh->b_this_page; } while (bh != head); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Wed Nov 2 16:10:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp6092wru; Wed, 2 Nov 2022 09:16:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7qLOQRIPTvoN3t3AvFACd49FqLdhhQk+8Kktj3kSxmuTbQHjMTBq9SA4lPcRHYNKH/F2iO X-Received: by 2002:a17:906:cc4d:b0:7ad:b598:9a53 with SMTP id mm13-20020a170906cc4d00b007adb5989a53mr22298381ejb.480.1667405801056; Wed, 02 Nov 2022 09:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405801; cv=none; d=google.com; s=arc-20160816; b=iAxLMkOMpzpk2JJYdw7cyAd3wXrxzo52UWMI6cIAJI9dekJvnNyDdP2LKapLBxJ2UZ B22AVhcVLGxcoDabkHaHQGuls7i7DX9TaettjTq4qsEQ+WD2PEev8g3P1ToTHAFboGQK QICJQFcSgRngRMZt9B55PkiXnXL89cUDkJQhnSlutuT+Hq4RFfA0S6kiIIROcjw9bPtN peomKaajvKBmeSGDNRLgW8xMvpFkRzswRJzMlBCC0r5/2qnMHA+BoCfHdnuBvgs/lMhd 7zG1MGrYileR/YdNMkqfh3YqRAdtUSwXeQqEJhmdEkKej58e1N3DB7GIFU9mrHIDIxop Vf5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BlC7rcv7uN/Ok17R0azuMVwGkvRCqLRr8I16XJ1l0Zg=; b=RbmsWBFNSqK5/BPDsMCeMdQ9dMjwT6hOllimu0ayPahB5b+wwHfuxmrVMCakGXbfLu n5n9BoehCgbEa6og+pH6JulbN8VbxHdIWQdlot0Ua92daB5D9bXVkNFrrh+XkqJ+l2gO 7WiODCF4rRwp6dAJ3R8I9g07SdAyBsrvgqLq9W7xWJQ36r9eUeMKfXRQ0Bd3OrtSEzE4 7siJeaHUGeoDL0mHvLmQFunzQmBHNB4FCQ2m8j2vnZ/6tpuXTM3SBgUPBd5YIfynimsA bIdCufsk45YA4qvEUStI1kmuwKA1csHHSdJF3GmZJtzQaoIRf+RMCxEdU/VJ8legurZD UuSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Nq5OC7/q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a056402090d00b00463817b0ba1si13110924edz.163.2022.11.02.09.16.16; Wed, 02 Nov 2022 09:16:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Nq5OC7/q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231701AbiKBQNr (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231609AbiKBQMH (ORCPT ); Wed, 2 Nov 2022 12:12:07 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BB1E2CE3B; Wed, 2 Nov 2022 09:11:37 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id v28so16646002pfi.12; Wed, 02 Nov 2022 09:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BlC7rcv7uN/Ok17R0azuMVwGkvRCqLRr8I16XJ1l0Zg=; b=Nq5OC7/qho070kMTIR5kedhLSGx2YL5E36Blk/zAHlfy6q42bFls2+pa4RnB8ovU/3 23vNW1b/D7YHHKye0/4R/8zfNZQd1v8t3O7W30JyYK8TO3BPzuGAvu8+idJLehY48eH0 nTA2LRYP2Tci8THpRdHRqOdUYAvC3WYgum+zsQ45VXVUlAh+7LDKxfOfFDNSJdU1TCHI 654ZghJ33xktcPdPAHAEZ2WzWNJD2pfRdlYSjV2sZ+0y6oREU3jCVDH6UyjTHuPXqQAv 7tNhrDH+d3WfX8ldYnIx9oUWEl/bGnai6OMrkkhyLBvzLpImZOGi3fus7xAeqEFsIJc3 iWsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BlC7rcv7uN/Ok17R0azuMVwGkvRCqLRr8I16XJ1l0Zg=; b=Fvuck+1W+cJTXC+sWfGTou//2NskyBwOZQg6ovylETjIEpiuuh3jAGwcY99xCLQCP+ p11sOrlC48E7gKeehx/HzdU6pezWfdPVN173i1NoAO3Gd4oyU9kY0nfZjrpvgKgB3s3Z m2Xy2v5V3mzQr5cDiD7rn6dylvHbDlSLQNkEVCkFJs6DwCFPTxjXbZRCSbiXCFzCXGxo Zi+taG3sWkQBVn1EvWUtOweIzjAH6rohFV9LeU96/5/AS7T8TXM521ZOLZz58kH9CTmh yFyulNsLyiVp32h1BVsNXAueHaiDIRK9eXgO+wKhn5lMYeg7u84fqH2LTXYY6QNl2YQx DCAw== X-Gm-Message-State: ACrzQf0oLsB690EsION+9y1SUL5g9ZgUfDCRXBujqKOCyY1rmSnHxt4l lpZz+ypCufEZOpD6kvIDX1OfXrdprDh7kw== X-Received: by 2002:a63:85c8:0:b0:46e:c387:c85f with SMTP id u191-20020a6385c8000000b0046ec387c85fmr22258571pgd.105.1667405497249; Wed, 02 Nov 2022 09:11:37 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:36 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Ryusuke Konishi Subject: [PATCH v4 20/23] nilfs2: Convert nilfs_btree_lookup_dirty_buffers() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:28 -0700 Message-Id: <20221102161031.5820-21-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401705406429179?= X-GMAIL-MSGID: =?utf-8?q?1748401705406429179?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). This change removes 1 call to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/btree.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index b9d15c3df3cc..da6a19eede9a 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c @@ -2141,7 +2141,7 @@ static void nilfs_btree_lookup_dirty_buffers(struct nilfs_bmap *btree, struct inode *btnc_inode = NILFS_BMAP_I(btree)->i_assoc_inode; struct address_space *btcache = btnc_inode->i_mapping; struct list_head lists[NILFS_BTREE_LEVEL_MAX]; - struct pagevec pvec; + struct folio_batch fbatch; struct buffer_head *bh, *head; pgoff_t index = 0; int level, i; @@ -2151,19 +2151,19 @@ static void nilfs_btree_lookup_dirty_buffers(struct nilfs_bmap *btree, level++) INIT_LIST_HEAD(&lists[level]); - pagevec_init(&pvec); + folio_batch_init(&fbatch); - while (pagevec_lookup_tag(&pvec, btcache, &index, - PAGECACHE_TAG_DIRTY)) { - for (i = 0; i < pagevec_count(&pvec); i++) { - bh = head = page_buffers(pvec.pages[i]); + while (filemap_get_folios_tag(btcache, &index, (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch)) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { + bh = head = folio_buffers(fbatch.folios[i]); do { if (buffer_dirty(bh)) nilfs_btree_add_dirty_buffer(btree, lists, bh); } while ((bh = bh->b_this_page) != head); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } From patchwork Wed Nov 2 16:10:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp6056wru; Wed, 2 Nov 2022 09:16:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7FLQ4ryHuZ60uOY7v8B+Zi5VdK5NbZ/tp50Oj4RYLKsZVbWtCoxAcWS4LVazaMQGIMrnGn X-Received: by 2002:a17:90a:b904:b0:213:f5ec:3915 with SMTP id p4-20020a17090ab90400b00213f5ec3915mr13779139pjr.33.1667405795813; Wed, 02 Nov 2022 09:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405795; cv=none; d=google.com; s=arc-20160816; b=W6W0N2ruhsXSuJ1Zpaa2dW052cAHXjpKa6nZ8nzYBZQuqeOPOyN5ph7KBrFuCPxLYA 7UvddJLtcKCqEY9S3ALxyIi1m+a4TPYBLTT/Mw2SaRE7wTvJadh1O+nhJIURrRLkCACn qbqSiqCF3ZBqFoQjXwqjG16eMYET0rq3OUkNENLrw/yTGAK48Kdq7+CfPyBei24k0JLs vC/CnkkHO9Aob+EfjL/SiELnsqazvGC5IO13xME+VZBtcbCCwxH3eW8KeFDqztMrFX36 B7xsoFCaOSpyYve4zFaHTkmoDqRW4laMZHv0ZAr1/P0QhUONzOINHmsVevqIFF1iWM7L VA1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zdjIiLbt6NZs/+ugsh8p0DToyI6+NA6EFXmKyQS/uaI=; b=n/iHIHKvMWOCh7JETDvM6dvYEbl5hfq6Vz6vNZcDrfpG8I70WJr3IPuYOhs5WmH71z /21GjdxJcxR1aZFo9FqKNw0BzH71AdAX/J2zvV9s3YBc+0az6sKIHGbjNGstmCnG1gY6 PMTtvmwOyOXp+qA7LToTDSPCBxVyh+pdvQHFUyD2NB0HLLC4K7YZfN/+YCbN7vj1oNNt wySdKuQXzVVTB+E2LvRJSL4BPvlzx+Owakrqsegw7/NBkyP9mnrXMSFS9Y2gviHjBmiD VAS2JLsDKIwIsxxJPdaulDCxMiY+DD3hzqH4kmgLQowBPjdwMwcS/uqfhEgVFn8zcSun P34Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="dnw/Y7Sd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d16-20020a170902ced000b00186f22a06bdsi16030261plg.459.2022.11.02.09.16.21; Wed, 02 Nov 2022 09:16:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="dnw/Y7Sd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231740AbiKBQNy (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231640AbiKBQMI (ORCPT ); Wed, 2 Nov 2022 12:12:08 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ABD62D1D5; Wed, 2 Nov 2022 09:11:39 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id v28so16646057pfi.12; Wed, 02 Nov 2022 09:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zdjIiLbt6NZs/+ugsh8p0DToyI6+NA6EFXmKyQS/uaI=; b=dnw/Y7Sdt/2yswLfUwe7rf3FamG1uOa+Cme4BQysz6O5GJju2KxY/lGLFeRfg3fP7F gusz6QFWiXK3Emskoxdh85TotdaoyDyH+kDkBo55CuXGPS5jgjmyY15TzCw5SJdm/Und Pe28CM7DVUvGUwOIf1oO6mSePnJQCQlGwEwLCjujRil72gYP2VXxqrNEY2Y2A8eBJRNr 6SM+6en5d7DcLIdBgiDQSKo8zoKuWtwZRdiHWF+RAAgco3tzrrCbCJhmkzEEdqzxvKka gMha+qpnNfslZTnKojM1KOTJPxVbBbMJ8BYFTrGc9EfVhhAKpe6HIgIjjlnkj/wKgw8P /0BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zdjIiLbt6NZs/+ugsh8p0DToyI6+NA6EFXmKyQS/uaI=; b=FUEId2bu/jqaxoUsuBVhZMNSUTZcJfu2uxenaXXnm2N5TnBbK6OsVI+iKq0nnLXluM dlSi5bEkCqYzlZthHviyRjQ6ezM9yiyfket7XpyvcBctidREIZHBSaIXO8+Q9w3RUNv4 /bJ3ZeR99klz6dgY3xz2DB7PebQEPEGGHYCla575MRhwXXqrcIIb6SyprLSlf0KrXvp1 NVkIJQEvT3PmrvubtSMCr6kJl5774VY6kyU1TdxL1VPvVUwhnb2deEL6OhbK66xv5L48 Rc7vBFWP7u61qCP/SgCLjHUpGvvEK6HFiR1W5PT5q5oYHddO7hyH23gSe5Ytn4TdxTLj 7uNg== X-Gm-Message-State: ACrzQf16jaLXDBlo8mSjC2CI0TgindfbhY3obR+eXl9ZyDPGlgnn+JDw aDfwWA95li6q7k50fzygQXQbd4vGj05e3Q== X-Received: by 2002:a63:4949:0:b0:442:b733:2fae with SMTP id y9-20020a634949000000b00442b7332faemr21682136pgk.424.1667405498578; Wed, 02 Nov 2022 09:11:38 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:38 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Ryusuke Konishi Subject: [PATCH v4 21/23] nilfs2: Convert nilfs_copy_dirty_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:29 -0700 Message-Id: <20221102161031.5820-22-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401699698208532?= X-GMAIL-MSGID: =?utf-8?q?1748401699698208532?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). This change removes 8 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/page.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 39b7eea2642a..d921542a9593 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -240,42 +240,43 @@ static void nilfs_copy_page(struct page *dst, struct page *src, int copy_dirty) int nilfs_copy_dirty_pages(struct address_space *dmap, struct address_space *smap) { - struct pagevec pvec; + struct folio_batch fbatch; unsigned int i; pgoff_t index = 0; int err = 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); repeat: - if (!pagevec_lookup_tag(&pvec, smap, &index, PAGECACHE_TAG_DIRTY)) + if (!filemap_get_folios_tag(smap, &index, (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch)) return 0; - for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *page = pvec.pages[i], *dpage; + for (i = 0; i < folio_batch_count(&fbatch); i++) { + struct folio *folio = fbatch.folios[i], *dfolio; - lock_page(page); - if (unlikely(!PageDirty(page))) - NILFS_PAGE_BUG(page, "inconsistent dirty state"); + folio_lock(folio); + if (unlikely(!folio_test_dirty(folio))) + NILFS_PAGE_BUG(&folio->page, "inconsistent dirty state"); - dpage = grab_cache_page(dmap, page->index); - if (unlikely(!dpage)) { + dfolio = filemap_grab_folio(dmap, folio->index); + if (unlikely(!dfolio)) { /* No empty page is added to the page cache */ err = -ENOMEM; - unlock_page(page); + folio_unlock(folio); break; } - if (unlikely(!page_has_buffers(page))) - NILFS_PAGE_BUG(page, + if (unlikely(!folio_buffers(folio))) + NILFS_PAGE_BUG(&folio->page, "found empty page in dat page cache"); - nilfs_copy_page(dpage, page, 1); - __set_page_dirty_nobuffers(dpage); + nilfs_copy_page(&dfolio->page, &folio->page, 1); + filemap_dirty_folio(folio_mapping(dfolio), dfolio); - unlock_page(dpage); - put_page(dpage); - unlock_page(page); + folio_unlock(dfolio); + folio_put(dfolio); + folio_unlock(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); if (likely(!err)) From patchwork Wed Nov 2 16:10:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14349 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp6190wru; Wed, 2 Nov 2022 09:16:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6SjJUjsnLMMWYZbutf6ryRAiFnf/aK9+yVMPdWmxbY5oqewqAzgLXeiGHOj0VIXmHkGHZc X-Received: by 2002:aa7:de81:0:b0:461:2122:a807 with SMTP id j1-20020aa7de81000000b004612122a807mr26039892edv.382.1667405815391; Wed, 02 Nov 2022 09:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405815; cv=none; d=google.com; s=arc-20160816; b=FT39+3+hQwj3NXgkqEgmtKi6/ADTkNbL9wC9kK1Rib1VQKOjlBTRdKCI4E7J/uY028 Q7MRNP3AyzWrfXXsz/0YwJ5v9NtMdYih57XWRrPToVe7ciIHpc1NoxUse7URCjyp6pg2 6UnRUBN7CotPy9waoJ6EVTveL1qGdGWJ8Gn7CXAbLUlPtky0CwJdyVbMkXfNT09afid3 wAU/x00TwOGUeUYJTAqtVHU3v43qfQyIM1nd9DpZMOZ/VNGsLwehUDdsAKL1LRjIE7sw mRqouEPLKJFR4c5dcowMkx+MapFzLM0ZF4ko7Dl38amEtF1glto7q4IHogvyn38B1yf0 kJlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=T3e61Fb9Dqh0rLEzgpxaQ/B901JahzW9QwTImcYRDNk=; b=WBUeM41Jd5/MXQ0rzd3ekevHgpI5wh4wZ/d/N8Fuxhy3kvrCQb9iRkewC74oT8euHO FIENRmRZDbeuywaGHt54n6CCEekFNDV/uBDotcs/7xYNhrk69AUmyhxVXgHGrUJTMYm0 Tty0L8ywfvqMH4wisCdNv6BTtnfaNs0LoFlKbWMNRJaBCRpdl7fbZeo0k//GBnsGVmHm uxYhl9nViYc3+c9WteK5s/z6QnVuY06bjjzpicD+7qYBcDNV1AYa/3SnnIOjEjs8c0BX 8GPW2nWgfXedAdz5svBVDENdFIka2NXuNYvWM7fqmRLN0MmBw+5kSjJjJr0eX4rh73ZE 5sIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pqx1PJqO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk34-20020a1709077fa200b007ad8bc64c89si3391992ejc.701.2022.11.02.09.16.30; Wed, 02 Nov 2022 09:16:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pqx1PJqO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231812AbiKBQOA (ORCPT + 99 others); Wed, 2 Nov 2022 12:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231631AbiKBQMI (ORCPT ); Wed, 2 Nov 2022 12:12:08 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8808B2C674; Wed, 2 Nov 2022 09:11:40 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id b1-20020a17090a7ac100b00213fde52d49so2314784pjl.3; Wed, 02 Nov 2022 09:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T3e61Fb9Dqh0rLEzgpxaQ/B901JahzW9QwTImcYRDNk=; b=pqx1PJqOgEaKfUss0nxJak4n84vFKOvzq3ESyrjGFD8v8ROxU3CQGdvwQuKFd1I/w3 dCJ41EX/Bok9xslgktz6xXZZB5vDFu5BXOoWGO34UzLTcVVzuhGdIGcQHvEi5gNg3GSQ gscxO1Gb4psr/vsFsU/1JpKGLnKfg3l6eDymWIA8qk7+XrNzqRLz/vgtPRF4DPnVnb4T PW63xls+m/+8H/fBE5siUOyqDVnX5GNrTviD0Y18uYcvd2toxW0MDmiLDFy+p7D7UQQ6 IBU8URj3sypjIFT2nA8r21p6YwsgewrtbGGcm7sfWsWRu0sZsqZoVeMOaVhnUYxkI+jf hvVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T3e61Fb9Dqh0rLEzgpxaQ/B901JahzW9QwTImcYRDNk=; b=YmUupG7+40vpkFo5FeZHeZnyBRgb0unk3+IU0m9KM5NHl9y6ROwcmCSUppd0EEDalu +W1hmKxby4hrpumwcvQoj4kx0DRgVslNeMWmvCcdj4XK5pG46B4S1cje9EeGX6ewEG3N 7XdL8KSM1lnk8K+ALUvlFDeBafim3mVmdtHwaIBINvPZ18QH/BEqnRUnj+ZUXigDzieG BvSbBGjp/4hrAQCfXRaybXRn2TNF9yyNaTx48fKnbnT4U/kC9HfRmer/4f885HkFaoyP fhcq1hUwxbE0I50ikAUP9eWVO66ERYjiFPdrn7xl/WvWeP4A/NwLGCY+C30nPnNy2vQx 81wg== X-Gm-Message-State: ACrzQf3k/7kEwfKo9QksgZqWKkqzuFEwwTo23NnDvK6HCfm99WDqtq8L /T0Vr61yF909TJX7prGCx/zsU4NRkbfStw== X-Received: by 2002:a17:90a:9a8f:b0:212:ea8d:dc34 with SMTP id e15-20020a17090a9a8f00b00212ea8ddc34mr45089840pjp.30.1667405500003; Wed, 02 Nov 2022 09:11:40 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:39 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" , Ryusuke Konishi Subject: [PATCH v4 22/23] nilfs2: Convert nilfs_clear_dirty_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:30 -0700 Message-Id: <20221102161031.5820-23-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401720608730909?= X-GMAIL-MSGID: =?utf-8?q?1748401720608730909?= Convert function to use folios throughout. This is in preparation for the removal of find_get_pages_range_tag(). This change removes 2 calls to compound_head(). Signed-off-by: Vishal Moola (Oracle) Acked-by: Ryusuke Konishi --- fs/nilfs2/page.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index d921542a9593..41ccd43cd979 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -358,22 +358,22 @@ void nilfs_copy_back_pages(struct address_space *dmap, */ void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent) { - struct pagevec pvec; + struct folio_batch fbatch; unsigned int i; pgoff_t index = 0; - pagevec_init(&pvec); + folio_batch_init(&fbatch); - while (pagevec_lookup_tag(&pvec, mapping, &index, - PAGECACHE_TAG_DIRTY)) { - for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *page = pvec.pages[i]; + while (filemap_get_folios_tag(mapping, &index, (pgoff_t)-1, + PAGECACHE_TAG_DIRTY, &fbatch)) { + for (i = 0; i < folio_batch_count(&fbatch); i++) { + struct folio *folio = fbatch.folios[i]; - lock_page(page); - nilfs_clear_dirty_page(page, silent); - unlock_page(page); + folio_lock(folio); + nilfs_clear_dirty_page(&folio->page, silent); + folio_unlock(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } } From patchwork Wed Nov 2 16:10:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 14350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp6564wru; Wed, 2 Nov 2022 09:17:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7XDxqt9jYLwQSYlRcJ7mO6yDn114TFziRaHwoLV77OdrmNUOMheEAeeRhX9xlwYEibKJ/A X-Received: by 2002:a63:d744:0:b0:46f:1a6e:1a2 with SMTP id w4-20020a63d744000000b0046f1a6e01a2mr22212965pgi.226.1667405873714; Wed, 02 Nov 2022 09:17:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405873; cv=none; d=google.com; s=arc-20160816; b=UWS2XYaqHcexRoMrBmBu1+rvqNbAyFiqtIJNEDcFGTrXLHYkIWPRGvlTT2NMIiqhB1 2rvCK5uK4a5WQ9bkzVYpXi13dDSnhO+JLuGX9LTUvdX9ncbUoOUPOATEq7o5LRYx73ch 2U+CD3TGAK0fezZS7//bzGL2g1uIQcy6GYh/4CRUEaW3rbatSqLiC9Ixa69/oW/y1ukz QLSM8f+rH8C0Mz8XX5HU/e/lkf/5iOeFhbTILffe0QxTWvP5QqS4dlIkP9Z7EZOZ89s6 1YS82/fCfBN2igLg8VJkvOAckTmS6/7qPQf5N4XMOJGKVtE6npKoYpOwIX8IVAgWiU4B YhGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0kIQ32jgESZghl2JsFuRf0mmCK8FvEn1HKHvqp4B/UI=; b=kGOYcSkqlP5Un3mRkXbKwFx6hZrkckHf75b0j2LEG8dmH5BadLFfmRKDeGxcavJ9rw pTsSkeP5ToQ7Hb2b5wKkWF1bNQ+zLLoxxZg7za41nmooSQ+n6WLVA0zlkpRqdw1DkFge Esp4NmaNgljbye3ggaXkvmnWtcfo/8RBjktPEiX1ob/vlRN72J0AqMqt7xMGN9ukdUwW sKygkb+Qb7v2fsgchdypg6Z1YYHvo96IIPc7mQGZuj1hpbCdjwUi8dgE2xsCXEXQYItt AirBD0TgFcuXZCVhT2uaT/obs/r9iS+MAkqfAYQQZyNEYnDc9kVCo+onK+7LDm80JmJn EmIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dfQedKuy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a634e11000000b0043adff6d43dsi16640244pgb.583.2022.11.02.09.17.37; Wed, 02 Nov 2022 09:17:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dfQedKuy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231725AbiKBQN6 (ORCPT + 99 others); Wed, 2 Nov 2022 12:13:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231638AbiKBQMI (ORCPT ); Wed, 2 Nov 2022 12:12:08 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A6282D1EB; Wed, 2 Nov 2022 09:11:42 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id v28so16646178pfi.12; Wed, 02 Nov 2022 09:11:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0kIQ32jgESZghl2JsFuRf0mmCK8FvEn1HKHvqp4B/UI=; b=dfQedKuymKKcgaBkhG/S6LPnJ2O+4EvsNOgODJ6HJIVIONp85PHUPikgR1OK0QEXN5 yllHZOH3ybASQiMP5BnKEWHTPiCoHka0zDja58Ru610nhX2hFD55wJ8Gd376sGcaf689 bZrfvpTt8G5QxybOH/Q6elDPBkfe6Fc3kWWsMNhs/R9vrbLsrZ8uD+rka72YKKWWWGgG dWU5w6rAAJp2LD2+bLNGgBA0LMOcxmf8XyqrkCvTB+U0KRHPVRqOWqltLY33KWJ08EtL x4VuHCxKqbKwgsffO/TRtj8XIVLeukEUR03vIqJL55yVembQK6w940oX9YlEtm9O5Cyv atIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0kIQ32jgESZghl2JsFuRf0mmCK8FvEn1HKHvqp4B/UI=; b=6V02c71ba8T+nKh7BAlS7W2AqHWrezXEd4LxWsbGLZ1bzT0PZeZDx8v7CfllOB/7i9 0owbRQcrwU1nZEngObNKxPn6xOKCAy7ZcmmuAp2HzZ5zpKF3OLhtv6qxrjG9cZFCe8Jy E8/yk0SbdkQH1S4RM7ZsDsp3kJrOrIr2Dzqdad1r8DFmGKq60xjeIKki9L8NERBVIDMu Z5XhX07zvyMEKyLqhBemyZxjjjCI1UPZn0VOLGK3fiNpfoNaI5z1tXLZqtzD41bXDKsp EKs2s/qggp/13SsVnmjfaH63qn7omzqrCQ3aVsi4Y2ImQZ+VA0O3Z1BWs8QZs/qSrDqc flxw== X-Gm-Message-State: ACrzQf0yZl7dMe7mSsF1f0BlRUhM1iSe1xSNTvNZWINFXf1azRmW53d8 rGAo4kGpcWO+egK2FsLHTUUmX4Uz6ewviw== X-Received: by 2002:a63:5a1b:0:b0:461:9934:6f62 with SMTP id o27-20020a635a1b000000b0046199346f62mr22432948pgb.266.1667405501408; Wed, 02 Nov 2022 09:11:41 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::8080]) by smtp.googlemail.com with ESMTPSA id ms4-20020a17090b234400b00210c84b8ae5sm1632101pjb.35.2022.11.02.09.11.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:41 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, linux-mm@kvack.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 23/23] filemap: Remove find_get_pages_range_tag() Date: Wed, 2 Nov 2022 09:10:31 -0700 Message-Id: <20221102161031.5820-24-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102161031.5820-1-vishal.moola@gmail.com> References: <20221102161031.5820-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401781592677741?= X-GMAIL-MSGID: =?utf-8?q?1748401781592677741?= All callers to find_get_pages_range_tag(), find_get_pages_tag(), pagevec_lookup_range_tag(), and pagevec_lookup_tag() have been removed. Signed-off-by: Vishal Moola (Oracle) --- include/linux/pagemap.h | 10 ------- include/linux/pagevec.h | 8 ------ mm/filemap.c | 60 ----------------------------------------- mm/swap.c | 10 ------- 4 files changed, 88 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 28275eecb949..c83dfcbc19b3 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -742,16 +742,6 @@ unsigned filemap_get_folios_contig(struct address_space *mapping, pgoff_t *start, pgoff_t end, struct folio_batch *fbatch); unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, pgoff_t end, xa_mark_t tag, struct folio_batch *fbatch); -unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index, - pgoff_t end, xa_mark_t tag, unsigned int nr_pages, - struct page **pages); -static inline unsigned find_get_pages_tag(struct address_space *mapping, - pgoff_t *index, xa_mark_t tag, unsigned int nr_pages, - struct page **pages) -{ - return find_get_pages_range_tag(mapping, index, (pgoff_t)-1, tag, - nr_pages, pages); -} struct page *grab_cache_page_write_begin(struct address_space *mapping, pgoff_t index); diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 215eb6c3bdc9..a520632297ac 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -26,14 +26,6 @@ struct pagevec { }; void __pagevec_release(struct pagevec *pvec); -unsigned pagevec_lookup_range_tag(struct pagevec *pvec, - struct address_space *mapping, pgoff_t *index, pgoff_t end, - xa_mark_t tag); -static inline unsigned pagevec_lookup_tag(struct pagevec *pvec, - struct address_space *mapping, pgoff_t *index, xa_mark_t tag) -{ - return pagevec_lookup_range_tag(pvec, mapping, index, (pgoff_t)-1, tag); -} static inline void pagevec_init(struct pagevec *pvec) { diff --git a/mm/filemap.c b/mm/filemap.c index cc4be51eae5b..8ad45c2e22cd 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2318,66 +2318,6 @@ unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, } EXPORT_SYMBOL(filemap_get_folios_tag); -/** - * find_get_pages_range_tag - Find and return head pages matching @tag. - * @mapping: the address_space to search - * @index: the starting page index - * @end: The final page index (inclusive) - * @tag: the tag index - * @nr_pages: the maximum number of pages - * @pages: where the resulting pages are placed - * - * Like find_get_pages_range(), except we only return head pages which are - * tagged with @tag. @index is updated to the index immediately after the - * last page we return, ready for the next iteration. - * - * Return: the number of pages which were found. - */ -unsigned find_get_pages_range_tag(struct address_space *mapping, pgoff_t *index, - pgoff_t end, xa_mark_t tag, unsigned int nr_pages, - struct page **pages) -{ - XA_STATE(xas, &mapping->i_pages, *index); - struct folio *folio; - unsigned ret = 0; - - if (unlikely(!nr_pages)) - return 0; - - rcu_read_lock(); - while ((folio = find_get_entry(&xas, end, tag))) { - /* - * Shadow entries should never be tagged, but this iteration - * is lockless so there is a window for page reclaim to evict - * a page we saw tagged. Skip over it. - */ - if (xa_is_value(folio)) - continue; - - pages[ret] = &folio->page; - if (++ret == nr_pages) { - *index = folio->index + folio_nr_pages(folio); - goto out; - } - } - - /* - * We come here when we got to @end. We take care to not overflow the - * index @index as it confuses some of the callers. This breaks the - * iteration when there is a page at index -1 but that is already - * broken anyway. - */ - if (end == (pgoff_t)-1) - *index = (pgoff_t)-1; - else - *index = end + 1; -out: - rcu_read_unlock(); - - return ret; -} -EXPORT_SYMBOL(find_get_pages_range_tag); - /* * CD/DVDs are error prone. When a medium error occurs, the driver may fail * a _large_ part of the i/o request. Imagine the worst scenario: diff --git a/mm/swap.c b/mm/swap.c index 955930f41d20..89351b6dd149 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -1098,16 +1098,6 @@ void folio_batch_remove_exceptionals(struct folio_batch *fbatch) fbatch->nr = j; } -unsigned pagevec_lookup_range_tag(struct pagevec *pvec, - struct address_space *mapping, pgoff_t *index, pgoff_t end, - xa_mark_t tag) -{ - pvec->nr = find_get_pages_range_tag(mapping, index, end, tag, - PAGEVEC_SIZE, pvec->pages); - return pagevec_count(pvec); -} -EXPORT_SYMBOL(pagevec_lookup_range_tag); - /* * Perform any setup for the swap system */