From patchwork Wed Apr 2 14:59:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036143 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 8E732C36017 for ; Wed, 2 Apr 2025 15:00:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D830528000E; Wed, 2 Apr 2025 11:00:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CBC2328000A; Wed, 2 Apr 2025 11:00:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE58428000E; Wed, 2 Apr 2025 11:00:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8E0B428000A for ; Wed, 2 Apr 2025 11:00:21 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 276B1BB811 for ; Wed, 2 Apr 2025 15:00:22 +0000 (UTC) X-FDA: 83289414684.08.4A29070 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id 92F4410000A for ; Wed, 2 Apr 2025 15:00:20 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="R/MLFsPv"; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743606020; 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=5XW0b8o2GA0rXaRAcMoHAk0zi9Q3pqKKR/5ZrqK6isA=; b=0LzyZEfRZc1GdWEcxI0kP5TWlHe3oYbDVXN8C6x85/aj+oW+mT9S3YZzw0bRPE/IKd9hJl vsb0WnJOZyDN9s5REo3+vIiZowiA9udZP4x7lKMjABqJlHo+J9VihNDzDAXV02VgHD7Fhv kiHrVi+lNRGTHWu5NSP7FFf+tOdiWOY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="R/MLFsPv"; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743606020; a=rsa-sha256; cv=none; b=sc7RjBX/PcjPwQCtcET8eriYXzc9Uykzuax+oYSYze/uvNSQ4FvtNHLfa/IVSQkW6ICGuB QqVHUs4pOB6cRi+oYaodaEO0oSyzw/e9IAC20C9YwQp9cCrwudXn+V5IBjmSgiADRFv0x6 OZ9cjCXr45lLjm2jJrMN+OKvZa5kz24= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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; bh=5XW0b8o2GA0rXaRAcMoHAk0zi9Q3pqKKR/5ZrqK6isA=; b=R/MLFsPvz24ooXP3n2jFFdaQXS M3AdX4NhgWKE+Ldr9ttHKD8qgG5GZYrzl4HoldQmoxWhsTna7sbeqGeV85qzgdBMglKSZcZo/qhDL 27mzrVxCjQJEvMLyNxePILgRc7e8EX9LjIZsx1RTe7+xFO4/WYXtZfFZp9QtaI2kspbnodfP3P44a fbnLduvq4PVvMS9Ka/aw11jUuI7aHj0yslB/pG7B/3rc6DfE161Izl44/4miE8Y+4cy2i60FQ4eM2 SOmtlICqt4DAxV3OBU6XtQ/ljD0WkgGJMiiWXQ4KH10ZgdKRajR1ONKHvVArn/PYczuOaMxhaNYYz gU7zsJJA==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzzZX-00000009gsB-18Xi; Wed, 02 Apr 2025 15:00:07 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , 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 Message-ID: <20250402150005.2309458-4-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402150005.2309458-1-willy@infradead.org> References: <20250402150005.2309458-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 92F4410000A X-Stat-Signature: hu591ntbce6iscasap3tty8uzkzajshg X-HE-Tag: 1743606020-865967 X-HE-Meta: U2FsdGVkX1936Bjf9xvfeT/jDhXENVdFXn5Lj+iUThqffJ8QL08ybjYXEc2ZALS3PyWhgjPz7f7EDqBXTpn9M0GjktWOQRt7RvxOxtd66q87bRLkbSqjl77/RsCNZ2fALbxvs8o+uW3v5ees+OmU0E1PEB8/siz3coP2f0Wz79jIrjkHN/qAsVXkBNE7yPvf2qWPoRBOqjBvp0eKbv83tSkJFrDDCJIobKhG/0dNAgFfGiXkyAC0I+f1uMTB+Oj11yGBe6qMs2g7ZHHhKXFMm6BvFNQvX6xeMMyBBABxjGBfvyl0RnYZmh49/b5HqHNYbDrWAbp8HoHFfDaLzTkBBIpSfBSJwxTrbyrmujO1Hisvbp+aMDvxlm/wlDPz+CYKX3jYN0t+OeVEzNwdBJJ/nCRv5LkXsdXUrstWnyPX6xFpeYI2t2W3VnogFMllSwno/M0GrbF9PnCPLjeFuM3D0vlw/B8qXD/H04aIXcWk0hvZWja1CvoAFRIL5te0rxOUiwKUIREQJSyHdBhs4W0XX/HZD40qSAvF8ZVmJkZSWS3VdY+x2/9uO+smFI8EXE4/rq2HYdiSZNWawBqfsqPOB1oechtNZ1T1yLYLxUQVLuI8JHxwUfyq9kuDzE3zqq2PKMov2tk4K372+15SaYIzZL+nwEMDMkuFvcTOmU5g6jjCSeYIbbXcj4yOSIyXM7nB8fOm9AkSFABl/SmrCcPR9H+es6O32TAzqYyVcoYSOdUIPj7AlWKEfeTDEwxz6SKDO7h8fV3K9iezQ/i/1lPgdTX4BhB+DSmdia1y0WnbligOfLkRZEhG7PLuAjOFJPuWi61K5BVA+1AE3XSejhhII+McTpI8A+0ge/DTHBqiiBUnHMsJI2BrBxjyRKeD5Pr23ADkwD2FSuzhMqglRTyiw4Ht20G0/Rez8kQPPRMHjhjTbUarir42sKfVZkMIL4HoOMmDpDryG6XCDoP0HhU hOfpYE2Z jB9EB+rXv7cG0NMeTMzpwD+L1RfYSkEM/aktusN1LyOvtm55lwwrvZ9r51qyJc1pyLkumoQGirmp9C/mHYa8yoiz/VpRCjjULdp/957GHd9I7EsC/ViTTu4wZvbVNq5UWIsokBMJIUM5TD2mxnK+SupcobIL67eQPGEXoWQOKSlWrIBXgWsd6JGzvndd3MnQo8Tv5/abi0lwZvaV+0d9XpJN7f4I1rZnh0YpDaHQBIKRSGbA= 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: List-Subscribe: List-Unsubscribe: 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) --- 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;