From patchwork Tue Mar 28 09:41:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13190767 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 B7F3AC76196 for ; Tue, 28 Mar 2023 09:42:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D8736B0072; Tue, 28 Mar 2023 05:42:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3131B6B0078; Tue, 28 Mar 2023 05:42:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13E726B0072; Tue, 28 Mar 2023 05:42:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E32326B0072 for ; Tue, 28 Mar 2023 05:42:30 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BE58C1A0171 for ; Tue, 28 Mar 2023 09:42:30 +0000 (UTC) X-FDA: 80617816860.01.72373B8 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.1]) by imf03.hostedemail.com (Postfix) with ESMTP id 804DC20019 for ; Tue, 28 Mar 2023 09:42:28 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=170520fj header.b=u5LXODGK; spf=pass (imf03.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 195.245.231.1 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com; dmarc=pass (policy=none) header.from=fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679996548; 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:in-reply-to: references:dkim-signature; bh=5ysgX3w4r/9z7wfbPe30efN793AZmmL/VAdTe4COUNg=; b=ukCvqbRv1sHUJGl0QfWptbjIXDNEMuxe1LCwQGAgqD7oaG6MYA2aZ0Yx16IkxmduKdNIVb wKbNLP02tGbzyCQYuyEPt9R2xEkv6SyuLJUuMeraM4nCS9RkyLWpfVfoOAoFQz5gIFY94M 6qIk58yOQIP08g6VfcOPNk7rrofhYyk= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=170520fj header.b=u5LXODGK; spf=pass (imf03.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 195.245.231.1 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com; dmarc=pass (policy=none) header.from=fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679996548; a=rsa-sha256; cv=none; b=A0arHfvt3gyhXGDdc8hndJSTFdvH/G2jkZ4dbIkocG2l1+KZxp9B7QK4+RSTtca7lWmi7a U+fNwOPfhB9a2Nl+A46w85vr7zc5Ybvw1P9zSvqTpZ8tReTxP8unXPHvAcgQum5Cm/SoK+ Fq0LH6kZ1rzwzIiMnV/p99viMzeCJ+Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1679996547; i=@fujitsu.com; bh=5ysgX3w4r/9z7wfbPe30efN793AZmmL/VAdTe4COUNg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=u5LXODGK/FG2+ThkcCErIQ3XT6s7340iM4GN/KR0FYHUojfV8FFAHtjtrG5VomqMT wpb2RGvBRPqETpHk74WqXr7fUYWYY9mv6FbS+MqyawH0rhZJPw6LdaOEGeKZpPq/q2 iwiAyHHSe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tcMf3v6 5UPbNS5hb4VmK4/v53/tzcCAvWzLk3lTW/7Io71Sz1q59P2U3Q0zZVMZ+ts18lwHDu6ar6W3b Py/U+h8sdc7Kynl74d6kp+7Sjz7tY4h4t29uf+kHQK9jiwIP9Wyuy15mL1h0ueXjq4KnC/soX /eVbNU77bBNyjvqw5+aXbXrTmjz0ay0T1yTrBdnVBF85Xzh9wrPYiMUmUwp60zlUb/Zqi90uv zahJtDubF24d9aX2jkHY7R4diixFGckGmoxFxUnAgBGx1palQMAAA== X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-3.tower-571.messagelabs.com!1679996540!574172!1 X-Originating-IP: [62.60.8.97] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.104.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 902 invoked from network); 28 Mar 2023 09:42:20 -0000 Received: from unknown (HELO n03ukasimr01.n03.fujitsu.local) (62.60.8.97) by server-3.tower-571.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Mar 2023 09:42:20 -0000 Received: from n03ukasimr01.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTP id 29CE31001A5; Tue, 28 Mar 2023 10:42:20 +0100 (BST) Received: from R01UKEXCASM121.r01.fujitsu.local (R01UKEXCASM121 [10.183.43.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTPS id 1D68F10019D; Tue, 28 Mar 2023 10:42:20 +0100 (BST) Received: from 692d629b0116.g08.fujitsu.local (10.167.234.230) by R01UKEXCASM121.r01.fujitsu.local (10.183.43.173) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 28 Mar 2023 10:42:16 +0100 From: Shiyang Ruan To: , , , CC: , , , , Subject: [PATCH v11 0/2] mm, pmem, xfs: Introduce MF_MEM_REMOVE for unbind Date: Tue, 28 Mar 2023 09:41:44 +0000 Message-ID: <1679996506-2-1-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.167.234.230] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM121.r01.fujitsu.local (10.183.43.173) X-Virus-Scanned: ClamAV using ClamSMTP X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 804DC20019 X-Rspam-User: X-Stat-Signature: euenmc5riphr9bksgu4za5x7t88ps8a1 X-HE-Tag: 1679996548-828682 X-HE-Meta: U2FsdGVkX1/tTL/fGbrDzelQtlJzHtmLq6MBzV9rF+N9UYXqcUiapDNtUoj4b90QCZsakRK+Mm+TNKreEQ/vi0S1LZFC31Z7g4/nNVbuw4vxlLVq2WeUdQMspINwr5s+19/MTUkcIzvL3VyZPxNfxzMWip4jFtqZD3ZcyYTzpyDCURuvSNukdplsWq513bYuhg+Q7KPiLt0oFb6/KfoLaxla4HgfHpav9SNZDtgngI2XrlEFD/NKMaUJzfBev+VGemuIrzJt11vrRitg80hrZTQOWi5LYGiIYqUbRbDTAOmtnflW6zqKzWEh9NquBZbB6o9XBQZWY6sbFtXUDGf4cyxC4yugi+lYR9+01C8/ufLx6TApzR1N5juVrZVCXrYU2zhgPxiYe+WXAGCFVq5cLzeKVODZylq8anGrjrBceLLRLpECuf7Jj9+fVuPL1SQCFIFOO5H3D+xfdiS9Q2jMpgoN7KIXJx4QXWliYdtpE8gNNjpUFIjCNmxMdKj06FF0b4NF1I/bs4+OS+Zr+Qx3lxi7HNqa11EYQxqBBPII3VidIhIJuIdRusymS5KtV/WD6Le4Kzq42M5oj1eGVH2+L5ASQuaQ3Iu1EFDYGrDna93ml8rD4HX4uWkCXdz1RthH+SmTnP02aC0412mUadXMRnTnZjnfFWufUh6hqzblEOoQbo7PZZUFMPsFWKRfKmDCse263PK2h3ymvcI+nyfJ4YmvQ4gVJQ0NTJqekHFbo2u471qhuUFLJwdpelDTyJ0btIRcibeMKws1AxZsmCBa4zDTDTntgWKIVqFq+Xqkfh8UM2HTfgsrmRr3XRJkRNixVsmNQ/XUsO5C3311grbC7AELlq0Q2KDUH6wMTiHdUiCl4Aa0re9D2uIeT7Ehpf65WmOPOuc6qv+7BQYk8vWudt5o3qVsp0/bWQlhpTj7FjAyp8tjWNa83N/4qr5/Nj1au9QvQC0L1jl57wYkJbe DrEuLk/X AXMUs92CmlVcN+oRuxJKbDB3l6JAHl6DWYg5+nWXoAbBYo4Zh/dZxIDd9yZJdqwHkNqFjiNhAvWQC8MUtPpg7sYhXDFjJzont57YPPzvXWxBTXNW6UELSiBEYRMogRXJ73pkD7uDzqqUM06fE+vHNnGEfkk16CggdciBGb0mPxcw1Om5Q6alE6XdTis0b4L/9boSoEznk+oXvzPzcfKeThRgbr6lbG5/9B+WXHMRTf1DwgIqtF+uMWzZcT3YGpJagNqzV5EXavz4fhcvRN+Ys3IuauPlH5sLU+nCxRvIj8EHb7AA04gNXs05p3RK41jmmJdYTct/3XYbnb9A14lUHkBbWzb0HBln145xT6vRHqvD039RkRaUoI18cow2JEAhoG2V2L9E65kYW76w= 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: This patchset is to add gracefully unbind support for pmem. Patch1 corrects the calculation of length and end of a given range. Patch2 introduces a new flag call MF_MEM_REMOVE, to let dax holder know it is a remove event. With the help of notify_failure mechanism, we are able to shutdown the filesystem on the pmem gracefully. Changes since v10: Patch1: 1. correct the count calculation in xfs_failure_pgcnt(). Patch2: 2. drop the patch which introduces super_drop_pagecache(). 3. in mf_dax_kill_procs(), don't SetPageHWPoison() and search for all tasks while mf_flags has MF_MEM_PRE_REMOVE. 4. only do mf_dax_kill_procs() on dax mapping. 5. do invalidate_inode_pages2_range() for each file found during rmap, to make sure the dax entry are disassociated before pmem is gone. Otherwise, umount filesystem after unbind will cause crash because the dax entries have to be disassociated but now the pmem is not exist. For detail analysis of this change, please refer this link[1]. [1] https://lore.kernel.org/linux-xfs/b1d9fc03-1a71-a75f-f87b-5819991e4eb2@fujitsu.com/ Shiyang Ruan (2): xfs: fix the calculation of length and end mm, pmem, xfs: Introduce MF_MEM_REMOVE for unbind drivers/dax/super.c | 3 +- fs/xfs/xfs_notify_failure.c | 66 +++++++++++++++++++++++++++++++------ include/linux/mm.h | 1 + mm/memory-failure.c | 17 +++++++--- 4 files changed, 72 insertions(+), 15 deletions(-)