Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3090379rdh; Mon, 27 Nov 2023 06:22:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLQyagvmm5e+IfmuwuZlII87SmQ4fiAxI7HNOkyM/6czDEoxbG3FW3GdgShjiRvbG8gKvS X-Received: by 2002:a05:6a20:e119:b0:18c:3260:e221 with SMTP id kr25-20020a056a20e11900b0018c3260e221mr11429511pzb.62.1701094944387; Mon, 27 Nov 2023 06:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701094944; cv=none; d=google.com; s=arc-20160816; b=VdEkS9eo/PYM54vS6wl22YzWJgj01S/l+0fWIU6M5d1JRjO/e5lRIjgSrFs4LkTwvH kqrAPtgAyhBl8CxQtNxJiE06LDPdQn3zMufPQNbPEitoq0lSc5VQ9oMZdvKdXLH51uzr ovyhz+wmKrMZwxGVMyv0TZzmxLxLGNKfSQzganq1IGVTpQoz8AnQtRIKl7hWrskB5Wlv FoF3ioidXCEx8ktXI5WlVOg6ldrZR2TNGdBtBQRyYHlZEOJKHyz7cnIerKHZKzqHmK7p JOdZUk+nfNWQ2NvqOnqppOc5GTbWK+sp1aV0ssbW0fXfLVkq7gvKR6lXjdc65FPIHT4p CyjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=8DKYWg02sQhk17I8+i3J13/5ln/Edo/wZOpwVk1QeYM=; fh=JWieladFfeaIwBj69e66MtYgIw576fUcTLVAEUXiV9w=; b=cXnB8YGkQ7Y3MC/d0ghVcq8k+VPe3L9gRxJoDEFpTaqpJF9Vo8GCgA7EImm65CqqlZ 8FXMT0Ncne+JQW0x1gKEHp6eu2+n2k6NIZJ9ni/4lH+6bgJXGq1W95Z9ixCdCHI2e39h TqvW76GWWcvETBocA8QnmrMc+WW8P4ad+Wy+F/gchzOJ+KjrTzAE8t52jEhzlddgIRH6 LxIhZaGU3OASj3Lvy3tSNa259p6Xh6u/KFAhxMqdHANm2xxvnpY0/iRz7gGW6xilrt/p VDaSdgbtHGhNGxV43loEw4c9V9NDlwUxfXIlY0l91TtLFSAxJ4I+sVPY32YRSYDhrE2N pTdA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id g14-20020a056a000b8e00b006cd8454cbb4si4011074pfj.337.2023.11.27.06.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:22:24 -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; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id AE50380658DA; Mon, 27 Nov 2023 06:22:21 -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 S233762AbjK0OV7 (ORCPT + 99 others); Mon, 27 Nov 2023 09:21:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233767AbjK0OVn (ORCPT ); Mon, 27 Nov 2023 09:21:43 -0500 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA6DE3872 for ; Mon, 27 Nov 2023 06:19:04 -0800 (PST) Received: by verein.lst.de (Postfix, from userid 2407) id 5652667373; Mon, 27 Nov 2023 15:18:58 +0100 (CET) Date: Mon, 27 Nov 2023 15:18:57 +0100 From: Christoph Hellwig To: Daniel Wagner Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Keith Busch , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke Subject: Re: [RFC v1] nvme: add cse, ds, ms, nsze and nuse to sysfs Message-ID: <20231127141857.GA25833@lst.de> References: <20231127103208.25748-1-dwagner@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231127103208.25748-1-dwagner@suse.de> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-0.8 required=5.0 tests=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]); Mon, 27 Nov 2023 06:22:21 -0800 (PST) On Mon, Nov 27, 2023 at 11:32:08AM +0100, Daniel Wagner wrote: > Also getting a pointer to the nvme_ns data structure is a bit strange > (dev_to_nvme_ns). > This stip is necessary as many of the ns attributes are in > nvme_ns. Shouldn't these per path values not all be the same and thus couldn't > these be in nvme_ns_head? Anyway, just not sure who to deal with this. So any > pointers highly welcomed! Yes, they probably should be in the ns_head. > + list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) { > + down_read(&ctrl->namespaces_rwsem); > + list_for_each_entry(ns, &ctrl->namespaces, list) { > + ret = ns; > + break; > + } > + up_read(&ctrl->namespaces_rwsem); > + } > + return ret; > + } .. I also don't think this would even be safe as-is as we dont hold a reference to the ns after dropping the lock. > +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 lba_ds_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + struct nvme_ns *ns = dev_to_nvme_ns(dev); > + > + return sysfs_emit(buf, "%d\n", ns->lba_shift); lba_ds is a bit of an odd name. And I also don't think we even need this, because it really is just a weird enconding for the logical block size already exposed by the block layer. > +static ssize_t lba_ms_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + struct nvme_ns *ns = dev_to_nvme_ns(dev); > + > + return sysfs_emit(buf, "%d\n", ns->ms); > +} > +static DEVICE_ATTR_RO(lba_ms); I'd probably spell out metadata_size, or probably even better metadata_bytes to match the unit postfixes elsewhere in the block code. > + > +static ssize_t nsze_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + struct nvme_ns *ns = dev_to_nvme_ns(dev); > + > + return sysfs_emit(buf, "%llu\n", ns->nsze); > +} > +static DEVICE_ATTR_RO(nsze); This is just the normal size of the block device we already export.