From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF2D3ECAAD3 for ; Thu, 1 Sep 2022 22:02:56 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1oTsH2-00077F-E3; Thu, 01 Sep 2022 22:02:56 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oTsGu-00076j-8X for linux-f2fs-devel@lists.sourceforge.net; Thu, 01 Sep 2022 22:02:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=NOXLTO79qhrJOlYyxIYm/ZYJYsfR2nEvKsGqG4l5Qvs=; b=FpAPPzv/KEGpfjPmVPBk00e1Gh ti/T0k8mIdXEi4vZ0TdTNFPLMkXKLMTWrQN2/tfyfsMEsfAlqMy9cJpZh/uFIuG3HOPUXsLsD1HeY vTRyT3xZdVUhv2nv0N/U4Sw3576u3i17w1Jnvf5pCkP9nSWAcYJTXWm5nNfXApuLqVuA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=NOXLTO79qhrJOlYyxIYm/ZYJYsfR2nEvKsGqG4l5Qvs=; b=MgqFlciErFQfOG96ZP5shFVsaC GAHjCyG7xc4fgzWFmlyMd8hALT2UqwySRJNYbIxahSKE09yJuRXcIJLSLFVb9N63nJnY+xw6kUkXU OJtafadWLqyerJsRCki9kKyRk1Wc/ZRRGTKfA23YOgZlYrENUIKerWK+rACb+e9hNk2k=; Received: from mail-pf1-f173.google.com ([209.85.210.173]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1oTsGt-00AafH-Ch for linux-f2fs-devel@lists.sourceforge.net; Thu, 01 Sep 2022 22:02:48 +0000 Received: by mail-pf1-f173.google.com with SMTP id 145so123420pfw.4 for ; Thu, 01 Sep 2022 15:02:47 -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; bh=NOXLTO79qhrJOlYyxIYm/ZYJYsfR2nEvKsGqG4l5Qvs=; b=BofO2z6y9ENTQWp0Yvv0xZOA4E0ZmpnPsRHNqq6A2jC1fFkLvkeI9auiLxIXCMWaFI Ny/wnTRd4bsfeSW1PW0hlP2y1AW0H/gKGeJyyyuXIzCBClJwAJdgV0XPBr23RLqie4M/ ewOkzhyY5JUKKRcuoL+BKdtDBY649mPhRz+RjFkATheqTrkrL23h4FPz7QrlORmIjWgR HOb4a9Tepxb/llZqXj0DwkH1KVQYgyA1Reni49ob6gMd5Ubkso+9GqQHb704TQ/xa7VI DNqNBw4bPc6iBtu1mEpGSjGiajYdCK5/I1MxHEc0MmiyV/DXBSSxCupIrv8urS1sT+Pz 3wwg== 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; bh=NOXLTO79qhrJOlYyxIYm/ZYJYsfR2nEvKsGqG4l5Qvs=; b=YzlBY4Vc1ZwkOdJKBT4IUtUNaMLslTIZ5ZxPqpdi7eJWQi+hIetOb9fYEE8KJX7m0s WwL7d1/i2jl/Gd1eGqH81F29yAKocJxCsfhQ6IjWP2LxxFiiZZrphnFCXWs4wa7vMnXw 7WhEI8mM5IU7/LiPyhwTkR3rtiyruqrk6tSZa0yHxE+GazLhgWxeWnx/+OK/NnNDIQQJ uGp1SDKrdlatzabVyO+8GxE2mNXOA9wl1c3WQmohE1JiILVdRVctuoUh8mSe4efFC/EO RelaHVJluFY0Fm/g1Y8Six0U/VV+qiHckr4rQwpmihkJAHSfM66oEvJTT/BezPBFioOo nYFA== X-Gm-Message-State: ACgBeo0aKGK/H+NoFUn38DyoWjh1pRUaTwoCUoovEVvELPKvY8ctiEME v23rt0WD3WFVjm8MAyxn5AI= X-Google-Smtp-Source: AA6agR4QgchkxCnj/34OOoCX8oBg5svfID3CvXXYOvQ+6OAqnA4ElIZZzg75g2LnJSAMa171PFwf5w== X-Received: by 2002:a63:256:0:b0:42f:b14b:2085 with SMTP id 83-20020a630256000000b0042fb14b2085mr11358313pgc.189.1662069761849; Thu, 01 Sep 2022 15:02:41 -0700 (PDT) Received: from vmfolio.. (c-73-189-111-8.hsd1.ca.comcast.net. [73.189.111.8]) by smtp.googlemail.com with ESMTPSA id fv4-20020a17090b0e8400b001fb350026f1sm128894pjb.4.2022.09.01.15.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:02:41 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-fsdevel@vger.kernel.org Date: Thu, 1 Sep 2022 15:01:20 -0700 Message-Id: <20220901220138.182896-6-vishal.moola@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220901220138.182896-1-vishal.moola@gmail.com> References: <20220901220138.182896-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Headers-End: 1oTsGt-00AafH-Ch Subject: [f2fs-dev] [PATCH 05/23] afs: Convert afs_writepages_region() to use filemap_get_folios_tag() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-cifs@vger.kernel.org, linux-nilfs@vger.kernel.org, "Vishal Moola \(Oracle\)" , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-mm@kvack.org, ceph-devel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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) --- fs/afs/write.c | 114 +++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 55 deletions(-) diff --git a/fs/afs/write.c b/fs/afs/write.c index 9ebdd36eaf2f..c17dbd82a38c 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -699,82 +699,86 @@ static int afs_writepages_region(struct address_space *mapping, loff_t start, loff_t end, loff_t *_next) { 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; - + folio_batch_release(&fbatch); cond_resched(); } while (wbc->nr_to_write > 0); -- 2.36.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel