From patchwork Wed Jan 4 21:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13088957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B004C54EBC for ; Wed, 4 Jan 2023 21:15:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF7418E000C; Wed, 4 Jan 2023 16:15:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A7F848E0001; Wed, 4 Jan 2023 16:15:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 834A88E000C; Wed, 4 Jan 2023 16:15:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6BCC88E0001 for ; Wed, 4 Jan 2023 16:15:11 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3CC7B14053F for ; Wed, 4 Jan 2023 21:15:11 +0000 (UTC) X-FDA: 80318372022.02.2CA825F Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf04.hostedemail.com (Postfix) with ESMTP id 6B01B40012 for ; Wed, 4 Jan 2023 21:15:08 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ANmSn8BX; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672866908; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wfZkCFUzCyr5OXa7ytE85YOM9f5TCt/N2uJtwdJBiOM=; b=lecJV9tMeV5Cdx8bZoFq7VY4hke7jK6YxJdNePSjdCcSMbVbS2kOucqla4A1xlEr4v7haP 0TOAj5VMjLwxncqjoOgCFMBhfrPrkur5ci1UzkEF3AzpVMaAkIEOF540bWxtFZoCUyhQey lALXD8VAalXr1UZ0vINPpt77wtRmsI4= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ANmSn8BX; spf=pass (imf04.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672866908; a=rsa-sha256; cv=none; b=J3M4+auDJ+zEKyUDwBhla783K45HR+4zVPnT+Jv0uspKdG8op1gOOG2hiE4ezTPj07CVFT dB1jXZK//DJxda3Y4hUAOffUOLeBmHuD+Era8yxMG9/M56tQmtBlJBhQtBjtv4Rs/ke5J5 ORRkvYpuJ4oNpOHkZIwaP5RYt2cQmxc= Received: by mail-pl1-f170.google.com with SMTP id d3so37194760plr.10 for ; Wed, 04 Jan 2023 13:15:08 -0800 (PST) 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=wfZkCFUzCyr5OXa7ytE85YOM9f5TCt/N2uJtwdJBiOM=; b=ANmSn8BXHVDz0ywhmRcvLuF8DmLMxQ93lpCBxWPoHvl/LSFXfzY43Ai3sHGITPHyQv UGZzlKZDcI52wvQqJokP4vvvyYwFacbOTKHFKBLZTgqtGB7SlcKPR1/yEL1Rk/1RY7FV tlrzh6yP+L+Y3+ZGkeUhuel3RvMqL9274p714tcLuggAYT99ceFPsKAH/YBG+2giTF1e eyw4SncaR+Kt5OfkjfrFa7F9COcHovEDwjB/dlalyP7DZPUQV2SabwF4hhl1H5GEIbyF 4m8vBFV3aeKB/xxOyyrXqMrlT7asP5ajHmmGEgqtrEunzP8BT+cK8xe4xARR13Gku/PW jpgw== 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=wfZkCFUzCyr5OXa7ytE85YOM9f5TCt/N2uJtwdJBiOM=; b=kZhlIH+1RABDoi47i6zSsv06B5eUR6T6+km5fc/xJU2eAFrTZ0T5eedtms00G+cOWE ncCgrTSQYVgp0rV6zi98X3ljq/rfqKCb/p0ffiwnINUgWuKIv8T26j2W+V/0TjXFI2Jb Sop5mxzY8kL7gwXDWWePqGwD0L+eJ0ef2KPq2mpWCuOLHFvFwzyUscI7TwdEgoO6/JGN 1rd8iGXKkJ4GxzY7E9+q8iGfFTAzeYIwuPiuWaKuaTyLeG3RkMy8Or5cnLq/wbd0+bFL V9kQKlu1W9LCZqE8bqkuCI7MfKnozemUZ4h6dF8qsb6ww2Jw6nCuQApyUBIUJwwFY4is 9PWg== X-Gm-Message-State: AFqh2kqLZVOCwfCvsYOtfRVbPtZZMiscmA8EyR2ARBcEfOUKTY7PSLGa eMkbiAIhiRVA6jXdzwXcrazmSQNwRU6SJg== X-Google-Smtp-Source: AMrXdXtAkt1PiXf89KpZT/PVVs6pHX6w2TYw+klecmBeo8HqViRecFRkPGwHQvT7jR7OxpCa8lhGxg== X-Received: by 2002:a17:90a:5d08:b0:219:4578:6409 with SMTP id s8-20020a17090a5d0800b0021945786409mr52643871pji.41.1672866907758; Wed, 04 Jan 2023 13:15:07 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::a55d]) by smtp.googlemail.com with ESMTPSA id i8-20020a17090a138800b00226369149cesm6408pja.21.2023.01.04.13.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 13:15:07 -0800 (PST) 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 v5 08/23] ceph: Convert ceph_writepages_start() to use filemap_get_folios_tag() Date: Wed, 4 Jan 2023 13:14:33 -0800 Message-Id: <20230104211448.4804-9-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230104211448.4804-1-vishal.moola@gmail.com> References: <20230104211448.4804-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Stat-Signature: bb94mgrody6kmofbjbj9urmq3fmwtoxo X-Rspam-User: X-Rspamd-Queue-Id: 6B01B40012 X-Rspamd-Server: rspam06 X-HE-Tag: 1672866908-165049 X-HE-Meta: U2FsdGVkX1/YTAmoFi8wri+AS8BOd7RUsaEB8oEMT4O20qZPtvD3Xh27BpwQk+3Nod5WDMQstxDCWAwfyJTLM8k/MJ6IMj9qQ1/jeoovuWIlxW9qGsqkzjqsZhBuR0xNUHFnPiHVTKB5pJ1tX59/d6t6bleQ9NZjnDt6SKZjOXEf0dhxwxoiHB3uWEnQC21NebIjNNPo03Ow+cJt4eeYWNRmkx0RjYRcQ5l3mZVfqtM7auLJKdbqpey0WGdVy8BLAzwy8+zFdfPdwmxR/YV7MVPX8ofMo7w9HFI/ZKueRL/clEbW5kqSlxiKvYLpmQKxb/BszjezW1v5fIPCMSwME6sW44BjnuoyUwXEVq4udPPAqidWuZGxtO0y7hGSe+6akBEiiITI2e5RXpCHh2364dnmYOWd4yCIYFn94kbXvvaEblnW+gI45A3kccno6fGsicIqIQ6613u3BeV/ASmpUQe/YFIk0WRVN4rlFlVRK9EzDF74CeTzp2luDc32diKTUvRqsH8CX/+mPWw0IbriQyUZOvM2y+t0kXEOD6DqkNZgLrtnfB0TiQXHD4ag1LCiQpgA88H1d4EpHXuIQ1cBEg7HHjft3Zre728ed+hseasOUxjPKMMYoCSf4BL6BbGSHPpICUkURdZdmVC47apErWYRSW35fPtskysyBkLWW5zoeG4GplMP2xYo02ANii5yyVeVh4JXwUeZ7NCHzoJTjES9FtBLZZM2QJHUMKsK8J8yqqXkl6ZwCMIIVYzxGP9fXOtpHQc55plJyzKTnMA+Bn8JE6JdmRfaJmdVmBDdNEBSb7SXTQMXmihfeSYzp2Y+Il74q0YquVi1uYVLM2uNrtSrCp3qC+lak05q+2XRMNL8MjVnpAvy8rAgNrHwhebm/nZaLj7ktT+fepY8BwSd1nA7C/wef63vrz1QHtCCR6/XZ7p6Yoibo0tu5sVImcOZQMuq46Gdlkz908Euww7 cNHbSapK wRHVwIuHT4vRmw0XYsgdbYAG3zO6eTjc6Rt18tP79s4dmVeXYpbPPDPK2HKjq0Yhc1GmgIVhBQwo5WAByuNwaTxEWyIhect0G/ngu9Y/fZbWsg9rG00wKAGpilRkkNw6UEKpKRddNXMbUKDJ03ctgzg1CgYKpLoi7jIyOmlqa1DnFNPGaEcLi7EdxzOAoD+ucJZkqYHoq2cKj3ooiHXPaE3qlqDZuVPpSokTWdgzGzWyCToeZEGg5HqyRKhqYzCkOIuZAATbmNYxHRB3VUuux67Z23oI62KNVzKuA X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 8c74871e37c9..905268bf9741 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(); } }