Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp481241iog; Wed, 15 Jun 2022 06:19:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tMu5daRhXU0j5bPCc+tZ3XcUQNSBjnL53gdBq6qBfnJjVyo5tqel6RQbOqKD1j0ItWdGhJ X-Received: by 2002:a17:902:f149:b0:167:8569:ec00 with SMTP id d9-20020a170902f14900b001678569ec00mr9373616plb.8.1655299152107; Wed, 15 Jun 2022 06:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655299152; cv=none; d=google.com; s=arc-20160816; b=MhdnOe6ALhP1XB+sXqe1Vbswuytnwy528KBGPlPSoZ6oftKQ++MUEUvx/5u+a11Cpd gHYXW/2BVhkUrj35ndxhLQl8xjJY7FHcrhmA0rn4JW+ltB7tBSJ1uw0R4unNbVVb+nqQ LDeKOaJBBijwnfMUdVd7jHrEuCHHiaOKQqDSt+CBfb2ZJCuvGlP0dWyFY+5ToEiK8IFD FBV0sB9LFy8LG/b/u60iFbfzyHdrvJc3+QxXuTxUQbkheoEb/nA9mL70pvgLrKMojDn8 gb6FNt90uSFxPHW6BzuLFxP4Jwcfn0kNKoaoT9kcwSaU4OvHwZwjBm2pAloxdMWjv9V1 4VUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-hdrordr:ironport-data; bh=Dw4dtxLXgUncvsBJ+rKIMob/7PeKF+kPxOCHo5iCiZc=; b=soL7ssAD7WBGQdL6/uZOMijd4YmC007SlpKf56Fdr91+aCczzWlrFhkzaVhUNkFQ8S s8gu+FnNeAqE/BQus5kApvRz010YQZLspNQiVZ+8T8Yq//fMcDoL92Tj07wAj0v28Ns6 mR+O4l3bfi4VGdx5JBNK35sheu/yGtaVs54A3TXbSYlU6obN24DtFXBENqa9QHBd3bgM iy9e1fEWFZvvv+wAxx8M6GThX3gI+zMF18Dbe3cq4htD82iwjpxO1PxZ3lsUIBQtTuBK V/8YvzkOMsDjze9rNrEmEu62GfaTJY8kjdWGUOrRI9RuoL9lWiN3i09bgqMw9haNBgiz e3Dw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a170903230500b00164179b39acsi17879072plh.556.2022.06.15.06.18.56; Wed, 15 Jun 2022 06:19:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244422AbiFOMyM (ORCPT + 99 others); Wed, 15 Jun 2022 08:54:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349376AbiFOMyH (ORCPT ); Wed, 15 Jun 2022 08:54:07 -0400 Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CD04C2DD5F; Wed, 15 Jun 2022 05:54:04 -0700 (PDT) IronPort-Data: =?us-ascii?q?A9a23=3A7AsUtKId1AvLrT49FE+RupQlxSXFcZb7ZxGrkP8?= =?us-ascii?q?bfHDo0Dkr02BTnWVNUWrQaPqNYWqjKNoib4u3pE4Gv8fVm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D=3D?= X-IronPort-AV: E=Sophos;i="5.88,333,1635177600"; d="scan'208";a="124979929" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Jun 2022 20:54:03 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id D8E334D1719F; Wed, 15 Jun 2022 20:54:02 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD05.g08.fujitsu.local (10.167.33.204) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 15 Jun 2022 20:54:04 +0800 Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 15 Jun 2022 20:54:02 +0800 Received: from irides.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.23 via Frontend Transport; Wed, 15 Jun 2022 20:54:02 +0800 From: Shiyang Ruan To: , , , , CC: , , , , Subject: [RFC PATCH v3] mm, pmem, xfs: Introduce MF_MEM_REMOVE for unbind Date: Wed, 15 Jun 2022 20:54:00 +0800 Message-ID: <20220615125400.880067-1-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220410171623.3788004-1-ruansy.fnst@fujitsu.com> References: <20220410171623.3788004-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-yoursite-MailScanner-ID: D8E334D1719F.A2FA5 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is inspired by Dan's "mm, dax, pmem: Introduce dev_pagemap_failure()"[1]. With the help of dax_holder and ->notify_failure() mechanism, the pmem driver is able to ask filesystem (or mapped device) on it to unmap all files in use and notify processes who are using those files. Call trace: trigger unbind -> unbind_store() -> ... (skip) -> devres_release_all() # was pmem driver ->remove() in v1 -> kill_dax() -> dax_holder_notify_failure(dax_dev, 0, U64_MAX, MF_MEM_REMOVE) -> xfs_dax_notify_failure() Introduce MF_MEM_REMOVE to let filesystem know this is a remove event. So do not shutdown filesystem directly if something not supported, or if failure range includes metadata area. Make sure all files and processes are handled correctly. [1]: https://lore.kernel.org/linux-mm/161604050314.1463742.14151665140035795571.stgit@dwillia2-desk3.amr.corp.intel.com/ Signed-off-by: Shiyang Ruan == Changes since v2: 1. Rebased on next-20220615 Changes since v1: 1. Drop the needless change of moving {kill,put}_dax() 2. Rebased on '[PATCHSETS] v14 fsdax-rmap + v11 fsdax-reflink'[2] --- drivers/dax/super.c | 2 +- fs/xfs/xfs_notify_failure.c | 6 +++++- include/linux/mm.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 9b5e2a5eb0ae..d4bc83159d46 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -323,7 +323,7 @@ void kill_dax(struct dax_device *dax_dev) return; if (dax_dev->holder_data != NULL) - dax_holder_notify_failure(dax_dev, 0, U64_MAX, 0); + dax_holder_notify_failure(dax_dev, 0, U64_MAX, MF_MEM_REMOVE); clear_bit(DAXDEV_ALIVE, &dax_dev->flags); synchronize_srcu(&dax_srcu); diff --git a/fs/xfs/xfs_notify_failure.c b/fs/xfs/xfs_notify_failure.c index aa8dc27c599c..91d3f05d4241 100644 --- a/fs/xfs/xfs_notify_failure.c +++ b/fs/xfs/xfs_notify_failure.c @@ -73,7 +73,9 @@ xfs_dax_failure_fn( struct failure_info *notify = data; int error = 0; - if (XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) || + /* Do not shutdown so early when device is to be removed */ + if (!(notify->mf_flags & MF_MEM_REMOVE) || + XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) || (rec->rm_flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK))) { xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_ONDISK); return -EFSCORRUPTED; @@ -182,6 +184,8 @@ xfs_dax_notify_failure( if (mp->m_logdev_targp && mp->m_logdev_targp->bt_daxdev == dax_dev && mp->m_logdev_targp != mp->m_ddev_targp) { + if (mf_flags & MF_MEM_REMOVE) + return -EOPNOTSUPP; xfs_err(mp, "ondisk log corrupt, shutting down fs!"); xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_ONDISK); return -EFSCORRUPTED; diff --git a/include/linux/mm.h b/include/linux/mm.h index 623c2ee8330a..bbeb31883362 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3249,6 +3249,7 @@ enum mf_flags { MF_SOFT_OFFLINE = 1 << 3, MF_UNPOISON = 1 << 4, MF_NO_RETRY = 1 << 5, + MF_MEM_REMOVE = 1 << 6, }; int mf_dax_kill_procs(struct address_space *mapping, pgoff_t index, unsigned long count, int mf_flags); -- 2.36.1