linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>
Cc: Matthew Wilcox <willy@infradead.org>,
	linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 23/23] mm: remove folio_account_redirty
Date: Wed, 28 Jun 2023 17:31:44 +0200	[thread overview]
Message-ID: <20230628153144.22834-24-hch@lst.de> (raw)
In-Reply-To: <20230628153144.22834-1-hch@lst.de>

Fold folio_account_redirty into folio_redirty_for_writepage now
that all other users except for the also unused account_page_redirty
wrapper are gone.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/writeback.h |  5 ----
 mm/page-writeback.c       | 49 +++++++++++----------------------------
 2 files changed, 14 insertions(+), 40 deletions(-)

diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index fba937999fbfd3..083387c00f0c8b 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -375,11 +375,6 @@ void tag_pages_for_writeback(struct address_space *mapping,
 			     pgoff_t start, pgoff_t end);
 
 bool filemap_dirty_folio(struct address_space *mapping, struct folio *folio);
-void folio_account_redirty(struct folio *folio);
-static inline void account_page_redirty(struct page *page)
-{
-	folio_account_redirty(page_folio(page));
-}
 bool folio_redirty_for_writepage(struct writeback_control *, struct folio *);
 bool redirty_page_for_writepage(struct writeback_control *, struct page *);
 
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index db794399900734..56074637ef4fe0 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1193,7 +1193,7 @@ static void wb_update_write_bandwidth(struct bdi_writeback *wb,
 	 * write_bandwidth = ---------------------------------------------------
 	 *                                          period
 	 *
-	 * @written may have decreased due to folio_account_redirty().
+	 * @written may have decreased due to folio_redirty_for_writepage().
 	 * Avoid underflowing @bw calculation.
 	 */
 	bw = written - min(written, wb->written_stamp);
@@ -2709,37 +2709,6 @@ bool filemap_dirty_folio(struct address_space *mapping, struct folio *folio)
 }
 EXPORT_SYMBOL(filemap_dirty_folio);
 
-/**
- * folio_account_redirty - Manually account for redirtying a page.
- * @folio: The folio which is being redirtied.
- *
- * Most filesystems should call folio_redirty_for_writepage() instead
- * of this fuction.  If your filesystem is doing writeback outside the
- * context of a writeback_control(), it can call this when redirtying
- * a folio, to de-account the dirty counters (NR_DIRTIED, WB_DIRTIED,
- * tsk->nr_dirtied), so that they match the written counters (NR_WRITTEN,
- * WB_WRITTEN) in long term. The mismatches will lead to systematic errors
- * in balanced_dirty_ratelimit and the dirty pages position control.
- */
-void folio_account_redirty(struct folio *folio)
-{
-	struct address_space *mapping = folio->mapping;
-
-	if (mapping && mapping_can_writeback(mapping)) {
-		struct inode *inode = mapping->host;
-		struct bdi_writeback *wb;
-		struct wb_lock_cookie cookie = {};
-		long nr = folio_nr_pages(folio);
-
-		wb = unlocked_inode_to_wb_begin(inode, &cookie);
-		current->nr_dirtied -= nr;
-		node_stat_mod_folio(folio, NR_DIRTIED, -nr);
-		wb_stat_mod(wb, WB_DIRTIED, -nr);
-		unlocked_inode_to_wb_end(inode, &cookie);
-	}
-}
-EXPORT_SYMBOL(folio_account_redirty);
-
 /**
  * folio_redirty_for_writepage - Decline to write a dirty folio.
  * @wbc: The writeback control.
@@ -2755,13 +2724,23 @@ EXPORT_SYMBOL(folio_account_redirty);
 bool folio_redirty_for_writepage(struct writeback_control *wbc,
 		struct folio *folio)
 {
-	bool ret;
+	struct address_space *mapping = folio->mapping;
 	long nr = folio_nr_pages(folio);
+	bool ret;
 
 	wbc->pages_skipped += nr;
-	ret = filemap_dirty_folio(folio->mapping, folio);
-	folio_account_redirty(folio);
+	ret = filemap_dirty_folio(mapping, folio);
+	if (mapping && mapping_can_writeback(mapping)) {
+		struct inode *inode = mapping->host;
+		struct bdi_writeback *wb;
+		struct wb_lock_cookie cookie = {};
 
+		wb = unlocked_inode_to_wb_begin(inode, &cookie);
+		current->nr_dirtied -= nr;
+		node_stat_mod_folio(folio, NR_DIRTIED, -nr);
+		wb_stat_mod(wb, WB_DIRTIED, -nr);
+		unlocked_inode_to_wb_end(inode, &cookie);
+	}
 	return ret;
 }
 EXPORT_SYMBOL(folio_redirty_for_writepage);
-- 
2.39.2


  parent reply	other threads:[~2023-06-28 15:33 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28 15:31 btrfs compressed writeback cleanups Christoph Hellwig
2023-06-28 15:31 ` [PATCH 01/23] btrfs: pass a flags argument to cow_file_range Christoph Hellwig
2023-07-04  8:47   ` Johannes Thumshirn
2023-07-20 11:22   ` David Sterba
2023-07-20 13:25     ` Christoph Hellwig
2023-06-28 15:31 ` [PATCH 02/23] btrfs: don't create inline extents in fallback_to_cow Christoph Hellwig
2023-06-28 15:31 ` [PATCH 03/23] btrfs: split page locking out of __process_pages_contig Christoph Hellwig
2023-06-28 15:31 ` [PATCH 04/23] btrfs: remove btrfs_writepage_endio_finish_ordered Christoph Hellwig
2023-07-04  8:50   ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 05/23] btrfs: remove end_extent_writepage Christoph Hellwig
2023-06-28 15:31 ` [PATCH 06/23] btrfs: reduce debug spam from submit_compressed_extents Christoph Hellwig
2023-07-04  8:54   ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 07/23] btrfs: remove the return value from submit_uncompressed_range Christoph Hellwig
2023-07-04  8:56   ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 08/23] btrfs: remove the return value from extent_write_locked_range Christoph Hellwig
2023-07-04  8:56   ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 09/23] btrfs: improve the delalloc_to_write calculation in writepage_delalloc Christoph Hellwig
2023-06-28 15:31 ` [PATCH 10/23] btrfs: reduce the number of arguments to btrfs_run_delalloc_range Christoph Hellwig
2023-07-04  9:00   ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 11/23] btrfs: clean up the check for uncompressed ranges in submit_one_async_extent Christoph Hellwig
2023-07-04  9:07   ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 12/23] btrfs: don't clear async_chunk->inode in async_cow_start Christoph Hellwig
2023-06-28 15:31 ` [PATCH 13/23] btrfs: merge async_cow_start and compress_file_range Christoph Hellwig
2023-07-04  9:09   ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 14/23] btrfs: merge submit_compressed_extents and async_cow_submit Christoph Hellwig
2023-06-28 15:31 ` [PATCH 15/23] btrfs: streamline compress_file_range Christoph Hellwig
2023-06-28 15:31 ` [PATCH 16/23] btrfs: further simplify the compress or not logic in compress_file_range Christoph Hellwig
2023-07-14 13:47   ` Josef Bacik
2023-06-28 15:31 ` [PATCH 17/23] btrfs: use a separate label for the incompressible case " Christoph Hellwig
2023-06-28 15:31 ` [PATCH 18/23] btrfs: share the code to free the page array " Christoph Hellwig
2023-06-28 15:31 ` [PATCH 19/23] btrfs: don't redirty pages " Christoph Hellwig
2023-07-20 11:41   ` David Sterba
2023-07-20 13:26     ` Christoph Hellwig
2023-06-28 15:31 ` [PATCH 20/23] btrfs: refactor the zoned device handling in cow_file_range Christoph Hellwig
2023-06-28 15:31 ` [PATCH 21/23] btrfs: don't redirty locked_page in run_delalloc_zoned Christoph Hellwig
2023-06-28 15:31 ` [PATCH 22/23] btrfs: fix zoned handling in submit_uncompressed_range Christoph Hellwig
2023-06-28 15:31 ` Christoph Hellwig [this message]
2023-06-28 15:45   ` [PATCH 23/23] mm: remove folio_account_redirty Matthew Wilcox
2023-07-14 13:49 ` btrfs compressed writeback cleanups Josef Bacik
2023-07-20 11:47 ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230628153144.22834-24-hch@lst.de \
    --to=hch@lst.de \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).