Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3444208imm; Fri, 25 May 2018 05:57:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZphITCi3qgjdeAvIo/Wv5GYhk2/pnC836/QeaJN2mdJ/EqlsY4BdhywqmYAHVYx4ED1Dn1H X-Received: by 2002:a17:902:8345:: with SMTP id z5-v6mr2443273pln.311.1527253053685; Fri, 25 May 2018 05:57:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527253053; cv=none; d=google.com; s=arc-20160816; b=cHzWhh+6Pc9kb0TkuTiHG3u+VAYuCus5TCvQF0+HVbm9FJaMA0d/dkdslsFyoCItq1 euNWYrUmkJbQYXMV8s2Ar2713a8zC0Hqv/MEORSOCztbuWlRQEma4I78R+cdzmwVZpwd Rhwtk4wfaWMU2hhpmPF8JeJgZPcFGazbxEs3mGv/YQOGM4OD8CZGCr4IXth2yY4zN7eF g5WrwW+WZby4NiFamHvNYdUBBDqDivpz3UcPHvYyWOArzhdkwp2oUUaTnPDtlgv5PqJZ Qqx84Enabyh1BdaWqXme91yMvOUNqr7WPAfEbb/MwoolB7fFGQuaMwCeUaXPTOR9ldx+ eqHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=tua4F0v+NyUbteR94dt0EAOgL+D7hBl6ddRNFJV4lOo=; b=TurEf7zI8dXQOaYTfymfSqtZkoyU7C9l3a7aHa70Bz2Gntwa70MtwBHsH/QtSFIU7i Ipz1qpMNPOOeQalF+sId8lCQFGibRGs5KeZmPyIBtPbEVfaogA4YlIrb/F41Ks27R6qq zhooO19BN0QDwid5Z0pFDQ78Gp/O8ig9l123xbK0mUJgU97nzm47EaCatYPijdO+vFQD nYtcHLgUkqLWK/FWAgc0VC5dEz/06R3lGu28LKGMpxQ1j9PmKExqRNdVvvrxLzHnXsjQ uuhcj5vkpMntCSWrh8rmZwxFCusiiBSCIDYWZE5TuB2aoZLgxfuyOJr8xVVVOEAZKJAS vcdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o62-v6si18989334pga.94.2018.05.25.05.57.18; Fri, 25 May 2018 05:57:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936093AbeEYMyc (ORCPT + 99 others); Fri, 25 May 2018 08:54:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:40258 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752880AbeEYMxi (ORCPT ); Fri, 25 May 2018 08:53:38 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E3A00AE91; Fri, 25 May 2018 12:53:36 +0000 (UTC) From: Johannes Thumshirn To: Christoph Hellwig , Keith Busch , Sagi Grimberg Cc: Hannes Reinecke , Mike Snitzer , Laurence Oberman , Ewan Milne , James Smart , Linux Kernel Mailinglist , Linux NVMe Mailinglist , "Martin K . Petersen" , Martin George , John Meneghini Subject: [PATCH 3/3] nvme multipath: add dev_attr_mpath_personality Date: Fri, 25 May 2018 14:53:22 +0200 Message-Id: <20180525125322.15398-4-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180525125322.15398-1-jthumshirn@suse.de> References: <20180525125322.15398-1-jthumshirn@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Snitzer Allows the ability to consistently access 'mpath_personality' regardless of which mode we're in (native vs other), using: /sys/block/nvmeXn1/device/mpath_personality Signed-off-by: Mike Snitzer --- drivers/nvme/host/core.c | 57 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 7105980dde3f..e953712086ee 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2119,12 +2119,9 @@ nvme_subsys_show_str_function(serial); nvme_subsys_show_str_function(firmware_rev); #ifdef CONFIG_NVME_MULTIPATH -static ssize_t nvme_subsys_show_mpath_personality(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t __nvme_subsys_show_mpath_personality(struct nvme_subsystem *subsys, + char *buf) { - struct nvme_subsystem *subsys = - container_of(dev, struct nvme_subsystem, dev); ssize_t ret; if (subsys->native_mpath) @@ -2135,12 +2132,9 @@ static ssize_t nvme_subsys_show_mpath_personality(struct device *dev, return ret; } -static ssize_t nvme_subsys_store_mpath_personality(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t __nvme_subsys_store_mpath_personality(struct nvme_subsystem *subsys, + const char *buf, size_t count) { - struct nvme_subsystem *subsys = - container_of(dev, struct nvme_subsystem, dev); bool native_mpath = false; int ret = 0; @@ -2162,6 +2156,24 @@ static ssize_t nvme_subsys_store_mpath_personality(struct device *dev, out: return ret ? ret : count; } + +static ssize_t nvme_subsys_show_mpath_personality(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct nvme_subsystem *subsys = + container_of(dev, struct nvme_subsystem, dev); + return __nvme_subsys_show_mpath_personality(subsys, buf); +} + +static ssize_t nvme_subsys_store_mpath_personality(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct nvme_subsystem *subsys = + container_of(dev, struct nvme_subsystem, dev); + return __nvme_subsys_store_mpath_personality(subsys, buf, count); +} static SUBSYS_ATTR_RW(mpath_personality, nvme_subsys_show_mpath_personality, nvme_subsys_store_mpath_personality); #endif @@ -2819,6 +2831,28 @@ static ssize_t nvme_sysfs_show_address(struct device *dev, } static DEVICE_ATTR(address, S_IRUGO, nvme_sysfs_show_address, NULL); +#ifdef CONFIG_NVME_MULTIPATH +static ssize_t nvme_sysfs_show_mpath_personality(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); + + return __nvme_subsys_show_mpath_personality(ctrl->subsys, buf); +} + +static ssize_t nvme_sysfs_store_mpath_personality(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); + + return __nvme_subsys_store_mpath_personality(ctrl->subsys, buf, count); +} +static DEVICE_ATTR(mpath_personality, 0644, + nvme_sysfs_show_mpath_personality, nvme_sysfs_store_mpath_personality); +#endif + static struct attribute *nvme_dev_attrs[] = { &dev_attr_reset_controller.attr, &dev_attr_rescan_controller.attr, @@ -2831,6 +2865,9 @@ static struct attribute *nvme_dev_attrs[] = { &dev_attr_subsysnqn.attr, &dev_attr_address.attr, &dev_attr_state.attr, +#ifdef CONFIG_NVME_MULTIPATH + &dev_attr_mpath_personality.attr, +#endif NULL }; -- 2.16.3