From patchwork Mon Oct 17 20:24:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 3715 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1629839wrs; Mon, 17 Oct 2022 13:30:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7KdIg3RRp6jOKxMFHu/Y2bjatHw+7A4kb+MgOn/8cSzeqy5EjAMp/HRINcsCGQn0aOxZ/7 X-Received: by 2002:a17:907:1b1e:b0:783:8e33:2d1c with SMTP id mp30-20020a1709071b1e00b007838e332d1cmr10154325ejc.304.1666038625740; Mon, 17 Oct 2022 13:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666038625; cv=none; d=google.com; s=arc-20160816; b=c4fLr3X1L00qA+sX3YtubyUlAbz6m9xyh3nLnHP5cvK2JZakV7ZMCgg/2TKXH5dDKY LXYqdjgtdrMe6Z0kRF2Scoy6+ClLjCR37oRTL7UZ0Y5eZTgx+Mh+rF0qK3co3B7u3c2a 3+F40IbwgoRxhK2Y6ngK+ZMQJ0E+36UluSyOKWrHhG92HguzL2EjinLzVsQqRKNraKXA wXMda1UHKi7m4Pc/dP+nYqkfj7VgCLgaZ3nSHRXytcKQaU4fbEflQmDzIMyvCf3US9qH idu9lvCek/E+MJbIbv1tNslEVM2oZLbYUzpd7xWnIbhbugpnd0exIz1a+F0d/NoGD3kB d0lQ== 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=UKjWA6ZN/TheYqZsKVsDxcL9aYYtGwA1j96y5Q3bLg8=; b=qyfNfaAE9f2igpMT4TqFHBnOvUzTOoO0qQqYRv/Nme61ag12L2W+wUjquwq7sDFPU1 GBt50fEsmasOLiI/UuTMHlowc6WMJWv1lC2BfD+nF78ZLd/TOD3eXwwwA5gsT0eIaqy+ GZ0Zn/ZLbCh5IuwmeJAu8CbDXvGo8wgKNAnSvZQhOayP3PTkRRvt7kjl21rzSPJKROEv gkW/fRCKzbtx0cXoGcb6NiEiR9aYwAtGGQzyUev3LOPzrEFM1wdGkvAzXQaPgUDkpxpK 24lcu4ay+4Y90tTh0lnMtwYlgMrtDCRl+sbHU3rkXsXfuCQAnDq5wl1TydeCQcrCSFE2 KEAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bA5Qe50y; 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 nc23-20020a1709071c1700b00779f8e7ec5bsi10454505ejc.42.2022.10.17.13.30.00; Mon, 17 Oct 2022 13:30:25 -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=bA5Qe50y; 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 S231779AbiJQU24 (ORCPT + 99 others); Mon, 17 Oct 2022 16:28:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbiJQU05 (ORCPT ); Mon, 17 Oct 2022 16:26:57 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 147AB4F393; Mon, 17 Oct 2022 13:25:35 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id h2so4465571plb.2; Mon, 17 Oct 2022 13:25:35 -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=UKjWA6ZN/TheYqZsKVsDxcL9aYYtGwA1j96y5Q3bLg8=; b=bA5Qe50yNj5Q74nC8AoJWbqxD30sNHXDZRSZjLBU2ggQFOqnFMYZOUdCpT+mhZ+lq2 faSlXwHIGonCA6fUpkF9TlvUtgw/q6Heb3/ZnncPeVsTRrFgCXZeF4p/xm3lRedvgw3W KKSZEuRHBFegZU8TkJCDKngUK1I8Usc/cY0HM7AG/2SXrG2rKfhT3xuYgfj86S9gbCSX IrGZrOKnzQR/yeV1HdzoBMkIs+Ea1Mg1RHmC0magT0MuqnjtiN78JLLz1516GfpIZ1AG tKmy+RCLo5bw3oF7LzYGH6a8yDVV4MfZAq+1BAkjHVnMGsbgv9qe4Ucppkoa20qwLXUS BCSQ== 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=UKjWA6ZN/TheYqZsKVsDxcL9aYYtGwA1j96y5Q3bLg8=; b=FtNCzYwSqPab/TYKK0it2xSw0vN+gcqV70buT+jjF64FCRSeypL0C/25kyw52dFvX8 gxXfwwfSk9i6OBOcqFwCemgkyXXQjAWVP6Pa4aroOiOiQeXTBJxLQW9jA2IdBNz0DPav yUzfWcx3IyAeRFAZWZkKDaumNj//ClG4koNyF1Ez8nmbWMjlPQ+zwvGwAtlt0CjTNg1E Ryb7Cck8AHx9LChZIBmcH3B6wsNaQktVMN1Qytct31OZS+jARXc2yIL/MqIz5K6SkFfY lD6Uwu9TSWrOWhSEAHdpCimDUpJyfKHjo63l+sFH+RPQBv0drwcDTOZbdS/Qft1d9BJm WkoA== X-Gm-Message-State: ACrzQf0NxmCsg2ZnLKWMc6Jogwyg9I15jB6xFxhw9qxYU3YCKX0wTBEv pcgqDNWfGf2x7wQnVaqAKYA7hXwYOmJcyw== X-Received: by 2002:a17:902:f08c:b0:183:9296:8b65 with SMTP id p12-20020a170902f08c00b0018392968b65mr14029611pla.59.1666038302223; Mon, 17 Oct 2022 13:25:02 -0700 (PDT) Received: from vmfolio.. (c-76-102-73-225.hsd1.ca.comcast.net. [76.102.73.225]) by smtp.googlemail.com with ESMTPSA id pj12-20020a17090b4f4c00b00200b12f2bf5sm145037pjb.1.2022.10.17.13.25.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:25:01 -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 v3 08/23] ceph: Convert ceph_writepages_start() to use filemap_get_folios_tag() Date: Mon, 17 Oct 2022 13:24:36 -0700 Message-Id: <20221017202451.4951-9-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221017202451.4951-1-vishal.moola@gmail.com> References: <20221017202451.4951-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?1746968117591704590?= X-GMAIL-MSGID: =?utf-8?q?1746968117591704590?= 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(); } }