-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create-ns: align the namespaces to 1Mib boundaries when using SI suffixes #2095
Conversation
The $ nvme create-ns /dev/nvme0 -s 80Mi -c 80Mi -f 0 |
I think we should have one pair of options which take value verbatim without any modifications and one set which do IIRC, this is what we had in mind when we added the |
By the way for example is there any user to use the -S and -C options to align the values to 512 Kilobyte boundaries but not 1 Megabyte boundaries. If so in the case the options are not able to use for the case with the PR changes. |
That is true, but it's not a bit of a corner case? Is there a real need to create namespaces of < 1Mbyte size? |
Not sure if namespace granularity (CNS 16h) is being accounted for in current implementation, but if controller supports it then granularity can be accounted for when creating namespaces (with same matching indices 0-15 as for LBA formats). |
Not yet. For anyone looking for the documentation it is in |
Yup, CNS 01h will report if granularity is supported at bit 7 for "Controller Attributes (CTRATT)" |
If the granularity is not support should we keep the current command options behavir? Or the controllers needed the size aligned to a 1 megabyte boundary are supported the granularity? |
I think it makes sense to align it to 1 MB boundary in absence of the granularity information. The worst case scenario is that we waste 1MB disk space. If you look at partitioning tools, it is not uncommon that some space is unused to alignment constrains. As I said, I see these options here as the user friendly command line options to create namespaces. You should not need to know the spec at all to create a new namespace. As long we have the low level command line arguments around, there is always the possibility to configure a namespace exactly as you want it do be. |
Agreed. Thanks for your explanation. |
@maurizio-lombardi do you plan to add the Granularity discovery bit? |
I am going to look at how to do that. |
@maurizio-lombardi any updates? |
7. 12. 2023 v 14:27, Daniel Wagner ***@***.***>:
@maurizio-lombardi any updates?Hello, sorry I was busy with other things, I will come up with something as soon as possible
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
edbc0d6
to
e68e99b
Compare
I updated the patch but I didn't have the opportunity to test it yet so it may not work as intended. I plan to test it this week |
046b788
to
d5df782
Compare
I've lost the overview here. Is the patch ready to be merged (tested)? It looks it is in shape. The only small thing is that the documentation is not mentioning that it will be align on |
It is not, on one of my machines I get quite high values from the granularity list, for example 4 Gb of preferred granularity. (desc->nszegran = 4294967296 desc->ncapgran = 4294967296). I didn't expect the values to be so high and this makes some u32 variables to overflow, leading to divisions by zero and crashes. |
By the way, the specification says that the list gives us a preferred granularity, but doesn't say that we are obliged to respect it |
Uff, this is a big alignment requirement! Does this mean we stick your initial idea to align to 1 MB ? Not really sure what to do here. |
Me neither, I am tempted to align to 1 Mb unless the controller suggests that a smaller value is preferred. |
Maybe we should just do this and see if someone complains :) |
Will modify the patch and go ahead then, unless @ikegami-t disagrees |
Agreed. Thank you. |
d5df782
to
daadfd0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically looks good but only some minor comments let me mention.
nvme.c
Outdated
/* Only the first descriptor is valid */ | ||
index = 0; | ||
} else if (index > gr_list->num_descriptors) { | ||
/* The descriptor will contain only zeroes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be split the line to start multiple lines comment as belwo below.
- /* The descriptor will contain only zeroes
+ /*
+ * The descriptor will contain only zeroes
nvme.c
Outdated
return err; | ||
} | ||
|
||
align_nsze = align_ncap = 1 << 20; /* Default 1 Mb */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value can be initialized by the variable definitions as for example. By the way 1 Mb
should be 1 MiB
. (The lowercase character b
also should be uppercase charadter B
. This is also same for the commit message summary 1Mib
and description 1Mb
.)
__u32 nsid:
__u32 align_nsze = 1 << 20; /* Default 1 MiB */
__u32 align_ncap = align_nsze;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok this one, I will change it
daadfd0
to
ce4bd36
Compare
…ixes Some controllers refuse to create namespaces with a size not aligned to a 1 MiB boundary, this happens when using the -S and -C options. $ nvme create-ns /dev/nvme0 -S 80M -C 80M -f 0 NVMe status: Invalid Field in Command: A reserved coded value or an unsupported value in a defined field(0x2) Fix this problem by modifying create_ns() parse_lba_num_si() to align the values to 1 MiB boundaries. If granularity is supported, we will use the specified values, if they are smaller than 1 MiB. Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
ce4bd36
to
4285759
Compare
Thanks! |
Some controllers refuse to create namespaces with a size not aligned to a 1 megabyte boundary, this happens when using the -S and -C options.
$ nvme create-ns /dev/nvme0 -S 80M -C 80M -f 0
NVMe status: Invalid Field in Command: A reserved coded value or an unsupported value in a defined field(0x2)
Fix this problem by modifying parse_lba_num_si() to align the values to 1 Megabyte boundaries.