Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp50237rwi; Wed, 2 Nov 2022 09:13:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5lMABn2eTkVS4PVOFXvXjupnFHMcrpso4vx3sUz6BwEDj7nklmsx7iPRA7HN3Rlb/p7KHo X-Received: by 2002:a17:907:78a:b0:78d:9ac7:b697 with SMTP id xd10-20020a170907078a00b0078d9ac7b697mr24082522ejb.457.1667405584986; 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=LdW1DUBxXod+z+/QxTJfurZ3wzpKToQdmvQ60vv4x/9Uu2alXiN2d+BkXUAdIk+ckW SOzYaVF7mGLLMdVIysUUfM5oIncAtvyH9brCGNQ+w5wvvNmIz7wk5i1ykWHvscU3BtCV kau3H5LFTDceLGisT4bITarq1umx3CMGdrZv4Hb0khtxg7AM1C3XpPO2U5N/0F1A6Gic xXqP1w3nCssJHPflJa+Jshj2ctut5YkEr9X2S5NvvFGCIM1pzEtM4Yqi+e/hckXAl7Rk 5ZFgzdUY5kPVD5xFe4Jv6h+qJPJjEtUXbaLcLvx3LjSwLIhWaX10tbuUhPgsKPaj+iGl PM2A== 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=sURVXA/O9ALV5rZWwG+Qv9BavGFdrv2Ah2PUQ7ij0D65U/IMChyi18uEZ15oGYybg9 avcyVMDgfSjmeEedKgwnJCRVkVmTBuHOVsiriSnVz7UkUC7/Ip+A4xYWyDLy24tAdWRZ 519o8/3M3dxI9d5kC+oQpfj6GTJ3ppfK+l0IOIDD1cUfe9H2Mnw3/i7VHAb2n7l8cQPy K50qjgF5aD67/ssCSGzvSepZDXxfVe5bfe0pHH0+skhUAzgC/bC0BK5NFDAtsgVSGDFa jQgB6CqooIF5uqZtIxM84E3AKjHk7LbF2KZr1rl01U6KHalui6Og/8h4EcmKqIbrjLfx KKPA== 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-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be7-20020a1709070a4700b007a087cce094si18440182ejc.512.2022.11.02.09.12.42; Wed, 02 Nov 2022 09:13:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 S231531AbiKBQLv (ORCPT + 99 others); Wed, 2 Nov 2022 12:11:51 -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 Content-Transfer-Encoding: 8bit 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-ext4@vger.kernel.org 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(); } } -- 2.38.1