Skip to content

types: Change LM CDQ sz argument from u8 to u32.#1006

Merged
igaw merged 1 commit intolinux-nvme:masterfrom
DanceDance:nvme-lm-cdq-args-sz-fix
May 8, 2025
Merged

types: Change LM CDQ sz argument from u8 to u32.#1006
igaw merged 1 commit intolinux-nvme:masterfrom
DanceDance:nvme-lm-cdq-args-sz-fix

Conversation

@DanceDance
Copy link
Copy Markdown
Contributor

According to NVMe 2.1 Base Specificaiton, Controller Data Queue Size (CDQSIZE) occupies bits 31:00 of CDW12, so it should be using u32.

Screenshot 2025-05-02 at 15 31 01

Note that in other places, like nvme-cli, the correct u32 is used:

@igaw
Copy link
Copy Markdown
Collaborator

igaw commented May 7, 2025

The problem is that this is a stable API, which means all changes should be made with backward compatibility in mind. This change will break existing users which will update libnvme but not nvme-cli.

The current way to handle this is to add padding (the new struct size needs to be multiple of the largest member, due to alignment constraints) and than add a new membber. In the function the arg type size is then check and the different versions used, e.g. 5ac91b7 ("types: Add ns-mgmt host software specified fields").

@DanceDance DanceDance force-pushed the nvme-lm-cdq-args-sz-fix branch 3 times, most recently from 5be1982 to d4b3835 Compare May 8, 2025 02:28
@DanceDance
Copy link
Copy Markdown
Contributor Author

Thanks, @igaw, for the explanation. Please take a look at the latest change. I did some manual testing as well, but with this approach we would need another change to nvme_cli to use the newly created sz_u32 as well.

Comment thread src/nvme/api-types.h Outdated
@@ -989,6 +991,8 @@ struct nvme_lm_cdq_args {
__u16 cdqid;
__u8 sel;
__u8 sz;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The good news is that we don't promise source code backwards compatibility. That means you could rename this one and name the new member sz. Then we don't have to modify nvme-cli, only recompile it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point! I've updated the patch. I did test locally without modifying nvme_cli and it worked too.

@DanceDance DanceDance force-pushed the nvme-lm-cdq-args-sz-fix branch from d4b3835 to c267988 Compare May 8, 2025 08:38
To maintain backwards compatibility, the old sz renamed to sz_u8.

According to NVMe 2.1 Base Specificaiton, Controller Data Queue Size
(CDQSIZE) occupies bits 31:00 of CDW12, so it should be using u32.

Signed-off-by: Dmitry Sherstoboev <[email protected]>
@igaw igaw force-pushed the nvme-lm-cdq-args-sz-fix branch from c267988 to e1b1026 Compare May 8, 2025 14:19
@igaw
Copy link
Copy Markdown
Collaborator

igaw commented May 8, 2025

just renamed sz_u32 to sz.

@igaw igaw merged commit 48ce0ca into linux-nvme:master May 8, 2025
12 checks passed
@igaw
Copy link
Copy Markdown
Collaborator

igaw commented May 8, 2025

Thanks!

@DanceDance DanceDance deleted the nvme-lm-cdq-args-sz-fix branch May 9, 2025 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants