From patchwork Tue Sep 18 05:49:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10603747 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 0B9B35A4 for ; Tue, 18 Sep 2018 06:01:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED5522A2FF for ; Tue, 18 Sep 2018 06:01:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1DDA2A30A; Tue, 18 Sep 2018 06:01:09 +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 887FF2A2FF for ; Tue, 18 Sep 2018 06:01:09 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 726F72113DA22; Mon, 17 Sep 2018 23:01:09 -0700 (PDT) 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=134.134.136.31; helo=mga06.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 C5C4B2113DA19 for ; Mon, 17 Sep 2018 23:01:08 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2018 23:01:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,388,1531810800"; d="scan'208";a="74109101" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga008.jf.intel.com with ESMTP; 17 Sep 2018 23:01:08 -0700 Subject: [ndctl PATCH 2/3] ndctl: Revert "ndctl, intel: Fallback to smart cached shutdown_count" From: Dan Williams To: linux-nvdimm@lists.01.org Date: Mon, 17 Sep 2018 22:49:21 -0700 Message-ID: <153724976126.55312.1677206589965006541.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153724975102.55312.9664009456306267501.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153724975102.55312.9664009456306267501.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 Static device attribute data, if it needs to be cached and exported to unprivileged userspace, should live in sysfs. Cc: Keith Busch Cc: Vishal Verma Signed-off-by: Dan Williams --- ndctl/lib/intel.c | 41 ----------------------------------------- ndctl/lib/libndctl.c | 6 +----- ndctl/lib/private.h | 3 --- 3 files changed, 1 insertion(+), 49 deletions(-) diff --git a/ndctl/lib/intel.c b/ndctl/lib/intel.c index 15c5d1a60e34..0abea1e1f5ff 100644 --- a/ndctl/lib/intel.c +++ b/ndctl/lib/intel.c @@ -56,46 +56,6 @@ static struct ndctl_cmd *alloc_intel_cmd(struct ndctl_dimm *dimm, return cmd; } -/* - * If provided, read the cached shutdown count in case the user does not have - * access rights to run the smart command, and pretend the command was - * successful with only the shutdown_count valid. - */ -static int intel_smart_handle_error(struct ndctl_cmd *cmd) -{ - struct ndctl_dimm *dimm = cmd->dimm; - struct ndctl_bus *bus = cmd_to_bus(cmd); - struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus); - char *path = NULL, shutdown_count[16] = {}; - int fd, rc = cmd->status; - - if (!dimm) - goto out; - - if (asprintf(&path, DEF_TMPFS_DIR "/%s/usc", - ndctl_dimm_get_devname(dimm)) < 0) - goto out; - - fd = open(path, O_RDONLY); - if (fd < 0) - goto free_path; - - if (read(fd, shutdown_count, sizeof(shutdown_count)) < 0) - goto close; - - cmd->intel->smart.flags = ND_INTEL_SMART_SHUTDOWN_COUNT_VALID; - cmd->intel->smart.shutdown_count = strtoull(shutdown_count, NULL, 0); - rc = cmd->status = 0; - close: - close (fd); - free_path: - free(path); - out: - if (rc) - err(ctx, "failed: %s\n", strerror(errno)); - return rc; -} - static struct ndctl_cmd *intel_dimm_cmd_new_smart(struct ndctl_dimm *dimm) { struct ndctl_cmd *cmd; @@ -107,7 +67,6 @@ static struct ndctl_cmd *intel_dimm_cmd_new_smart(struct ndctl_dimm *dimm) if (!cmd) return NULL; cmd->firmware_status = &cmd->intel->smart.status; - cmd->handle_error = intel_smart_handle_error; return cmd; } diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 481b110d2a18..5bc97f25607c 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -2753,9 +2753,7 @@ NDCTL_EXPORT int ndctl_cmd_submit(struct ndctl_cmd *cmd) fd = open(path, O_RDWR); if (fd < 0) { - if (!cmd->handle_error) - err(ctx, "failed to open %s: %s\n", path, - strerror(errno)); + err(ctx, "failed to open %s: %s\n", path, strerror(errno)); rc = -errno; goto out; } @@ -2771,8 +2769,6 @@ NDCTL_EXPORT int ndctl_cmd_submit(struct ndctl_cmd *cmd) close(fd); out: cmd->status = rc; - if (rc && cmd->handle_error) - rc = cmd->handle_error(cmd); return rc; } diff --git a/ndctl/lib/private.h b/ndctl/lib/private.h index b6e438aff8c7..5ddc682b7514 100644 --- a/ndctl/lib/private.h +++ b/ndctl/lib/private.h @@ -227,8 +227,6 @@ struct ndctl_namespace { * @firmware_status: NFIT command output status code * @iter: iterator for multi-xfer commands * @source: source cmd of an inherited iter.total_buf - * @handle_error: function pointer to handle a cmd error and override it to - * return alternative data (from a cache for example). * * For dynamically sized commands like 'get_config', 'set_config', or * 'vendor', @size encompasses the entire buffer for the command input @@ -257,7 +255,6 @@ struct ndctl_cmd { int dir; } iter; struct ndctl_cmd *source; - int (*handle_error)(struct ndctl_cmd *cmd); union { struct nd_cmd_ars_cap ars_cap[0]; struct nd_cmd_ars_start ars_start[0];