From patchwork Wed Jan 4 21:14:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13089066 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 A77BAC46467 for ; Wed, 4 Jan 2023 21:20:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3500D8E0003; Wed, 4 Jan 2023 16:20:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FF058E0001; Wed, 4 Jan 2023 16:20:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C69A8E0003; Wed, 4 Jan 2023 16:20:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 077878E0001 for ; Wed, 4 Jan 2023 16:20:47 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CE4F41A02B1 for ; Wed, 4 Jan 2023 21:20:46 +0000 (UTC) X-FDA: 80318386092.08.31F0B12 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf23.hostedemail.com (Postfix) with ESMTP id 2F5CC140003 for ; Wed, 4 Jan 2023 21:20:44 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OncBz9F5; spf=pass (imf23.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.45 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=1672867245; 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=+xmszoMF+zXuajEbDNQtanZkcgOmS+CJpLcEGks1cJg=; b=SMRV8fYEFl6jOOQjfWQn9b5xWpZKm9WfXCfhoFrPAZEzBX0rHL3e9t16rwR3MHYX29dg2F vUmh64trVucfDsKXnozk5toRUtVu09sZ8ja3HwXwuFWIt92rBqyt658p0a1LqNnr8WhlWq aO6wgURi4qrRlj1Mh6T/xQxjYLXF+a0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OncBz9F5; spf=pass (imf23.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.45 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=1672867245; a=rsa-sha256; cv=none; b=pC2bBV2203IdDDEvD+IeKDB4IOegll6JBayMMVyuLJtIYWwmrGMfHhNd5vNDmNGfLc1XA2 YlSFxA9GxbGtaVB11SKvH09GdmWf8KwWmCOFoETLrKJ0LT0d2tjrlnWL0AlTUIPJJr7733 PLa5igeT+rWOxklSjniXl6fTFaj6hiI= Received: by mail-pj1-f45.google.com with SMTP id h7-20020a17090aa88700b00225f3e4c992so27622427pjq.1 for ; Wed, 04 Jan 2023 13:20:44 -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=+xmszoMF+zXuajEbDNQtanZkcgOmS+CJpLcEGks1cJg=; b=OncBz9F5gBo7cV1EReOGwL58RLiuGeHUNG9zdhd9I0bXKATJ5Zhy+0GmzcSRHZkGqe GWyLzbZvdJd/L2NfcZcScrFyPQDUeVa3ZPsrKxfcBXxNsTmcxuJGYX6Si9XAN/vN44PO JWIeuxKk4kEu/XBQv7tTuvTs0ONLCiFiszBqZ22kD1lrenj6LzRTGJaJ35L4UabDI4X9 oDH4s+R9oGwf42PnMqbTSeqPtDYmsw6Hy03fA74G24fm2HmtysF71GUVxhIByHu1D1Re mLiVQ//u9upm+YXU62JZZsO92EKHd72eQkKl2tPz+jR9e+206/W8Bdj6AulQvLoDfNUZ B5/A== 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=+xmszoMF+zXuajEbDNQtanZkcgOmS+CJpLcEGks1cJg=; b=gBWJNHn3XqATpSaUc7Kk+CyFmdjOJW/g+BcmLvWEyoBmzIDCpi9gPo2gueqqdLTcWs hryShoD8NmffDR1QSJ4BSOvsys9LvFkcczS97B0CCet1Qd0KicmHi4/FUTBRdnj1Qx40 ufz6zlH60+LIVrtOINdHTBfXvCIrdsu88x/vFCXeT4Nr7qEeqSc6oBiv0uPNOwoeTzrk DIONKKnh/AfRCVmnUpCvtIWBrz1iJcuXrZqTJMHKsz25XyXpI+p6xNpNAcyrFnO0mi75 vnhTUqZBhJHawpPIM9P8GEWjP7R5XAJtL674EwrfORYdxCeI9Y9tJeKmX4PNZnTJgEhJ jY0A== X-Gm-Message-State: AFqh2ko3Dr0uZkZkAfJlKToG9OFKiWs7tYm+mLQMk6SyDjW6aCEcBm1U YGD56bN4pnxxhvREZIuIrUcWtcit922kzg== X-Google-Smtp-Source: AMrXdXvHnTnnPFQftwDqWW79TZxt6Ds+PTbYHXL3GxE41AK61UcPUBYk4efjU/wb+K+ueTETX1yb+w== X-Received: by 2002:a17:90a:b296:b0:225:d9e7:2728 with SMTP id c22-20020a17090ab29600b00225d9e72728mr40013660pjr.33.1672866920523; Wed, 04 Jan 2023 13:15:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 13:15:20 -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)" Subject: [PATCH v5 17/23] gfs2: Convert gfs2_write_cache_jdata() to use filemap_get_folios_tag() Date: Wed, 4 Jan 2023 13:14:42 -0800 Message-Id: <20230104211448.4804-18-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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2F5CC140003 X-Stat-Signature: 31n6iaaq9x9kr1pcg71munrqifodmm6m X-Rspam-User: X-HE-Tag: 1672867244-960409 X-HE-Meta: U2FsdGVkX18SbqcYcJSC/VepcBf+2kNZkNK8lfqrCrNGPVeQGSYKU1wTv+7j7rcbrjILwIv+M5jjFjCRk01HDVuZmXM6IXkg1b3P0vBMnJVjEGN/fmC4Ifxez8kiS9/MkSkDRdGJ6I5O5fgpD8AB5Dh9HNU2pn7KowTjJm68wFf3LIlkpnlO5fTWtGxirt+ybdAm0pNJqMDlEKs8l1EONeJlCuXrb2V/94rnSzq9Y1Zjf9smOzIkXJp/52DLY+4hQQU+DllZ0t2qETz3CCFqhhxvPfH6dAMqVbqTcnKJ3prDHzRUigw6m/OFS6VMcZ/mS2QmxK6aamFm4pFQEueb4tf8fiHo349urEpLtGu/V5HKd2xM18DNbBd3Dxvz8Wb+JjTC95ol9rvfQQp0xNH8sCexZLAcR/G5+pxAJbiUo9p0xYM5oms0GUMxNmutZ10MAqOkN1936CANWkgSns3MMfwOFalJjBSSeBtn6Q1/470CQWCUqZ/EA5PROPWDFJXWc5i+DGr5RzFeDn1OZI3yMnz37IepAQfkt4sb8k4ui74rO9i2XVA3kHTOmRV1hOIlFuts/VbC4x1go1OW83e4dIwmtv4Hk5vmx83ign4YMEztYu9ALkjKEAHZ/ZPMevewH804WNGDOh9sFBW0p9OXf5ZmiDTs/5F7zbegLvF5u9PAEq8SkfeJhB6+lsXAOqiG/8sST4NWRhrrbS+WyYOBFlIWOXVQi8PwfYaYsHQz5bb4CIjVmKKJEd+9ou+5hM9boQFnHAMYEtspBkIZhXDIaEFz4LtV8l67BVG22mQpBsaVpYAqLK8oyeN6USKiOjndmUwiLsGxioyTlKY8+I6GLhptSGXiUKLOjVzCjqvfJtjiiWkj6WmyQFapaEqpk7XS+AUQNwWDuKpTjvtbawSNx6qv1N80uKwWW4XiMv3crWm3HUiOtJp6G7LkfaSQ/QtPj4r7p56Wetq5ymiqP+o UKQ+Q1O3 jFRiQBLNqUc1/PyiNTzTFHCl7Qf2adzpfX5ZcTzzNEUoDnL2xHWkkbEBZYcf5+G7Jxc5p5vaAQZ4gz9EvjFYA55BBm6OKPQnELlsw09HTRjavL/8dGUXBzzAMlXQdniay/y2CQUklJKlFjRpntBLEWD06mAIt3RcCvyc1ZJ3f6VUHu1SypjvKTA/dPdYylIqvQBpc4wFfnaj/DTXIkfw3Otnk/EpsJTxrZg+vWkRdzdqkb9wvNJgJI4G161w4uNAumH5PMumv9rdF61++1e6u126jRQ== 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: 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) Reviewed-by: Andreas Gruenbacher --- 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 e782b4f1d104..0a47068f9acc 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(); }