forked from mirrors/linux
		
	migrate: Remove call to ->writepage
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> Link: https://lore.kernel.org/r/20250402150005.2309458-4-willy@infradead.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
		
							parent
							
								
									e300830fcc
								
							
						
					
					
						commit
						7ee3647243
					
				
					 1 changed files with 7 additions and 53 deletions
				
			
		
							
								
								
									
										60
									
								
								mm/migrate.c
									
									
									
									
									
								
							
							
						
						
									
										60
									
								
								mm/migrate.c
									
									
									
									
									
								
							| 
						 | 
					@ -944,67 +944,21 @@ int filemap_migrate_folio(struct address_space *mapping,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL_GPL(filemap_migrate_folio);
 | 
					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.
 | 
					 * Default handling if a filesystem does not provide a migration function.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static int fallback_migrate_folio(struct address_space *mapping,
 | 
					static int fallback_migrate_folio(struct address_space *mapping,
 | 
				
			||||||
		struct folio *dst, struct folio *src, enum migrate_mode mode)
 | 
							struct folio *dst, struct folio *src, enum migrate_mode mode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (folio_test_dirty(src)) {
 | 
						WARN_ONCE(mapping->a_ops->writepages,
 | 
				
			||||||
		/* Only writeback folios in full synchronous migration */
 | 
								"%ps does not implement migrate_folio\n",
 | 
				
			||||||
		switch (mode) {
 | 
								mapping->a_ops);
 | 
				
			||||||
		case MIGRATE_SYNC:
 | 
						if (folio_test_dirty(src))
 | 
				
			||||||
			break;
 | 
							return -EBUSY;
 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			return -EBUSY;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return writeout(mapping, src);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Buffers may be managed in a filesystem specific way.
 | 
						 * Filesystem may have private data at folio->private that we
 | 
				
			||||||
	 * We must have no buffers or drop them.
 | 
						 * can't migrate automatically.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if (!filemap_release_folio(src, GFP_KERNEL))
 | 
						if (!filemap_release_folio(src, GFP_KERNEL))
 | 
				
			||||||
		return mode == MIGRATE_SYNC ? -EAGAIN : -EBUSY;
 | 
							return mode == MIGRATE_SYNC ? -EAGAIN : -EBUSY;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue