All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nvme-user: Minor enhancement and fixes
@ 2014-11-28 13:50 Swati C
  2014-12-01 15:45 ` Keith Busch
  0 siblings, 1 reply; 8+ messages in thread
From: Swati C @ 2014-11-28 13:50 UTC (permalink / raw)


Addressing comments from -
[PATCH] nvme-user: Minor enhancement and fixes
(http://lists.infradead.org/pipermail/linux-nvme/2014-November/001214.html)

Minor enhancements to nvme_format_ns.c
	- Make Metadata Settings a user settable value.
	- Support for Secure Erase Settings.

Signed-off-by: Swati C <s.chawdhary at samsung.com>
---
 nvme_format_ns.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 73 insertions(+), 7 deletions(-)

diff --git a/nvme_format_ns.c b/nvme_format_ns.c
index 4d81ce4..232bb36 100644
--- a/nvme_format_ns.c
+++ b/nvme_format_ns.c
@@ -14,11 +14,12 @@ int main(int argc, char **argv)
 {
 	static const char *perrstr;
 	struct nvme_admin_cmd cmd;
-	int err, fd, nsid, fmt, i;
+	int err, fd, nsid, fmt, i, ms, ses;
+	struct nvme_id_ctrl ctrl;
 	struct nvme_id_ns ns;
 
 	if (argc < 2) {
-		fprintf(stderr, "Usage: %s <device> [<lbaf>]\n",
+		fprintf(stderr, "Usage: %s <device> [<lbaf>] [<ms>] [<ses>]\n",
 			argv[0]);
 		return 1;
 	}
@@ -28,6 +29,11 @@ int main(int argc, char **argv)
 	if (fd < 0)
 		goto perror;
 
+	perrstr = "Identifying controller";
+	err = identify(fd, 0, &ctrl, 1);
+	if (err < 0)
+		goto perror;
+
 	perrstr = "Getting namespace ID";
 	nsid = ioctl(fd, NVME_IOCTL_ID);
 	if (nsid < 0 )
@@ -38,7 +44,17 @@ int main(int argc, char **argv)
 	if (err < 0)
 		goto perror;
 
-	if (argc == 2) {
+	if (argc == 5) {
+		fmt = atoi(argv[2]);
+		ms = atoi(argv[3]);
+		ses = atoi(argv[4]);
+	} else if (argc == 4) {
+		fmt = atoi(argv[2]);
+		ms = atoi(argv[3]);
+	} else if (argc == 3) {
+		fmt = atoi(argv[2]);
+	} else {
+		/* User Input for LBAF */
 		printf("LBA formats:\n");
 		for (i = 0; i <= ns.nlbaf; i++) {
 			printf("lbaf %2d : ms:%-2d ds:%-2d rp:%#x %s\n", i,
@@ -51,20 +67,71 @@ int main(int argc, char **argv)
 			printf("Invalid input for format\n");
 			return -1;
 		}
-	} else if (argc == 3) {
-		fmt = atoi(argv[2]);
 	}
+	
 	if (fmt < 0 || fmt > ns.nlbaf) {
 		printf("Invalid format:%d\n", fmt);
 		return -1;
 	}
-	printf("Entered %d, formatting namespace\n", fmt);
+
+        if (argc < 4) {
+                /* User Input for Metadata Settings */
+                printf("\nMetadata Settings(ms):\n");
+                printf("Separate buffer		0 :\n");
+                printf("Extended data LBA	1 :\n");
+                printf("Enter ms: ");
+
+                if (scanf("%d", &ms) != 1) {
+                        printf("Invalid input for metadata settings\n");
+                        return -1;
+                }
+        }
+	
+	if (ms < 0 || ms > 1) {
+		printf("Invalid ms:%d\n", ms);
+		return -1;
+	}
+		
+	if (argc < 5) {
+		/* User Input for Secure Erase Settings */
+		printf("\nSecure Erase Settings(ses):\n");
+		printf("No Secure Erase		 0 :\n");
+		printf("User Data Erase		 1 :\n");
+		printf("Cryptographic Erase	 2 :\n");
+		printf("Enter ses: ");
+
+		if (scanf("%d", &ses) != 1) {
+			printf("Invalid input for secure erase settings\n");
+			return -1;
+		}
+	}
+	
+	if (ses < 0 || ses > 2) {
+		printf("Invalid ses:%d\n", ses);
+		return -1;
+	}
+	
+	if (ses == 2) {
+		/* Check if cryptographic erase is supported or not */
+		if (!(ctrl.fna & (1 << 2))) {
+			printf("Cryptographic Erase not supported\n");
+			return -1;
+		}
+	}
+	
+	printf("\nEntered format index %d, ms %d, ses %d, formatting namespace\n", fmt, ms, ses);
 
 	memset(&cmd, 0, sizeof(cmd));
 	cmd.opcode = nvme_admin_format_nvm;
 	cmd.nsid = nsid;
 	cmd.cdw10 = fmt;
 
+	/* Metadata Settings */
+	cmd.cdw10 |= (ms << 4);
+
+	/* Secure Erase Settings */
+	cmd.cdw10 |= (ses << 9);
+
 	perrstr = "Format NVM";
 	err = ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd);
 	if (err < 0)
@@ -78,4 +145,3 @@ int main(int argc, char **argv)
 	perror(perrstr);
 	return 1;
 }
-
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2] nvme-user: Minor enhancement and fixes
  2014-11-28 13:50 [PATCH v2] nvme-user: Minor enhancement and fixes Swati C
@ 2014-12-01 15:45 ` Keith Busch
  2014-12-02 19:10   ` Linda Knippers
  2014-12-05 16:40   ` Zakaria Abushima (zabushima)
  0 siblings, 2 replies; 8+ messages in thread
From: Keith Busch @ 2014-12-01 15:45 UTC (permalink / raw)


On Fri, 28 Nov 2014, Swati C wrote:
> Addressing comments from -
> [PATCH] nvme-user: Minor enhancement and fixes
> (http://lists.infradead.org/pipermail/linux-nvme/2014-November/001214.html)
>
> Minor enhancements to nvme_format_ns.c
> 	- Make Metadata Settings a user settable value.
> 	- Support for Secure Erase Settings.
>
> Signed-off-by: Swati C <s.chawdhary at samsung.com>

Thanks, applied.

On a side note, some people asked if I could take the example programs
here and turn it into something more useful with just one program to
run all nvme instead of a bunch of stand-alone programs. I took a stab
at it:

http://git.infradead.org/users/kbusch/linux-nvme-cli.git

It's still a work in progress, but just linking here in case others
have ideas or find it useful too.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] nvme-user: Minor enhancement and fixes
  2014-12-01 15:45 ` Keith Busch
@ 2014-12-02 19:10   ` Linda Knippers
  2014-12-02 19:32     ` Keith Busch
  2014-12-05 16:40   ` Zakaria Abushima (zabushima)
  1 sibling, 1 reply; 8+ messages in thread
From: Linda Knippers @ 2014-12-02 19:10 UTC (permalink / raw)


On 12/01/2014 10:45 AM, Keith Busch wrote:
> On Fri, 28 Nov 2014, Swati C wrote:
>> Addressing comments from -
>> [PATCH] nvme-user: Minor enhancement and fixes
>> (http://lists.infradead.org/pipermail/linux-nvme/2014-November/001214.html)
>>
>>
>> Minor enhancements to nvme_format_ns.c
>>     - Make Metadata Settings a user settable value.
>>     - Support for Secure Erase Settings.
>>
>> Signed-off-by: Swati C <s.chawdhary at samsung.com>
> 
> Thanks, applied.
> 
> On a side note, some people asked if I could take the example programs
> here and turn it into something more useful with just one program to
> run all nvme instead of a bunch of stand-alone programs. I took a stab
> at it:
> 
> http://git.infradead.org/users/kbusch/linux-nvme-cli.git
> 
> It's still a work in progress, but just linking here in case others
> have ideas or find it useful too.

Thanks, I think something like this will be very helpful.

I noticed that FreeBSD already has an nvmecontrol command.
https://www.freebsd.org/cgi/man.cgi?query=nvmecontrol&sektion=8&apropos=0&manpath=FreeBSD+10.1-RELEASE

I haven't tried it or looked to see what the functional differences
are between nvmecontrol and your nvme, if any.  Have you?

Thanks,

-- ljk

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] nvme-user: Minor enhancement and fixes
  2014-12-02 19:10   ` Linda Knippers
@ 2014-12-02 19:32     ` Keith Busch
  0 siblings, 0 replies; 8+ messages in thread
From: Keith Busch @ 2014-12-02 19:32 UTC (permalink / raw)


On Tue, 2 Dec 2014, Linda Knippers wrote:
> On 12/01/2014 10:45 AM, Keith Busch wrote:
>> On Fri, 28 Nov 2014, Swati C wrote:
>>> Addressing comments from -
>>> [PATCH] nvme-user: Minor enhancement and fixes
>>> (http://lists.infradead.org/pipermail/linux-nvme/2014-November/001214.html)
>>>
>>>
>>> Minor enhancements to nvme_format_ns.c
>>>     - Make Metadata Settings a user settable value.
>>>     - Support for Secure Erase Settings.
>>>
>>> Signed-off-by: Swati C <s.chawdhary at samsung.com>
>>
>> Thanks, applied.
>>
>> On a side note, some people asked if I could take the example programs
>> here and turn it into something more useful with just one program to
>> run all nvme instead of a bunch of stand-alone programs. I took a stab
>> at it:
>>
>> http://git.infradead.org/users/kbusch/linux-nvme-cli.git
>>
>> It's still a work in progress, but just linking here in case others
>> have ideas or find it useful too.
>
> Thanks, I think something like this will be very helpful.
>
> I noticed that FreeBSD already has an nvmecontrol command.
> https://www.freebsd.org/cgi/man.cgi?query=nvmecontrol&sektion=8&apropos=0&manpath=FreeBSD+10.1-RELEASE
>
> I haven't tried it or looked to see what the functional differences
> are between nvmecontrol and your nvme, if any.  Have you?

Thanks for the link! I had no idea that existed, though it looks like mine
implements more of the command set. I'll ask Jim if he's still working
on that. I'd like to see more unified NVMe tooling, so collaboration
is better.

> Thanks,
>
> -- ljk

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] nvme-user: Minor enhancement and fixes
  2014-12-01 15:45 ` Keith Busch
  2014-12-02 19:10   ` Linda Knippers
@ 2014-12-05 16:40   ` Zakaria Abushima (zabushima)
  2014-12-05 16:48     ` James R. Bergsten
  2014-12-05 16:58     ` Keith Busch
  1 sibling, 2 replies; 8+ messages in thread
From: Zakaria Abushima (zabushima) @ 2014-12-05 16:40 UTC (permalink / raw)


Hi Keith and Swati,

I have used my vendor specific tool to create namespace and managed to create it,

It doesn't appear in GUI as a file system where I can save things in but in /dev/ it lists nvme0 and nvme0n1

So I thought I might need to format it ? then I have used your tool nvme-format-ns and formatted the namespace ?

Nothing success and says icotl interrupted.

and then I thought that I might need to mount it ? I used linux built-in mount function as following:- mount /dev/nvme0n1

Since then the nvme0 and nvme0n1 disappeared and when I call lspci -v I noticed slight change, which is the " module driver in use nvme0" line has disappeared ? when it use to appear ? 

Any idear or help

Thanks a in advance.

Zakaria.

-----Original Message-----
From: Linux-nvme [mailto:linux-nvme-bounces@lists.infradead.org] On Behalf Of Keith Busch
Sent: 01 December 2014 15:46
To: Swati C
Cc: linux-nvme at lists.infradead.org
Subject: Re: [PATCH v2] nvme-user: Minor enhancement and fixes

On Fri, 28 Nov 2014, Swati C wrote:
> Addressing comments from -
> [PATCH] nvme-user: Minor enhancement and fixes
> (http://lists.infradead.org/pipermail/linux-nvme/2014-November/001214.
> html)
>
> Minor enhancements to nvme_format_ns.c
> 	- Make Metadata Settings a user settable value.
> 	- Support for Secure Erase Settings.
>
> Signed-off-by: Swati C <s.chawdhary at samsung.com>

Thanks, applied.

On a side note, some people asked if I could take the example programs here and turn it into something more useful with just one program to run all nvme instead of a bunch of stand-alone programs. I took a stab at it:

http://git.infradead.org/users/kbusch/linux-nvme-cli.git

It's still a work in progress, but just linking here in case others have ideas or find it useful too.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] nvme-user: Minor enhancement and fixes
  2014-12-05 16:40   ` Zakaria Abushima (zabushima)
@ 2014-12-05 16:48     ` James R. Bergsten
  2014-12-05 16:58     ` Keith Busch
  1 sibling, 0 replies; 8+ messages in thread
From: James R. Bergsten @ 2014-12-05 16:48 UTC (permalink / raw)


Were it me, I'd start over.  Power cycle, use the VS tool, then use whatever
Linux-dist-standard GUI thingy you have to do a FILESYSTEM format and then a
mount on /dev/nvme0n1.  That ought to work.

Good luck.
Jim B.

-----Original Message-----
From: Linux-nvme [mailto:linux-nvme-bounces@lists.infradead.org] On Behalf
Of Zakaria Abushima (zabushima)
Sent: Friday, December 5, 2014 8:41 AM
To: Keith Busch; Swati C
Cc: linux-nvme at lists.infradead.org
Subject: RE: [PATCH v2] nvme-user: Minor enhancement and fixes

Hi Keith and Swati,

I have used my vendor specific tool to create namespace and managed to
create it,

It doesn't appear in GUI as a file system where I can save things in but in
/dev/ it lists nvme0 and nvme0n1

So I thought I might need to format it ? then I have used your tool
nvme-format-ns and formatted the namespace ?

Nothing success and says icotl interrupted.

and then I thought that I might need to mount it ? I used linux built-in
mount function as following:- mount /dev/nvme0n1

Since then the nvme0 and nvme0n1 disappeared and when I call lspci -v I
noticed slight change, which is the " module driver in use nvme0" line has
disappeared ? when it use to appear ? 

Any idear or help

Thanks a in advance.

Zakaria.

-----Original Message-----
From: Linux-nvme [mailto:linux-nvme-bounces@lists.infradead.org] On Behalf
Of Keith Busch
Sent: 01 December 2014 15:46
To: Swati C
Cc: linux-nvme at lists.infradead.org
Subject: Re: [PATCH v2] nvme-user: Minor enhancement and fixes

On Fri, 28 Nov 2014, Swati C wrote:
> Addressing comments from -
> [PATCH] nvme-user: Minor enhancement and fixes 
> (http://lists.infradead.org/pipermail/linux-nvme/2014-November/001214.
> html)
>
> Minor enhancements to nvme_format_ns.c
> 	- Make Metadata Settings a user settable value.
> 	- Support for Secure Erase Settings.
>
> Signed-off-by: Swati C <s.chawdhary at samsung.com>

Thanks, applied.

On a side note, some people asked if I could take the example programs here
and turn it into something more useful with just one program to run all nvme
instead of a bunch of stand-alone programs. I took a stab at it:

http://git.infradead.org/users/kbusch/linux-nvme-cli.git

It's still a work in progress, but just linking here in case others have
ideas or find it useful too.

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

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] nvme-user: Minor enhancement and fixes
  2014-12-05 16:40   ` Zakaria Abushima (zabushima)
  2014-12-05 16:48     ` James R. Bergsten
@ 2014-12-05 16:58     ` Keith Busch
  2014-12-08 14:36       ` Zakaria Abushima (zabushima)
  1 sibling, 1 reply; 8+ messages in thread
From: Keith Busch @ 2014-12-05 16:58 UTC (permalink / raw)


It appears you broke your device.

If you see /dev/nvme0n1, you can treat it like any block handle (like
/dev/sda, for example). You shouldn't have to run an nvme format unless
that's what you really want to do, but it doesn't sound necessary given
your goal, and your device became unresponsive after.

After you fix your device, you can create a filesystem:

   # mke2fs /dev/nvme0n1

Then mount:

   # mount /dev/nvme0n1 /mnt

Adjust accordingly if you want a different filesystem or mount point.

On Fri, 5 Dec 2014, Zakaria Abushima (zabushima) wrote:
> Hi Keith and Swati,
>
> I have used my vendor specific tool to create namespace and managed to create it,
>
> It doesn't appear in GUI as a file system where I can save things in but in /dev/ it lists nvme0 and nvme0n1

> So I thought I might need to format it ? then I have used your tool nvme-format-ns and formatted the namespace ?
>
> Nothing success and says icotl interrupted.
>
> and then I thought that I might need to mount it ? I used linux built-in mount function as following:- mount /dev/nvme0n1
>
> Since then the nvme0 and nvme0n1 disappeared and when I call lspci -v I noticed slight change, which is the " module driver in use nvme0" line has disappeared ? when it use to appear ?
>
> Any idear or help
>
> Thanks a in advance.
>
> Zakaria.
>
> -----Original Message-----
> From: Linux-nvme [mailto:linux-nvme-bounces at lists.infradead.org] On Behalf Of Keith Busch
> Sent: 01 December 2014 15:46
> To: Swati C
> Cc: linux-nvme at lists.infradead.org
> Subject: Re: [PATCH v2] nvme-user: Minor enhancement and fixes
>
> On Fri, 28 Nov 2014, Swati C wrote:
>> Addressing comments from -
>> [PATCH] nvme-user: Minor enhancement and fixes
>> (http://lists.infradead.org/pipermail/linux-nvme/2014-November/001214.
>> html)
>>
>> Minor enhancements to nvme_format_ns.c
>> 	- Make Metadata Settings a user settable value.
>> 	- Support for Secure Erase Settings.
>>
>> Signed-off-by: Swati C <s.chawdhary at samsung.com>
>
> Thanks, applied.
>
> On a side note, some people asked if I could take the example programs here and turn it into something more useful with just one program to run all nvme instead of a bunch of stand-alone programs. I took a stab at it:
>
> http://git.infradead.org/users/kbusch/linux-nvme-cli.git
>
> It's still a work in progress, but just linking here in case others have ideas or find it useful too.
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] nvme-user: Minor enhancement and fixes
  2014-12-05 16:58     ` Keith Busch
@ 2014-12-08 14:36       ` Zakaria Abushima (zabushima)
  0 siblings, 0 replies; 8+ messages in thread
From: Zakaria Abushima (zabushima) @ 2014-12-08 14:36 UTC (permalink / raw)


Hi Keith,

I managed it to work by doing power cycle,

Also I followed mounting instruction and it worked but wondered how can I unmount it ? to be at previous state ?

Also I wondered why when I double click on the file system it says ? Not Authorized ?

Thanks

Zakaria.

-----Original Message-----
From: Keith Busch [mailto:keith.busch@intel.com] 
Sent: 05 December 2014 16:58
To: Zakaria Abushima (zabushima)
Cc: Keith Busch; Swati C; linux-nvme at lists.infradead.org
Subject: RE: [PATCH v2] nvme-user: Minor enhancement and fixes

It appears you broke your device.

If you see /dev/nvme0n1, you can treat it like any block handle (like /dev/sda, for example). You shouldn't have to run an nvme format unless that's what you really want to do, but it doesn't sound necessary given your goal, and your device became unresponsive after.

After you fix your device, you can create a filesystem:

   # mke2fs /dev/nvme0n1

Then mount:

   # mount /dev/nvme0n1 /mnt

Adjust accordingly if you want a different filesystem or mount point.

On Fri, 5 Dec 2014, Zakaria Abushima (zabushima) wrote:
> Hi Keith and Swati,
>
> I have used my vendor specific tool to create namespace and managed to 
> create it,
>
> It doesn't appear in GUI as a file system where I can save things in 
> but in /dev/ it lists nvme0 and nvme0n1

> So I thought I might need to format it ? then I have used your tool nvme-format-ns and formatted the namespace ?
>
> Nothing success and says icotl interrupted.
>
> and then I thought that I might need to mount it ? I used linux 
> built-in mount function as following:- mount /dev/nvme0n1
>
> Since then the nvme0 and nvme0n1 disappeared and when I call lspci -v I noticed slight change, which is the " module driver in use nvme0" line has disappeared ? when it use to appear ?
>
> Any idear or help
>
> Thanks a in advance.
>
> Zakaria.
>
> -----Original Message-----
> From: Linux-nvme [mailto:linux-nvme-bounces at lists.infradead.org] On 
> Behalf Of Keith Busch
> Sent: 01 December 2014 15:46
> To: Swati C
> Cc: linux-nvme at lists.infradead.org
> Subject: Re: [PATCH v2] nvme-user: Minor enhancement and fixes
>
> On Fri, 28 Nov 2014, Swati C wrote:
>> Addressing comments from -
>> [PATCH] nvme-user: Minor enhancement and fixes 
>> (http://lists.infradead.org/pipermail/linux-nvme/2014-November/001214.
>> html)
>>
>> Minor enhancements to nvme_format_ns.c
>> 	- Make Metadata Settings a user settable value.
>> 	- Support for Secure Erase Settings.
>>
>> Signed-off-by: Swati C <s.chawdhary at samsung.com>
>
> Thanks, applied.
>
> On a side note, some people asked if I could take the example programs here and turn it into something more useful with just one program to run all nvme instead of a bunch of stand-alone programs. I took a stab at it:
>
> http://git.infradead.org/users/kbusch/linux-nvme-cli.git
>
> It's still a work in progress, but just linking here in case others have ideas or find it useful too.
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-12-08 14:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-28 13:50 [PATCH v2] nvme-user: Minor enhancement and fixes Swati C
2014-12-01 15:45 ` Keith Busch
2014-12-02 19:10   ` Linda Knippers
2014-12-02 19:32     ` Keith Busch
2014-12-05 16:40   ` Zakaria Abushima (zabushima)
2014-12-05 16:48     ` James R. Bergsten
2014-12-05 16:58     ` Keith Busch
2014-12-08 14:36       ` Zakaria Abushima (zabushima)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.