From patchwork Wed Jan 4 21:14:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13088956 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 329DAC54E76 for ; Wed, 4 Jan 2023 21:15:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3C6C8E000B; Wed, 4 Jan 2023 16:15:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E4F778E0001; Wed, 4 Jan 2023 16:15:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C54208E000B; Wed, 4 Jan 2023 16:15:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A77098E0001 for ; Wed, 4 Jan 2023 16:15:08 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8203FC04D1 for ; Wed, 4 Jan 2023 21:15:08 +0000 (UTC) X-FDA: 80318371896.21.05E23BE Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf11.hostedemail.com (Postfix) with ESMTP id D5FE54000B for ; Wed, 4 Jan 2023 21:15:06 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=E+BBLApy; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672866906; 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=WpQ0T1hY90TiWrye/zwz8Fk0gosiIhGGJdVRGuIm1GI=; b=uKSetJ5g506/b6e30uEds4I+fSd+FyAwaGn1/EzLB6eGkNTMadA+uo9PJpcDAJQC/WnEmP ddjnw8AARxVUVR5TKNlCf1ZbrGhk9tUAjLWWQWwhgfbP+c4AzO4M2hx436V44IfM20IKcM EE3ykQk5XVywA2jSBMESrliuJW/9Rzs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=E+BBLApy; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672866906; a=rsa-sha256; cv=none; b=aTyIXTwyBxVMj1Hz6uEKY1828Sv6lEFKO9BbvERXSSeuNgzCmN/P6S7X61mkXlo2aPRBkF kOmMAAO/huz1vcw3Rtk8k4M/AWQ2jH4keaL9mLrTgxZCPcvTYj12QuLv5v7rqWXlcJNgQa 7349Gcf8941Cz8stD8pel4R8mu5m8DI= Received: by mail-pl1-f178.google.com with SMTP id jl4so30936190plb.8 for ; Wed, 04 Jan 2023 13:15:06 -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=WpQ0T1hY90TiWrye/zwz8Fk0gosiIhGGJdVRGuIm1GI=; b=E+BBLApy3NOf4wopcmgQT3kNLqU1Hr79oQuMl3hR4qfUlPWmBHbnGAZdWjmWQ2sPqR KD3vqU0o08iqRQDMZ+Dx71Uxb6FKKwlTAVnatYSqFEFo2ql7zVbgfTN0jI5SnejCghpW Yp2dxAkOFXpIR/EP01TN2Qi1KZfVkx0gCM6uZyj6KEkdh1uwBHmlMJb1jYaj5mpjWFdJ YKq6x1i+oKVpuPiMkiFj7F6T2fVMDzxqmVK0DBQsS4p2ok35IbL+fj4QgWC5A6B2GSq/ rquvFqryD//D0fhKfDeCa0GAp4a8mm3vC0NMLAwoabxYnh/OEdzg2OeVrhSmFb39plUP r7zw== 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=WpQ0T1hY90TiWrye/zwz8Fk0gosiIhGGJdVRGuIm1GI=; b=4Ipvd71IOsfrdaMyTnVnJVQEMyMltcpWnr1nsWKUzeGN65Wf5qZ1AT80Uc7NpaZCVY iWgoNUy65WjHSXjTDdLi4SAc6cNPrLyeWfyYz9OVZNjQNAgYsoGgck5+ycaUgo276lFM zFGw/pUSxiB6/Xf48xYoKlHs67xF8ohz9fN3usLibbO+e1aMHNZUOgpTOGyRvbcxXjiC atalsa+ewoGzMJqOVaW9LIRk7aXowT1NA70KnPV8HLgMhOlQdliUhkdlx5pm9xp3kuBr sOIpDCP8a0JCTsIbW21tQZFBbF6DNCX6Y0ENAKUe/wkUctmxGIi1azA5IhaIS9Z9V0qF +6eg== X-Gm-Message-State: AFqh2kp4eQ4pW0WBIH1YQ5wGhzgziurgQoGcahUwcygi2DuPKApf5PP6 LsrcjZ9ohXoxBkrGpGN/7s94IvKICnJJFw== X-Google-Smtp-Source: AMrXdXvMceiLQv8Bi2VTCFImf53/8/DB9Gj8r1k+O8qLsqokGEHS38Bc3wLTcycpGKeKQBiAhwaRsQ== X-Received: by 2002:a17:90a:fb87:b0:225:d81f:d463 with SMTP id cp7-20020a17090afb8700b00225d81fd463mr43386479pjb.26.1672866906363; Wed, 04 Jan 2023 13:15:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 13:15:06 -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)" , David Sterba Subject: [PATCH v5 07/23] btrfs: Convert extent_write_cache_pages() to use filemap_get_folios_tag() Date: Wed, 4 Jan 2023 13:14:32 -0800 Message-Id: <20230104211448.4804-8-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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D5FE54000B X-Stat-Signature: 7enzgx9arjj859qnmdsreeh5dze4a4sg X-HE-Tag: 1672866906-829942 X-HE-Meta: U2FsdGVkX1/qqoiU/nOnjP1liIBtn6hbBP8OYAVxMrLxMWSVer0RBEiFGXtCJ2gIzWP+BD0j0evtmMWJTby8TJ3wIgir1CSQVNCmKMdhQmaQEduSnzJHUB2p5rYUp5QwiA1z7wl/reafsybJSs34ruTCJfKvKfbRGCxb79UgEcQSfRljG7iJlfw9nlVm+6HYK9dgT0hJOQl3xLvUJHUhyKsATmxzYQgicXDY8fMaoNkJaA/VWmsBzffHNRXgchNBzUgHw8zJM42xqHhpuUMK3wGU2JoijFGs81rlp/jqLhAru1kujT59/+dejG2/gTp1Fiwjl1br7RJMcP03R5c4Fz7T+Iz7qEtMjuAx5hsNlKBsPAHaeXLfrFsWO/mznseJ7p8SbM4GiT8OchYIC9QqnAfI3qTaLaDj8VAENvCTEn3S6MhCNMkQH2iGqddYvwe60HVOldPyqI/AUonbh53hILd5SGY5CWMCXWwYKdcjGyaiw59Cqs1TxfpUMVUXH8OwclqdP+15BPdjVoxrI1mp0G08F2Scus70aJ/z/YR6qf9o96MLk6nwsq5/gnGpQGL8/Ue/86gBnpjex5VI9i/jniFDTeIAsJi+aFK/EgiTGAApaaRsHwSFLbc2y5/bsgw8fA/7KgAD/m4WZCuBu497QyWSp2HWQg18Y0XdAuKvaPpfmffeXq0q4+N1veTSfmns1VblqL5zp1nlFgcpN4QPS4z5eC6XpJuta1A893txB9UP1otiBJpStRT/BpWxhNa+7XKHszTNyhuMGm+0gvZPKgxWDuAoROJB34X1qyIXS3Of+OoMFo9/h5HqjNhYAFe8ZNpZPoo0aFMS/BxoYs4ePNNq0VtS7k2YJiWRuQ8uMQGqkMYfy99Jk5fIyF81nRdoVtiGy1ICyt8wxaQJ7RwfYBqMxGLp8VE8Hn0a7uG51wUSWOL+7ZfjZz1/KmAa0fk/3PynGzKgJMSQ1+w0zdu 4NGPRpys d86C1ez81uCEFelQHHqgdmlB7ZL+BTcTL0agJK9Ru3BQVJ9Zv/7zq7AvhbunyZPmIzNCOZnrnda5ql4UcAosm72xuICArE92jwEOfuiq4zNBAPFcnZIIhOHgAmU70xToXUoYcwaaKBbTTl1eacZ0RoYsYCwYCX8bPktH5k+EDyBG+ZNILV4BksQ8kGUPRxw+XLO4rw4raRAuvqeWJyk2JgVJMCG+QrHgSo7IJ3ksbIxONwhvAY2wU38R9zfm3vx1FxG4670Hi4mkhkeX3vKjz/O78ZJFW5/m7SaMj 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_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 64fbafc70822..a214b98c52fe 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2973,8 +2973,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; @@ -2994,7 +2994,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; @@ -3032,14 +3032,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 @@ -3047,29 +3047,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(bio_ctrl, 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(bio_ctrl, 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, bio_ctrl); + ret = __extent_writepage(&folio->page, wbc, bio_ctrl); if (ret < 0) { done = 1; break; @@ -3082,7 +3082,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) {