From patchwork Fri Dec 28 03:29:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10744129 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 7731413AD for ; Fri, 28 Dec 2018 03:42:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 675F328C94 for ; Fri, 28 Dec 2018 03:42:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B1F828C99; Fri, 28 Dec 2018 03:42:37 +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.9 required=2.0 tests=BAYES_00,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 0B4EB28C94 for ; Fri, 28 Dec 2018 03:42:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 88E86211A1E4E; Thu, 27 Dec 2018 19:42:35 -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=192.55.52.93; helo=mga11.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3122F2194D3B9 for ; Thu, 27 Dec 2018 19:42:35 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Dec 2018 19:42:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,407,1539673200"; d="scan'208";a="103841430" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga006.jf.intel.com with ESMTP; 27 Dec 2018 19:42:34 -0800 Subject: [ndctl PATCH 0/7] ndctl/monitor: Cleanups and fixes From: Dan Williams To: linux-nvdimm@lists.01.org Date: Thu, 27 Dec 2018 19:29:58 -0800 Message-ID: <154596779833.164521.12632457592535372923.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 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 Prompted by a need to add more commands to daxctl, and define a new configuration file for daxctl to install, I took a look at the ndctl monitor configuration file implementation and several fixes fell out. An initial attempt to remove casts from the ndctl monitor uncovered other cleanup opportunities. The motivation for some of the casts in ndctl/monitor.c was due to the need to de-reference the 'ctx' parameter passed to the log routines. That issue can be mitigated by teaching the command harness to pass a typed version of the @ctx argument to the builtin-command routines. However, looking closer, the monitor should not be passing @ctx to the log routines, it should establish its own log-context. That lead to the discovery of a few more cleanup opportunities, like unnecessary usage of vaprintf(). More is possible. I am not comfortable with the fact that the log facility dynamically changes the output and the output target based on the priority. The monitor also has several occasions where it is dynamically allocating memory unnecessarily. --- Dan Williams (7): ndctl, daxctl: Split builtin.h per-command ndctl, daxctl: Add type-safety to command harness ndctl/monitor: Drop 'struct ndctl_ctx *' casts ndctl/monitor: Unify definition of default monitor configfile path ndctl/monitor: Fix / cleanup log_file() ndctl/monitor: Drop vasprintf usage ndctl/monitor: Kill usage of ndctl/lib/private.h builtin.h | 51 ---------------- configure.ac | 8 ++ daxctl/builtin.h | 8 ++ daxctl/daxctl.c | 16 ++--- daxctl/list.c | 2 - ndctl/Makefile.am | 6 +- ndctl/bat.c | 2 - ndctl/builtin.h | 35 +++++++++++ ndctl/bus.c | 4 + ndctl/create-nfit.c | 2 - ndctl/dimm.c | 18 +++--- ndctl/inject-error.c | 3 - ndctl/inject-smart.c | 3 - ndctl/list.c | 2 - ndctl/monitor.c | 163 ++++++++++++++++++++------------------------------ ndctl/namespace.c | 10 ++- ndctl/ndctl.c | 64 ++++++++++---------- ndctl/region.c | 4 + ndctl/test.c | 2 - util/main.c | 13 ++-- util/main.h | 20 ++++++ 21 files changed, 207 insertions(+), 229 deletions(-) delete mode 100644 builtin.h create mode 100644 daxctl/builtin.h create mode 100644 ndctl/builtin.h