From patchwork Wed Jun 26 08:53:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13712430 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 B4C6FC30653 for ; Wed, 26 Jun 2024 08:54:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4857C6B0093; Wed, 26 Jun 2024 04:54:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 412E16B0096; Wed, 26 Jun 2024 04:54:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 176636B0098; Wed, 26 Jun 2024 04:54:46 -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 C5EF76B0095 for ; Wed, 26 Jun 2024 04:54:45 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 827B2C0C8D for ; Wed, 26 Jun 2024 08:54:45 +0000 (UTC) X-FDA: 82272429330.07.66554B0 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf18.hostedemail.com (Postfix) with ESMTP id 9745D1C000D; Wed, 26 Jun 2024 08:54:42 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719392062; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=55a+RYVMO2xObEKXg6OIQKt+jLPX8WHUckSNrVuuSxU=; b=0Ai6vr8ma2rIGKw73jMiPQff9H/mG7hhaPiUbQ9FtbmE7x+pu7uloLmLEJXSbrzylUv4jw KlU0Ie30leUKv4KJSGTGE/oSSWe+lGzo2bfxaI46M5lUBjlihyJfbpb6rGlp2CvJsCyKzr pwKYVOsM2PEQLFds7ZDj/RrmROen0bc= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719392062; a=rsa-sha256; cv=none; b=HzdznB91YwK5D2cvRZWJRfqFILnBcKwOuXDIIeQvRda2QuPJaMgvi3IrR1hdNQ1FoM4oAP ca1ZYY7/yVsXWU6fgsqqR+QOoyvirw6kebJYc5EieQV6CdprMSh0ZW7aoAdJaqECokP+r5 rFWGSibwYzZbnb1d/2Uc44SuxIoQf5E= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4W8Fm32Bt4z1ytgJ; Wed, 26 Jun 2024 16:50:59 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 3ADFA1A016C; Wed, 26 Jun 2024 16:54:39 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 26 Jun 2024 16:54:38 +0800 From: Kefeng Wang To: , CC: Tony Luck , Miaohe Lin , , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , Jiaqi Yan , Hugh Dickins , Vishal Moola , Alistair Popple , Jane Chu , Oscar Salvador , Lance Yang , Kefeng Wang Subject: [PATCH v5 5/6] fs: hugetlbfs: support poisoned recover from hugetlbfs_migrate_folio() Date: Wed, 26 Jun 2024 16:53:27 +0800 Message-ID: <20240626085328.608006-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240626085328.608006-1-wangkefeng.wang@huawei.com> References: <20240626085328.608006-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9745D1C000D X-Stat-Signature: woomsod3zdpee7g3somjjpit3bteynsq X-Rspam-User: X-HE-Tag: 1719392082-143514 X-HE-Meta: U2FsdGVkX19BNhuE2hg1meNBad8gCZ/3c/rrU4BToUL5SxMQs+UuSYBSaa8qGYTRwb9ZdAjwHhM3VnlzK/020L0v3t7mTCzQK0sz9dO+QZ9eVxzW3xYaQy+dJsNiB6PHR9Cw7Lt41KMi+CJqTliaZBkjOkllbRKTC9WGzC9GDkmRL8MWchQ6HxGUn30OmsGpgZmGMm9dwsEWsJxAda40HFCYS78q+JS/YqEE8hSB6F5pGDgnQvn+wRmFNCS7sTD89jumOpmeToG3R3OWsC/zzI9TlhI4QDyJKQLDe9lkpMn5LQ6ZgbT6ues1Hw+QfAdxw7GtXSZUgpUZkE26Cs/hyQOTDes2r/baAcH/A9vyPlk/FpU1Tl067NbYTWnuIKRGZr3alOu3u8pQs0o/5+UUkzdgYWWFnTa0MypKYxdxeaosjBU5+l9mzxClq8EPkwurMawLANPb3GCqYXLWQAXkUwufgWu8TQprfl350HRwGKgb76yB+9lJt5gez8hbTvQgya+Wrnr8HeuXLTUiXRhk/p7jQw9Fuf0eb3D7neZ0lHTbgxt1PDGhJopKiYSfESjRu5+seeSgCCX07kBVzxdX9K9DJabmLdEbgBByTjjhHcHUZhXSCTsekD4wIbJx1wJvUSE3Nrnpx6KMHcDLRB8AHSEl4+r4Wt3naH00bm6buSChceJRYjpHpy4ropcLtYHSVIaW+GXOtnWhH7a7eFosJ/j2+qSYRkvvd3YoezYcdkgNFJUglmwNK1JE1cTLNE22TeQ359Mo2cVs0hLxU3g6c9Lf7kTenmhmC2Zyxa0zo5VDYgOdoZDwPpQC9916nH0FAddu414gM8W7rrTMZZcBV8mMA6R9HcSRwsvJUYtceNX9nRe8t+OsqvTVkDvuYT8OCGwAJ6J4llRFcupvb+BhLtmRX3KBqSOD8wnD58PWxkQznRzzE4oC8AFj30YFIIYCeYT/gTfaXiaEEnqTh7G k5OwHVNN 9ib91BEHshnSycfJLanA5Kk2VKJYhwVzY8rxloLfId0IM8NRoRf5Uux+uk2U3rF1ZK8wvT+nofr7zLRFCwREmV+Te9MaqHf8rD6haNcZ2/v0h8kc9hWnBOdaS742ZGWSxEI8gsmR50wXmqBFv9fyMTlBzRCbqx+C6xzNLS0piGSmaNYSQ99TC3KwZUYTCA8lNKyM2j/2D9kRu5WDmI/ok4mwMTNC8/C7sUEAcZ5RViD7KmQOIatDaLwKTYe3B4S5tfYte8cv+tXaXNKk= 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: This is similar to __migrate_folio(), use folio_mc_copy() in HugeTLB folio migration to avoid panic when copy from poisoned folio. Signed-off-by: Kefeng Wang --- fs/hugetlbfs/inode.c | 2 +- mm/migrate.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 9456e1d55540..ecad73a4f713 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1128,7 +1128,7 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping, hugetlb_set_folio_subpool(src, NULL); } - folio_migrate_copy(dst, src); + folio_migrate_flags(dst, src); return MIGRATEPAGE_SUCCESS; } diff --git a/mm/migrate.c b/mm/migrate.c index f9d700d82ea9..ad78b053815a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -537,10 +537,16 @@ int migrate_huge_page_move_mapping(struct address_space *mapping, struct folio *dst, struct folio *src) { XA_STATE(xas, &mapping->i_pages, folio_index(src)); - int expected_count; + int rc, expected_count = folio_expected_refs(mapping, src); + + if (folio_ref_count(src) != expected_count) + return -EAGAIN; + + rc = folio_mc_copy(dst, src); + if (unlikely(rc)) + return rc; xas_lock_irq(&xas); - expected_count = folio_expected_refs(mapping, src); if (!folio_ref_freeze(src, expected_count)) { xas_unlock_irq(&xas); return -EAGAIN;