Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp50005rwi; Wed, 2 Nov 2022 09:12:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5CY43u5J7GD0KJ0wWGXi7hA3X4b17uDGXbRNiJVp9RhKnGrESJdoKHho4GHMI9gxlapugl X-Received: by 2002:a17:906:2353:b0:7ad:daae:6edd with SMTP id m19-20020a170906235300b007addaae6eddmr14638227eja.40.1667405575520; Wed, 02 Nov 2022 09:12:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405575; cv=none; d=google.com; s=arc-20160816; b=mf4ltG3zJMBW3ZRn0SaeY4tv7wip4JFpIoF4qRAqin3ot5tuEa8N2iR5zgmlNOqj7m 02fChIx79b0pEIwg7XR9YQ95RpQCMpONlGmhN0sUuDN9eXlwAxTgslV2tggntYQVhz8a EnVk4nwyR1d/gSyUvZndp0xbNttaCsPa6qECtB0MGpJ2bhlF1kLikk4u0PD96l3/hJz+ DIP7gYfj5u+1z2o3E2XYLSmAfkfoIDIXKLPvEZRps86eNbClXGclnh6QBnM6mUSgDZv1 nY3Fp77hwazQAGdIcMGEQtul0lFsA8ZIpNfjzRTl1lSqbtGbcxZvndfMf/rOTeXy88aO kaEQ== 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=ihiS02r9sD2/Zs2Vx3FiURN5naIQGKMktV+WLRuKSks=; b=UOQxWFLJ0H3xeMTtSh+ViW3xJhCEkNOHQ5L9TxZXcqk1D9OVFx6ho0CyWePhx0kH94 pfc02LbXvF5y2c9RkN+s+pCKjYC7kfvf6Ehqp9AgfAGK/Z5Qjb12mKC07s7wx5fS+NFB whpdwVBAN55OKyj63VAWk2vYVTsIiZJPbsC73o+IfEECViFy90Ev2w91wuW8kWCzI4Fv FfJg6gc5Gb1ac0LrrJr7wtK698zlM/pJ5yUAGgYHTKj8a3cWcNl8RZmBZxQwPFKzshW2 zO3Nxh68JSNZAfbmCDcCa0zvL0C92lA2AAThlLu3QDGgJGtdWrMGuUB77DANRwiN1NG1 86TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SeLQ4Qu5; 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 du10-20020a17090772ca00b0079194297b1bsi17977367ejc.815.2022.11.02.09.12.31; Wed, 02 Nov 2022 09:12:55 -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=SeLQ4Qu5; 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 S231357AbiKBQLq (ORCPT + 99 others); Wed, 2 Nov 2022 12:11:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbiKBQL1 (ORCPT ); Wed, 2 Nov 2022 12:11:27 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47BAA2C660; Wed, 2 Nov 2022 09:11:18 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id e129so16627748pgc.9; Wed, 02 Nov 2022 09:11:18 -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=ihiS02r9sD2/Zs2Vx3FiURN5naIQGKMktV+WLRuKSks=; b=SeLQ4Qu5//oXLNdBKVpytDwCWDO3I4G0YA52j5Knaxs6ot8nHTPxSvbYLibh2we7yp QOIy/yHsS5HNor/MIiz1/wjrknFzailQqLyUUDbncxkYbsgZJU/KhMzRQwgIl+QybVYC Rqmh80nwtQvOLrWqsNMA1En6NleAdRBSdgoag/eIey7KzBlGjcP3tZEj27YIEQECQyBF FiPgSN2IEHbjhKQ2oUVo+PWzz8cWJh20VFpEboEHH28rkzkyFMeuKzSfjD9ZDJNc3sQY DZllsnJTeZr1MOe9IOgxs+YIxX7s6esYPo/OjncN4dhR0FUlfGbp9Fqklf0gZ4+OOwoZ 8BhQ== 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=ihiS02r9sD2/Zs2Vx3FiURN5naIQGKMktV+WLRuKSks=; b=GvL5GNBMw9NCEtzfUbGxfIuMzYqgsULeOjItTmoVxbYJiev25G3z9P5Pse7IwexFMw ZdtWK7IGz0hAQf8bkG1k2+NwejO2ikh99wMvI7ZrlEgZm0XGHJsaX09faIqCzKcrLlzu GovpBKN5tJ1wk3q7y1QGGNEzu/DMHiSt474YxkelWwimQtzuRb/SEju+GuXt2t5Pn4xO PK2B+xG02WY3+9eQ0YumNhemLComitvZVHAlIqpWBeuqY0JPJsXHqsOWEQ3+q9ao0S7u 9N/q+Si5TEX/FzgC11odnjz9IY/2IYCybKp9VS9W8gvDAX9jxH/35xMgt8sZtzdL4nm2 L2Aw== X-Gm-Message-State: ACrzQf1diDpmBGE0bMGpzDnBgGtnfNy2Fgl3CBpvkaaM7Ex9Yv9Xk4ym zDhRJMOTXyNf9h/DqwBtWszt/JHrHoOGvA== X-Received: by 2002:a05:6a00:a22:b0:54e:6a90:fbef with SMTP id p34-20020a056a000a2200b0054e6a90fbefmr25892086pfh.53.1667405477494; Wed, 02 Nov 2022 09:11:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:11:17 -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)" , David Sterba Subject: [PATCH v4 07/23] btrfs: Convert extent_write_cache_pages() to use filemap_get_folios_tag() Date: Wed, 2 Nov 2022 09:10:15 -0700 Message-Id: <20221102161031.5820-8-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 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 9ae75db4d55e..983dde83ba93 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3088,8 +3088,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; @@ -3109,7 +3109,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; @@ -3147,14 +3147,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 @@ -3162,29 +3162,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(epd, 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(epd, 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, epd); + ret = __extent_writepage(&folio->page, wbc, epd); if (ret < 0) { done = 1; break; @@ -3197,7 +3197,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) { -- 2.38.1