Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp397016pxf; Wed, 31 Mar 2021 06:16:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF4xWjhV/jiA4o9HC22lpVAxn9u8OTCbt2qZHA2CX0kmsd3tXz1B5RRCR6PfCG/Ci23E5v X-Received: by 2002:a05:6402:1613:: with SMTP id f19mr3748613edv.222.1617196608952; Wed, 31 Mar 2021 06:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617196608; cv=none; d=google.com; s=arc-20160816; b=c1/VxrOus1QvpO8oEUGNFk6YsOujDdjWz01sta3ObJSrIbAoqEC8/L4AMfHwfGRAGE Hh5zBDmUd2xHNdor/hW5OMivtr+ctBWxR2Qczn9L4A4pVsNC5/bNdTLzwWnb2dXUaVp3 helyL3fgX6iwYd+YtMMTCs6O96c4bTccLKFQ2b5/IKE1aj1KngmFbEqj7R7cZTZNN/18 7CwqdpzKxGxzD8JbZu2O1Ylt+2vDOXtMQc63xGd3jLNbLbK6QWHc3E43DNHzwqc4UywM b+OLnjE+7z5/AA7C2b1mphRthhC8F7gTDC89d5R26StkOKmki412Pb9oBLb7s/zaFNFA 6sAg== 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 :message-id:date:subject:cc:to:from; bh=94AHzfgfKkp8D4O6sSbA1Sg7bfIGyNFxlCvP+csJQB8=; b=id8cCCnpfFUzK2UKf3EfrfeA6ly1QTRCKydtbw7s3FfFYxxSbrIpsEoJ404eg6ZzO+ OdGe3enCHUAGGrbk93zwPCj6NAhGQXVZriikWbap8FriIpUoPKakdGg+Ln/v1o2gyl4x ysUqzJ1f6+H/KD0VYmMSdCGIDEuTvLhDKuLviNIvSLyYWZ/vc9237PaP9JXO9kJwGVuQ VWkmyo75EgKF+eM4vKZGIwh+Rnc0tyZWpD/XtHL7rvPscrO/rtKSaKivb5Z5JWmgzTIC Gqd5I1pA7C3NoeF0yjw0y+uLvMi2ubpa9i3xnR5aHUFJV0gCXqX0mtdt8lKWPcsNmdTP o+Tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si1672908ejf.406.2021.03.31.06.16.25; Wed, 31 Mar 2021 06:16:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235630AbhCaNNK (ORCPT + 99 others); Wed, 31 Mar 2021 09:13:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:41318 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235219AbhCaNMj (ORCPT ); Wed, 31 Mar 2021 09:12:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D6E6BB250; Wed, 31 Mar 2021 13:12:38 +0000 (UTC) From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Hannes Reinecke , Chao Leng , Daniel Wagner , Victor Gladkov Subject: [PATCH] nvme: Export fast_io_fail_tmo to sysfs Date: Wed, 31 Mar 2021 15:12:28 +0200 Message-Id: <20210331131228.131118-1-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 8c4dfea97f15 ("nvme-fabrics: reject I/O to offline device") introduced fast_io_fail_tmo but didn't export the value to sysfs. That means the value is hard coded during compile time. Export the timeout value to user space via sysfs to allow runtime configuration. Cc: Victor Gladkov Signed-off-by: Daniel Wagner --- This patch is against nvme-5.13 BTW, checkpatch complains with WARNING: Symbolic permissions 'S_IRUGO | S_IWUSR' are not preferred. Consider using octal permissions '0644'. Is this something we want to adapt to? drivers/nvme/host/core.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 40215a0246e4..c8de0e37c7d9 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3696,6 +3696,36 @@ static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev, static DEVICE_ATTR(reconnect_delay, S_IRUGO | S_IWUSR, nvme_ctrl_reconnect_delay_show, nvme_ctrl_reconnect_delay_store); +static ssize_t nvme_ctrl_fast_io_fail_tmo_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); + + if (ctrl->opts->fast_io_fail_tmo == -1) + return sprintf(buf, "off\n"); + return sprintf(buf, "%d\n", ctrl->opts->fast_io_fail_tmo); +} + +static ssize_t nvme_ctrl_fast_io_fail_tmo_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); + struct nvmf_ctrl_options *opts = ctrl->opts; + int fast_io_fail_tmo, err; + + err = kstrtoint(buf, 10, &fast_io_fail_tmo); + if (err) + return -EINVAL; + + else if (fast_io_fail_tmo < 0) + opts->fast_io_fail_tmo = -1; + else + opts->fast_io_fail_tmo = fast_io_fail_tmo; + return count; +} +static DEVICE_ATTR(fast_io_fail_tmo, S_IRUGO | S_IWUSR, + nvme_ctrl_fast_io_fail_tmo_show, nvme_ctrl_fast_io_fail_tmo_store); + static struct attribute *nvme_dev_attrs[] = { &dev_attr_reset_controller.attr, &dev_attr_rescan_controller.attr, @@ -3715,6 +3745,7 @@ static struct attribute *nvme_dev_attrs[] = { &dev_attr_hostid.attr, &dev_attr_ctrl_loss_tmo.attr, &dev_attr_reconnect_delay.attr, + &dev_attr_fast_io_fail_tmo.attr, NULL }; -- 2.29.2