From patchwork Wed Feb 20 05:11:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 10821183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C788F1399 for ; Wed, 20 Feb 2019 05:11:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB68D2DEBE for ; Wed, 20 Feb 2019 05:11:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E53A2DEC4; Wed, 20 Feb 2019 05:11:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3C16C2DEBE for ; Wed, 20 Feb 2019 05:11:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3448D2095AE5E; Tue, 19 Feb 2019 21:11:45 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.131.130; helo=apc01-sg2-obe.outbound.protection.outlook.com; envelope-from=decui@microsoft.com; receiver=linux-nvdimm@lists.01.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-eopbgr1310130.outbound.protection.outlook.com [40.107.131.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2BA74208F612F for ; Tue, 19 Feb 2019 21:11:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=12KIYdP5ktHlFfiCIBMy0xTpMHsEmUY6J84hjLNFLXo=; b=RUTOXya9bK2JiA1W6CuMOEX+Jvu3UwrsIIpdkyi0SH0CXDP74lsGODntgIRmMvTfdcOm2ZoghQZReyXMjZpQ64tG3n888C5y5Ydi8Gf9Wa4dU81GBsZWlZlp2FZ6EyE4mvsgXAMqj8K39RzzTBM8JS94Lr76A51Hau1YLt2cV70= Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM (10.170.189.13) by PU1P153MB0105.APCP153.PROD.OUTLOOK.COM (10.170.188.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.0; Wed, 20 Feb 2019 05:11:40 +0000 Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f]) by PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f%9]) with mapi id 15.20.1665.002; Wed, 20 Feb 2019 05:11:40 +0000 From: Dexuan Cui To: Dave Jiang , Vishal Verma , Dan Williams , "linux-nvdimm@lists.01.org" , Michael Kelley , "qi.fuli@fujitsu.com" , Johannes Thumshirn Subject: [ndctl PATCH v2 4/4] ndctl, monitor: support NVDIMM_FAMILY_HYPERV Thread-Topic: [ndctl PATCH v2 4/4] ndctl, monitor: support NVDIMM_FAMILY_HYPERV Thread-Index: AdTI2rz1QLsetrmLRMK6s1y+OGDh+w== Date: Wed, 20 Feb 2019 05:11:40 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2019-02-20T05:11:38.6924733Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=efa35817-4f58-413a-b0c0-203c5da79211; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic x-originating-ip: [2001:4898:80e8:9:e09f:1351:8c90:7b8c] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1aa32363-d4ac-416a-5c00-08d696f1e5d4 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600126)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:PU1P153MB0105; x-ms-traffictypediagnostic: PU1P153MB0105: x-ms-exchange-purlcount: 1 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; PU1P153MB0105; 23:/vLFxViaBf/CZyuTqqnEK35ItejF4KKZshnxxViW8?= d0xGad9hmVcVJiYlEKNJCW42XvnKh+Va+glRtXbFYpIgIrEaMDTCkf2p+A6d4uYzJ7pJJJYFe3RwYF+j0zy/ccKQE1CrUxPjy0+w1kATeh1Vwgvb3PwiBkr/AEU4EX//6EpyPZEdDGBbaEKBdb7OBBgxIxhpM2ISm91TaOIwPOUnZqDdmQhSDzNG7J/OuVr5pdDZjuN0kIpLu8rZ31PuYTDp74G0Bxrg44PjS5kI4C0vHRDlFrr8ocnd+bVCbM477vtkOHrl25qBdO/5E+rt7DEbGkdcz7JHUrW6VQ9v4lpALviiuLt0AXXfEJw/4tAYTt07T89ANha9SA7hCDV+/Rbrz900qFyEEOiNH1PYK72Z51l4uKk2ryH2SIcx+L0EGMY8co7Y1ALqtpSW8Eh7GzfBlEODzWhIccD5VwyEgHqpsfxOHjnoNtyNOIl7OafN56cf4Fj03zqgy3Tw6KS9NRvBBTf4kqec5frB9Cu8WRhbsZ8W0tK1/ZZvchOhaBOywL+2rBZVjn+zwsnmIlCOWHsvgJR6VZE1GtlIXc3zTvfbWzLfutGuu/giDkJht/HSD9Z59PUAQE2UMORPW69EUU3txiCNLrEfsTsG6G4l7oewLXY3iVF3/5tDKfYt1wbvWePvghWR8khqEnVo28Bf/C5YqNJ6dkxhU5QcV2dnB1R0BrdLm6sDOuy7S4CgNwgCeX76lmXJVzgadbxFG2d/yl3J87tnNHCqrqZleSrVDxKUY5iqPh2YRk6uGBnu4+adI4a39ZJD525dzrutIMH9qAjfC/jmL1R99nNmLihq9l++RemstyJJAVYc4cMu499OBmS1JExAxHALBjGLrPL/n1YLz6PjoMrlIJFEz/Dd/lQfezz2TsINzmedQfpXrUhOQXUbqM95S8LIHu4kMEFRIU5djgy2OGck+lirb8ssyt7lGx2WvgckYS1yI881FEoOh4jfNgh4zgoep9NWOiy7/mngKmKI4Irt+Xu8ChM6CxwSMLqrn/fQsUvQFTC34JfgROfgwlo6/LAW2ssN4pb0G8kLRAPug9kIl6SnkuuoQgG7zRBK7XMrerJyTjd3TwbaJF79i8Yn5gDPHQnkpE2X56jiUTb6c6rB/y5oBKuINvTQrTIRiGQBHTJRE7/kyodXy5RXmhBhulsy/LJ5nuae+KP57M1JuVd0GwUlE/xvExEq7m4azF4z461q8pPa8MyxHM= x-microsoft-antispam-prvs: x-forefront-prvs: 0954EE4910 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(366004)(346002)(376002)(136003)(396003)(189003)(199004)(33656002)(478600001)(110136005)(316002)(14454004)(22452003)(106356001)(2906002)(46003)(8990500004)(6506007)(476003)(486006)(71200400001)(71190400001)(14444005)(256004)(186003)(6116002)(105586002)(10290500003)(68736007)(1511001)(97736004)(10090500001)(966005)(6346003)(102836004)(9686003)(6436002)(8676002)(55016002)(5660300002)(81156014)(6306002)(7736002)(305945005)(7696005)(86612001)(25786009)(53936002)(2501003)(74316002)(99286004)(86362001)(8936002)(81166006); DIR:OUT; SFP:1102; SCL:1; SRVR:PU1P153MB0105; H:PU1P153MB0169.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: gP2ovw2DiJlFrNojmBnNE/ZjTXFl+8F3M/j1cUjkB/EXsEYha82Sv/VkPIyxx4hIHgVyHH+2kRnetuGIHUGWAdjRc9LdNE7OUFwRMgetQvEVVsGZ+pwkL0EwnP31jrj72V6iq0Lg4GQsjCurpY837F37/M3IjxuP20qmL36BjQ9Ept7AGZLpmbO71THLdl1XF4jQsOQ2NJGCiTRlK5YjhpkOFIAipHc6MKxdKuZLfszTx7mm9GMo/Jj2PEU3bGRKL8Yh8xaN0BNjfhJaQhcYYcvWLFqDZ4JdIz4ProcPHes2eNbVJ/QnMxq5WioxBoTcwX57utzj4POOjl093qGQVkppIvJqt2lNN35Kd4kHgDy9w16wMDrvXJq0wynBpSi1oF7GFani/9zVbPaBZOl5CEWPl3HCuY7lvZXE/XXNS54= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1aa32363-d4ac-416a-5c00-08d696f1e5d4 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Feb 2019 05:11:40.2390 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1P153MB0105 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Currently "ndctl monitor" fails for NVDIMM_FAMILY_HYPERV due to "no smart support". NVDIMM_FAMILY_HYPERV doesn't use ND_CMD_SMART to get the health info. Instead, it uses ND_CMD_CALL, so the checking here can't apply,and it doesn't support threshold alarms -- actually it only supports one event: ND_EVENT_HEALTH_STATE. See http://www.uefi.org/RFIC_LIST ("Virtual NVDIMM 0x1901"). Let's skip the unnecessary checking for NVDIMM_FAMILY_HYPERV, and make sure we only monitor the "dimm-health-state" event and ignore the others. With the patch, when an error happens, we log it with such a message: {"timestamp":"1550547497.431731497","pid":1571,"event": {"dimm-health-state":true},"dimm":{"dev":"nmem1", "id":"04d5-01-1701-01000000","handle":1,"phys_id":0, "health":{"health_state":"fatal","shutdown_count":8}}} Here the meaningful info is: "health":{"health_state":"fatal","shutdown_count":8} Signed-off-by: Dexuan Cui --- ndctl/monitor.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/ndctl/monitor.c b/ndctl/monitor.c index 43b2abe..43beb06 100644 --- a/ndctl/monitor.c +++ b/ndctl/monitor.c @@ -265,31 +265,59 @@ static bool filter_region(struct ndctl_region *region, return true; } -static void filter_dimm(struct ndctl_dimm *dimm, struct util_filter_ctx *fctx) +static bool ndctl_dimm_test_and_enable_notification(struct ndctl_dimm *dimm) { - struct monitor_dimm *mdimm; - struct monitor_filter_arg *mfa = fctx->monitor; const char *name = ndctl_dimm_get_devname(dimm); + /* + * Hyper-V Virtual NVDIMM doesn't use ND_CMD_SMART to get the health + * info. Instead, it uses ND_CMD_CALL, so the checking here can't + * apply, and it doesn't support threshold alarms -- actually it only + * supports one event: ND_EVENT_HEALTH_STATE. + */ + if (ndctl_dimm_get_cmd_family(dimm) == NVDIMM_FAMILY_HYPERV) { + if (monitor.event_flags != ND_EVENT_HEALTH_STATE) { + monitor.event_flags = ND_EVENT_HEALTH_STATE; + + notice(&monitor, + "%s: only dimm-health-state can be monitored\n", + name); + } + return true; + } + if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SMART)) { err(&monitor, "%s: no smart support\n", name); - return; + return false; } if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SMART_THRESHOLD)) { err(&monitor, "%s: no smart threshold support\n", name); - return; + return false; } if (!ndctl_dimm_is_flag_supported(dimm, ND_SMART_ALARM_VALID)) { err(&monitor, "%s: smart alarm invalid\n", name); - return; + return false; } if (enable_dimm_supported_threshold_alarms(dimm)) { err(&monitor, "%s: enable supported threshold alarms failed\n", name); - return; + return false; } + return true; +} + +static void filter_dimm(struct ndctl_dimm *dimm, struct util_filter_ctx *fctx) +{ + struct monitor_dimm *mdimm; + struct monitor_filter_arg *mfa = fctx->monitor; + const char *name = ndctl_dimm_get_devname(dimm); + + + if (!ndctl_dimm_test_and_enable_notification(dimm)) + return; + mdimm = calloc(1, sizeof(struct monitor_dimm)); if (!mdimm) { err(&monitor, "%s: calloc for monitor dimm failed\n", name);