From patchwork Wed Jan 4 21:14:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13088953 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 19084C54EBD for ; Wed, 4 Jan 2023 21:15:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7FA28E0009; Wed, 4 Jan 2023 16:15:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A32948E0001; Wed, 4 Jan 2023 16:15:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8820F8E0009; Wed, 4 Jan 2023 16:15:06 -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 78F2F8E0001 for ; Wed, 4 Jan 2023 16:15:06 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 352F5160951 for ; Wed, 4 Jan 2023 21:15:06 +0000 (UTC) X-FDA: 80318371812.09.93D1EA9 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf08.hostedemail.com (Postfix) with ESMTP id 8AAE116000E for ; Wed, 4 Jan 2023 21:15:04 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FtYpbP6Q; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.173 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=1672866904; 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=V2mmRSbNA08/uL5X+kgeGS/ZlgopWrLZQOgB2XOAgyQ=; b=mv06Yk71sz8KpwJFptOxSn17KhDC91kStB50FJ92Mi1W17vlDdpsbKCE2EW4qaOkgAbkOq pdvtbLjb86t6blKpj+bCypCZBHWgY0CbUaagmw+C5g253xeCoZu4zflIyU0ae8KJzRuD2f EpWLf6t3ZcPOuiSFF2fRr9iaddYG2zo= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FtYpbP6Q; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.173 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=1672866904; a=rsa-sha256; cv=none; b=3vCh6Mcvn4xPmrudWAOxiQnucXNo0ibhNrAVy2vWGQY6CupgSz8YQJ45/pt9VpjZpKJDfn gXnbN56i7EGZX51sP90erZbrysFJYFZ41cO2nU9hOA8lbqTfV6twQiuNZADp0xo/fRVK8U 8q/P56j08h4V6H2BbNN+Q8oJ9vZXmIA= Received: by mail-pl1-f173.google.com with SMTP id d15so37214696pls.6 for ; Wed, 04 Jan 2023 13:15:04 -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=V2mmRSbNA08/uL5X+kgeGS/ZlgopWrLZQOgB2XOAgyQ=; b=FtYpbP6QDTs+0lZleCDk5ZEuYILk9YbbUBPUPSrk3Ld9sQDe/AXWgt1NFFEtyzVwVd 27XIJK2uMXpNSENtPUU9mTolqKYBkyqWBRgiNaPPr+6HKOkzRrfFG7vh51FRnD5XfrPm d3yU7xjojsyNe4TVkT6sdDculOxDV3WAY5LGCcI0ZY86e981vkbE2Keq4xL4jQlm+JDy 0+d7ZCBTlVPh+hBTPdMLgdJw4vZmFBuuPBlkVC18R54ZYLTjgjJSPd6APtzi8XuZocdm Vq+WqxTzB5n+aGbr09OvMJrslxbC/mLCAMYTELt30+n+Q7WR+zOqoKkaC27cWNkSuDUT 61uA== 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=V2mmRSbNA08/uL5X+kgeGS/ZlgopWrLZQOgB2XOAgyQ=; b=NzQemHNyQxTtMsBRIzKQzTtn7YlQTp35PzU4CGdAUeiCaTZLDYUCBvK+HaEtVZmO6z 4xfXkwoT3Mq5Vm5gwx4oM4gsBwpgS1M8GiYJTk7uLmrVBMu97yUTJy4EWWQh/WDUFDWp 5nmSOmoQigMatlLW/UDGHkfudvHJ+D4XlMeF9N3w2pX1/1B8QBJmkybl9SztPF0Bbwri vI1u7ORiu3kW5TSCU6d6rornejTNHuGw1vWy5dI0sPm6ppfiEjuFZID1oVd7Wyai3bTD NLHxviXQThGpqZmYZKCplPmz0VDcf7jG69GrQ7wtt3w1wNb6ERWfsDCgxYHBr/CyzbBm bfAw== X-Gm-Message-State: AFqh2kpRj/cLfxVUnYZQs2s7pS4YuCusGjBlfQVlASkj0NLtoKTlygef 2WCzEK06ioxmjtlfiMCC/6U= X-Google-Smtp-Source: AMrXdXsgqtpANtSCNZq+/gUhsOvEJLufITPz0tuKGVLeAke3wLXVvQoumIbsLoPmk9yfZKpeAUrvrg== X-Received: by 2002:a17:90b:2291:b0:226:43ba:54af with SMTP id kx17-20020a17090b229100b0022643ba54afmr18504817pjb.2.1672866903454; Wed, 04 Jan 2023 13:15:03 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 13:15:03 -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 Howells Subject: [PATCH v5 05/23] afs: Convert afs_writepages_region() to use filemap_get_folios_tag() Date: Wed, 4 Jan 2023 13:14:30 -0800 Message-Id: <20230104211448.4804-6-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: 8AAE116000E X-Stat-Signature: uigxr8rb4y7gqgtnuxf1e9e9qknedbx3 X-Rspam-User: X-HE-Tag: 1672866904-99405 X-HE-Meta: U2FsdGVkX1/cHiWz+osXAjFG9MoPd6eDcFIlDrhOjHtXL3NIsZpvDLgqXCXs7sUcOX3BGYrboATMXwTZL9uxDM6UnlbkC8sy5WCwbUwNmt5/rYdUTTfHBobA2aWFokiiaWky/zUrFO9eF1ST8HCRVAXecY50fZXhki9gw+JI3pyrIvDP4qLTUCFPsOPgiz4RsOd2lJRbwsaZCODZRA9Jq7ciHN0BKgvUwAmKEYbnGK9rfEVf1q0Vt7ncACGSvUooCtXK6GcEQgs+1bh8q7nab4G1eYI/uGJ9/gzFA+cutWL+SfbG0sVIKeNXkKKwsGWef8+BwiKNZ5Bm9JgBI3te2HHmmF5Yc88R09cCh1z+5nThoxOoERoT04T17kOaW1Pps7pp0HASsB7zEpzRrVgKPcSUZlyPSvK75lkXx8aSlu0QFd/tnZZkZcjAdn7cMKkwe5Ae2tc1vmahQHREIFHTZMoTs5nHQoDDs606nRFkPsIOUB5Ue1LsSiGexk3j/ADt/uOidACt5wo5uwCi3jUmK7EZbw/SB/fvIaIYBe60WkNQbSaRRCFWfhVULYkqJp6VkdrTSEn+L6bIXt1z5Rr3qLSPGy4pMvK7LPvTCz+ScupBhcRr9qIaUld1x5bNsy9QysFv2F7kwzbwcVlpw9kXULWBAS+Gma2h6IGkTOjGYObpmO40fhj4UkOZtsku0dVxTdrt4KxcYfXPI8RSnCqHTvUPD7V4DJ5+0d235asdg6Q8i6d7JHpqlxEgU4jNHch0R80uZZjr/Aldvy7biMHZQODu1rdY9F1rc9B67RquNfIDHTHMAmHKVWwZGTWcLBYbC8VQFKgr1Y7XvNrmCrmIa7Q9SSb+iaCdmmS9FeEgeVY+WvnmPmHQCnROWLm8szux1EIKbasNJmTMctSlFe95P479Vc2fiaXzhj2YMdKwlJjlI3mN6wL9eVgyzKgvOZExJhEkHoXgoG5OxzY81ze BdGT3K2t /pqAtXXScyt0hahRXoR8GExCIu4CmflkjAfkuq4BTkg9LzgiOFFgdxHrHF4bOlsoa4Vd+AgTPwCjxSEXYuTpWu+dCyEW2cI4qJ501829Nr7a/QBDQgGmOU4zsp3E5S+ZMZpv9vRd4ntw3ysg4tno8FBuVxCQzxYUI2EOjC22FHutgBfc3KYtyUWwHkBKHJ4voOvmfhepuCi03rZNCS1y1OqRsYdzb4wFlzaRxhIopO0fdAmWojgeaLdiHBOxEqOix2t+LGao68SPBTofB6jPREFW6k9qOYVyRokvC 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 to use folios throughout. This function is in preparation to remove find_get_pages_range_tag(). Also modified this function to write the whole batch one at a time, rather than calling for a new set every single write. Signed-off-by: Vishal Moola (Oracle) Tested-by: David Howells --- fs/afs/write.c | 116 +++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 57 deletions(-) diff --git a/fs/afs/write.c b/fs/afs/write.c index 19df10d63323..2d3b08b7406c 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -704,85 +704,87 @@ static int afs_writepages_region(struct address_space *mapping, bool max_one_loop) { struct folio *folio; - struct page *head_page; + struct folio_batch fbatch; ssize_t ret; + unsigned int i; int n, skips = 0; _enter("%llx,%llx,", start, end); + folio_batch_init(&fbatch); do { pgoff_t index = start / PAGE_SIZE; - n = find_get_pages_range_tag(mapping, &index, end / PAGE_SIZE, - PAGECACHE_TAG_DIRTY, 1, &head_page); + n = filemap_get_folios_tag(mapping, &index, end / PAGE_SIZE, + PAGECACHE_TAG_DIRTY, &fbatch); + if (!n) break; + for (i = 0; i < n; i++) { + folio = fbatch.folios[i]; + start = folio_pos(folio); /* May regress with THPs */ - folio = page_folio(head_page); - start = folio_pos(folio); /* May regress with THPs */ - - _debug("wback %lx", folio_index(folio)); + _debug("wback %lx", folio_index(folio)); - /* At this point we hold neither the i_pages lock nor the - * page lock: the page may be truncated or invalidated - * (changing page->mapping to NULL), or even swizzled - * back from swapper_space to tmpfs file mapping - */ - if (wbc->sync_mode != WB_SYNC_NONE) { - ret = folio_lock_killable(folio); - if (ret < 0) { - folio_put(folio); - return ret; - } - } else { - if (!folio_trylock(folio)) { - folio_put(folio); - return 0; + /* At this point we hold neither the i_pages lock nor the + * page lock: the page may be truncated or invalidated + * (changing page->mapping to NULL), or even swizzled + * back from swapper_space to tmpfs file mapping + */ + if (wbc->sync_mode != WB_SYNC_NONE) { + ret = folio_lock_killable(folio); + if (ret < 0) { + folio_batch_release(&fbatch); + return ret; + } + } else { + if (!folio_trylock(folio)) + continue; } - } - if (folio_mapping(folio) != mapping || - !folio_test_dirty(folio)) { - start += folio_size(folio); - folio_unlock(folio); - folio_put(folio); - continue; - } + if (folio->mapping != mapping || + !folio_test_dirty(folio)) { + start += folio_size(folio); + folio_unlock(folio); + continue; + } - if (folio_test_writeback(folio) || - folio_test_fscache(folio)) { - folio_unlock(folio); - if (wbc->sync_mode != WB_SYNC_NONE) { - folio_wait_writeback(folio); + if (folio_test_writeback(folio) || + folio_test_fscache(folio)) { + folio_unlock(folio); + if (wbc->sync_mode != WB_SYNC_NONE) { + folio_wait_writeback(folio); #ifdef CONFIG_AFS_FSCACHE - folio_wait_fscache(folio); + folio_wait_fscache(folio); #endif - } else { - start += folio_size(folio); + } else { + start += folio_size(folio); + } + if (wbc->sync_mode == WB_SYNC_NONE) { + if (skips >= 5 || need_resched()) { + *_next = start; + _leave(" = 0 [%llx]", *_next); + return 0; + } + skips++; + } + continue; } - folio_put(folio); - if (wbc->sync_mode == WB_SYNC_NONE) { - if (skips >= 5 || need_resched()) - break; - skips++; + + if (!folio_clear_dirty_for_io(folio)) + BUG(); + ret = afs_write_back_from_locked_folio(mapping, wbc, + folio, start, end); + if (ret < 0) { + _leave(" = %zd", ret); + folio_batch_release(&fbatch); + return ret; } - continue; - } - if (!folio_clear_dirty_for_io(folio)) - BUG(); - ret = afs_write_back_from_locked_folio(mapping, wbc, folio, start, end); - folio_put(folio); - if (ret < 0) { - _leave(" = %zd", ret); - return ret; + start += ret; } - start += ret; - - if (max_one_loop) - break; - + folio_batch_release(&fbatch); cond_resched(); } while (wbc->nr_to_write > 0);