Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp906035rdb; Fri, 1 Dec 2023 01:31:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYHy9s4Q8/dXi5mzMnwxzlkkN3yJ0A06i1MLbwfEk+XJ7UD3bzmoNNTebcL14FvKA176w1 X-Received: by 2002:a05:6871:4184:b0:1f9:62f5:cc44 with SMTP id lc4-20020a056871418400b001f962f5cc44mr33444147oab.1.1701423074102; Fri, 01 Dec 2023 01:31:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701423074; cv=none; d=google.com; s=arc-20160816; b=NVIAvHStCPh8W1U0B8bJr+zghm9g19/D9bgd7pWKRvwhDT5CyFS0ES9B8ijylXwAsv SbE2Ws58aic7a86MtIc4AiHTnCEkOJQSAsCv6u9/D/vFqAbRbLY0IqWvR6zpjZyHuADe DvVcot2ZxP1UXnHa7qsnzm62VdeHovyn6qrTDbxlshrUSSMq+xdUcOhYbrWqEwrJSANL 0/fqdpi6j8xZ1R7QFTx/FwXWRAbSem8nw0bHc1id7u8E+ymHTLDfXFMEym0BGNgmjplA ASu7OhwB5j35LRMakMvYLRX+f3qt5hapj3hof0pkFFXNW2OE8uemPLNtiBYJUV9yQgW4 8W5w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=sQwzdTYvrRv6kwmyIfzY+Auo3yOb/qjcABHg72uxOp8=; fh=DJbT8ne4Efjik5M2lT8AzCh46QRFyMX3tPkPd3UGLh8=; b=CE8fNCa/rFFIrSDHIPH6xe7zQupULQ83XvxgCHmLOYDQVP/IGMyTD7TtVhkD8Tecy2 Tw9vn4mKTCaiuQw6VV46wrjt8G7OXNjkspi1o8u2aWqY2a7r22lxD9WjIvTSF+mEouqM QBo0dq8UdtQ/EQUAZVygwBdM0IRFgL0ttIWWAVfk9XWFMPMTkWVPYVzto8tq6eaxsm4s Hnji2tHdluirlcwCryzoF7IoN9ggO9CdBAkd4iNj2atLQ0CtIjD6gkDhSzpXB8zJje5/ 9YUd0bN4GMPTOa52u/OFpY6j+FcJ3HO95503K0D2LYXc+GnZPj+P6hYcs+7HkfOy2l82 UFRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=h9galPa2; dkim=neutral (no key) header.i=@suse.de header.b=fdIxNGC7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id j5-20020a634a45000000b005c622a6f3cfsi3081296pgl.117.2023.12.01.01.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 01:31:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=h9galPa2; dkim=neutral (no key) header.i=@suse.de header.b=fdIxNGC7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 37A728043017; Fri, 1 Dec 2023 01:31:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378206AbjLAJaB (ORCPT + 99 others); Fri, 1 Dec 2023 04:30:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378194AbjLAJ3l (ORCPT ); Fri, 1 Dec 2023 04:29:41 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1DF82D47 for ; Fri, 1 Dec 2023 01:27:50 -0800 (PST) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6934D1FD66; Fri, 1 Dec 2023 09:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1701422868; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sQwzdTYvrRv6kwmyIfzY+Auo3yOb/qjcABHg72uxOp8=; b=h9galPa2C+0p7I+D8lvp9bH8FnGklhot5gehpiYeTyxRa2Oez7FV3aemn1mQJzkUVe0BIO /SPOg/SzRc1+X8BRpk495JNnbmX65Py4zEW+9jU1a/bdPvczh+2WIiquzPSbvzAj4J7GbA FenU/BJ17jybUhZrloeAxa8FcFxA5Jk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1701422868; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sQwzdTYvrRv6kwmyIfzY+Auo3yOb/qjcABHg72uxOp8=; b=fdIxNGC76hOGaO75uyt2pUAucI2fsflbx30GV3uhdgnok4QaVk0YkJd+ewgwmmNbH6To9L W+wWRFQuMV5HK7CQ== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 574F913928; Fri, 1 Dec 2023 09:27:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id +1yfExSnaWUbZgAAn2gu4w (envelope-from ); Fri, 01 Dec 2023 09:27:48 +0000 From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Keith Busch , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke , Daniel Wagner Subject: [RFC v2 3/3] nvme: add csi, ms and nuse to sysfs Date: Fri, 1 Dec 2023 10:27:35 +0100 Message-ID: <20231201092735.28592-4-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231201092735.28592-1-dwagner@suse.de> References: <20231201092735.28592-1-dwagner@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spamd-Result: default: False [-3.30 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: -3.30 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 01 Dec 2023 01:31:03 -0800 (PST) libnvme is using the sysfs for enumarating the nvme resources. Though there are few missing attritbutes in the sysfs. For these libnvme issues commands during discovering. As the kernel already knows all these attributes and we would like to avoid libnvme to issue commands all the time, expose these missing attributes. TODO: update nuse on request Signed-off-by: Daniel Wagner --- drivers/nvme/host/core.c | 1 + drivers/nvme/host/nvme.h | 1 + drivers/nvme/host/sysfs.c | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index bcc5fefb53a8..8aa744356468 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2057,6 +2057,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, blk_mq_freeze_queue(ns->disk->queue); lbaf = nvme_lbaf_index(id->flbas); ns->head->lba_shift = id->lbaf[lbaf].ds; + ns->head->nuse = le64_to_cpu(id->nuse); nvme_set_queue_limits(ns->ctrl, ns->queue); ret = nvme_configure_metadata(ns, id); diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 1ad2539df6fe..3a2395bf8025 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -456,6 +456,7 @@ struct nvme_ns_head { u16 pi_size; u16 sgs; u32 sws; + u64 nuse; u8 pi_type; u8 guard_type; #ifdef CONFIG_BLK_DEV_ZONED diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c index c6b7fbd4d34d..555e8842f0d4 100644 --- a/drivers/nvme/host/sysfs.c +++ b/drivers/nvme/host/sysfs.c @@ -114,12 +114,36 @@ static ssize_t nsid_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(nsid); +static ssize_t csi_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return sysfs_emit(buf, "%d\n", dev_to_ns_head(dev)->ids.csi); +} +static DEVICE_ATTR_RO(csi); + +static ssize_t metadata_bytes_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return sysfs_emit(buf, "%d\n", dev_to_ns_head(dev)->ms); +} +static DEVICE_ATTR_RO(metadata_bytes); + +static ssize_t nuse_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return sysfs_emit(buf, "%llu\n", dev_to_ns_head(dev)->nuse); +} +static DEVICE_ATTR_RO(nuse); + static struct attribute *nvme_ns_id_attrs[] = { &dev_attr_wwid.attr, &dev_attr_uuid.attr, &dev_attr_nguid.attr, &dev_attr_eui.attr, + &dev_attr_csi.attr, &dev_attr_nsid.attr, + &dev_attr_metadata_bytes.attr, + &dev_attr_nuse.attr, #ifdef CONFIG_NVME_MULTIPATH &dev_attr_ana_grpid.attr, &dev_attr_ana_state.attr, -- 2.43.0