Linux-NVME Archive on lore.kernel.org
 help / color / Atom feed
From: Mark Ruijter <MRuijter@onestopsystems.com>
To: Christoph Hellwig <hch@infradead.org>,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Cc: "hch@lst.de" <hch@lst.de>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
	"sagi@grimberg.me" <sagi@grimberg.me>
Subject: Re: [PATCH] nvmet: make ctrl model configurable
Date: Mon, 11 Nov 2019 13:31:39 +0000
Message-ID: <829AB08E-457F-4E8E-8964-DD3ADF9140BD@onestopsystems.com> (raw)
In-Reply-To: <20191111103421.GB6127@infradead.org>

[-- Attachment #1: Type: text/plain, Size: 3539 bytes --]


Hi Chaitanya & Christoph,

I changed the patch I posted this morning and added the changes suggested.

I also wrote a patch for nvmetcli and verified that nvmetcli can set and save the model description:

dev:/usr/src/nvmetcli # ./nvmetcli save /tmp/test.json
dev:/usr/src/nvmetcli # cat /sys/kernel/config/nvmet/subsystems/loop/attr_model 
mark
dev:/usr/src/nvmetcli # grep model /tmp/test.json
        "model": "mark", 

dev:/usr/src/nvmetcli # ./nvmetcli 
/subsystems/loop> ls  
o- loop ............................................................ [version=1.3, allow_any=1, serial=198f07c757eb114d, model=mark]
  o- allowed_hosts ........................................................................................................... [...]
  o- namespaces .............................................................................................................. [...]
    o- 1 ............................................ [path=/dev/loop0, uuid=d808c1db-3507-40cf-8ade-aa4b1a3b290b, grpid=1, enabled]
/subsystems/loop> set attr model=coolmodel
Parameter model is now 'coolmodel'.
/subsystems/loop> ls
o- loop ....................................................... [version=1.3, allow_any=1, serial=198f07c757eb114d, model=coolmodel]
  o- allowed_hosts ........................................................................................................... [...]
  o- namespaces .............................................................................................................. [...]
    o- 1 ............................................ [path=/dev/loop0, uuid=d808c1db-3507-40cf-8ade-aa4b1a3b290b, grpid=1, enabled]
/subsystems/loop> exit
dev:/usr/src/nvmetcli # ./nvmetcli save /tmp/testcool.jsonl 
dev:/usr/src/nvmetcli # grep model /tmp/testcool.json
        "model": "coolmodel", 
dev:/usr/src/nvmetcli #

I also verified that writing illegal characters in the model fails and that the initiator sees the model description that was set:
 echo -e "\t failit" > attr_model 
-bash: echo: write error: Invalid argument

echo this~works > attr_model

# nvme list
Node             SN                   Model                                    Namespace Usage                      Format           FW Rev  
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1     4d11eb57c7078f19     this~works                               1         104,86  MB / 104,86  MB    512   B +  0 B   5.3.5   

Thanks,

Mark Ruijter
 

Op 11-11-19 11:35 heeft Linux-nvme namens Christoph Hellwig <linux-nvme-bounces@lists.infradead.org namens hch@infradead.org> geschreven:

    > +	const char *model = ctrl->subsys->model;
    
    Can we have a little nvme_controller_mode() helper that uses
    subsystem->model if it is set, and otherwise the default?  That saves
    memory by not duplicating the default name for every subsystem.
    
    > +	kfree(subsys->model);
    > +	subsys->model = kstrndup(page, len, GFP_KERNEL);
    > +	if (!subsys->model)
    > +		ret = -ENOMEM;
    
    I don't think we should free the old model until the new one
    is allocated.
    
    Otherwise this looks good to me, but can someone also prepare a
    nvmetcli patch as well?
    
    _______________________________________________
    Linux-nvme mailing list
    Linux-nvme@lists.infradead.org
    http://lists.infradead.org/mailman/listinfo/linux-nvme
    


[-- Attachment #2: model_patch_patched2.diff --]
[-- Type: application/octet-stream, Size: 4022 bytes --]

[-- Attachment #3: nvmetcli.patch --]
[-- Type: application/octet-stream, Size: 785 bytes --]

[-- Attachment #4: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01  8:08 Chaitanya Kulkarni
2019-11-11 10:34 ` Christoph Hellwig
2019-11-11 13:31   ` Mark Ruijter [this message]
2019-11-12  7:07     ` Chaitanya Kulkarni
2019-11-12  7:06   ` Chaitanya Kulkarni
2019-11-11 11:09 ` Mark Ruijter
  -- strict thread matches above, loose matches on Subject: below --
2019-10-30 19:48 Chaitanya Kulkarni
2019-10-30 20:08 ` Mark Ruijter
2019-10-30 20:09   ` Chaitanya Kulkarni
2019-10-30 21:43   ` Chaitanya Kulkarni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=829AB08E-457F-4E8E-8964-DD3ADF9140BD@onestopsystems.com \
    --to=mruijter@onestopsystems.com \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-NVME Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nvme/0 linux-nvme/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nvme linux-nvme/ https://lore.kernel.org/linux-nvme \
		linux-nvme@lists.infradead.org
	public-inbox-index linux-nvme

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-nvme


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git