linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	intel-gfx@lists.freedesktop.org, linux-mm@kvack.org,
	dri-devel@lists.freedesktop.org
Subject: [PATCH v2 3/9] migrate: Remove call to ->writepage
Date: Wed,  2 Apr 2025 15:59:57 +0100	[thread overview]
Message-ID: <20250402150005.2309458-4-willy@infradead.org> (raw)
In-Reply-To: <20250402150005.2309458-1-willy@infradead.org>

The writepage callback is going away; filesystems must implement
migrate_folio or else dirty folios will not be migratable.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/migrate.c | 60 ++++++----------------------------------------------
 1 file changed, 7 insertions(+), 53 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index f3ee6d8d5e2e..6e2488e5dbe4 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -944,67 +944,21 @@ int filemap_migrate_folio(struct address_space *mapping,
 }
 EXPORT_SYMBOL_GPL(filemap_migrate_folio);
 
-/*
- * Writeback a folio to clean the dirty state
- */
-static int writeout(struct address_space *mapping, struct folio *folio)
-{
-	struct writeback_control wbc = {
-		.sync_mode = WB_SYNC_NONE,
-		.nr_to_write = 1,
-		.range_start = 0,
-		.range_end = LLONG_MAX,
-		.for_reclaim = 1
-	};
-	int rc;
-
-	if (!mapping->a_ops->writepage)
-		/* No write method for the address space */
-		return -EINVAL;
-
-	if (!folio_clear_dirty_for_io(folio))
-		/* Someone else already triggered a write */
-		return -EAGAIN;
-
-	/*
-	 * A dirty folio may imply that the underlying filesystem has
-	 * the folio on some queue. So the folio must be clean for
-	 * migration. Writeout may mean we lose the lock and the
-	 * folio state is no longer what we checked for earlier.
-	 * At this point we know that the migration attempt cannot
-	 * be successful.
-	 */
-	remove_migration_ptes(folio, folio, 0);
-
-	rc = mapping->a_ops->writepage(&folio->page, &wbc);
-
-	if (rc != AOP_WRITEPAGE_ACTIVATE)
-		/* unlocked. Relock */
-		folio_lock(folio);
-
-	return (rc < 0) ? -EIO : -EAGAIN;
-}
-
 /*
  * Default handling if a filesystem does not provide a migration function.
  */
 static int fallback_migrate_folio(struct address_space *mapping,
 		struct folio *dst, struct folio *src, enum migrate_mode mode)
 {
-	if (folio_test_dirty(src)) {
-		/* Only writeback folios in full synchronous migration */
-		switch (mode) {
-		case MIGRATE_SYNC:
-			break;
-		default:
-			return -EBUSY;
-		}
-		return writeout(mapping, src);
-	}
+	WARN_ONCE(mapping->a_ops->writepages,
+			"%ps does not implement migrate_folio\n",
+			mapping->a_ops);
+	if (folio_test_dirty(src))
+		return -EBUSY;
 
 	/*
-	 * Buffers may be managed in a filesystem specific way.
-	 * We must have no buffers or drop them.
+	 * Filesystem may have private data at folio->private that we
+	 * can't migrate automatically.
 	 */
 	if (!filemap_release_folio(src, GFP_KERNEL))
 		return mode == MIGRATE_SYNC ? -EAGAIN : -EBUSY;
-- 
2.47.2


  parent reply	other threads:[~2025-04-02 15:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-02 14:59 [PATCH v2 0/9] Remove aops->writepage Matthew Wilcox (Oracle)
2025-04-02 14:59 ` [PATCH v2 1/9] 9p: Add a migrate_folio method Matthew Wilcox (Oracle)
2025-04-03  3:46   ` Dominique Martinet
2025-04-03  3:53     ` Matthew Wilcox
2025-04-02 14:59 ` [PATCH v2 2/9] vboxsf: Convert to writepages Matthew Wilcox (Oracle)
2025-04-02 14:59 ` Matthew Wilcox (Oracle) [this message]
2025-04-05 16:56   ` [PATCH v2 3/9] migrate: Remove call to ->writepage Zi Yan
2025-04-02 14:59 ` [PATCH v2 4/9] writeback: Remove writeback_use_writepage() Matthew Wilcox (Oracle)
2025-04-02 14:59 ` [PATCH v2 5/9] shmem: Add shmem_writeout() Matthew Wilcox (Oracle)
2025-04-02 15:00 ` [PATCH v2 6/9] i915: Use writeback_iter() Matthew Wilcox (Oracle)
2025-04-04  8:26   ` Christoph Hellwig
2025-04-04 13:40     ` Matthew Wilcox
2025-04-02 15:00 ` [PATCH v2 7/9] ttm: Call shmem_writeout() from ttm_backup_backup_page() Matthew Wilcox (Oracle)
2025-04-02 15:00 ` [PATCH v2 8/9] mm: Remove swap_writepage() and shmem_writepage() Matthew Wilcox (Oracle)
2025-04-02 15:00 ` [PATCH v2 9/9] fs: Remove aops->writepage Matthew Wilcox (Oracle)
2025-04-02 17:10 ` [PATCH v2 1/9] 9p: Add a migrate_folio method David Howells
2025-04-04  8:31 ` [PATCH v2 0/9] Remove aops->writepage Christoph Hellwig
2025-04-04 13:42   ` Matthew Wilcox

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=20250402150005.2309458-4-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.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).