Skip to content
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

nbft: added NBFT table support #572

Merged
merged 1 commit into from
Apr 12, 2023

Conversation

johnmeneghini
Copy link

@johnmeneghini johnmeneghini commented Feb 2, 2023

Added support for parsing and printing the contents of the NBFT table (per NVMe-oF boot specification v1.0).

Signed-off-by: Stuart Hayes stuart_hayes@dell.com
Signed-off-by: Martin Belanger martin.belanger@dell.com
Signed-off-by: Martin Wilck mwilck@suse.com
Signed-off-by: Tomas Bzatek tbzatek@redhat.com
Signed-off-by: John Meneghini jmeneghi@redhat.com

@johnmeneghini johnmeneghini marked this pull request as draft February 2, 2023 22:14
@johnmeneghini johnmeneghini marked this pull request as ready for review February 2, 2023 22:17
Copy link
Contributor

@tbzatek tbzatek left a comment

Choose a reason for hiding this comment

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

Mostly forwarding my previous remarks from the private repo.

src/nvme/nbft.h Outdated Show resolved Hide resolved
src/nvme/nbft.h Outdated Show resolved Hide resolved
src/nvme/nbft.h Outdated Show resolved Hide resolved
src/libnvme.map Outdated Show resolved Hide resolved
src/nvme/nbft.h Outdated Show resolved Hide resolved
src/nvme/nbft.h Outdated Show resolved Hide resolved
Copy link
Collaborator

@igaw igaw left a comment

Choose a reason for hiding this comment

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

I think we should have a unit test for the parser. My idea would be to grab a memory dump and use it to verify that the parser works.

nbft_read could accept a descriptor instead of a filename and we could run this code with valgrind without having to setup any hardware.

Furthermore, if we modify stuff it could be easily verified nothing breaks.

src/nvme/nbft.h Outdated Show resolved Hide resolved
src/nvme/nbft.h Show resolved Hide resolved
src/nvme/nbft.h Outdated Show resolved Hide resolved
src/nvme/nbft.c Outdated Show resolved Hide resolved
src/nvme/nbft.c Outdated Show resolved Hide resolved
src/nvme/nbft.c Outdated Show resolved Hide resolved
src/nvme/nbft.c Outdated Show resolved Hide resolved
src/nvme/nbft.c Outdated Show resolved Hide resolved
src/nvme/nbft.c Outdated Show resolved Hide resolved
src/nvme/nbft.c Outdated Show resolved Hide resolved
@igaw
Copy link
Collaborator

igaw commented Feb 3, 2023

The checkpatch.pl script the Linux tree helps to spot a lot of the style issues.

src/nvme/nbft.c Outdated Show resolved Hide resolved
@tbzatek
Copy link
Contributor

tbzatek commented Feb 27, 2023

Alright, I'm going to slowly start addressing the points raised above to get things moving. As this will change the API, I'll be posting fixes to linux-nvme/nvme-cli#1791 accordingly.

@tbzatek

This comment was marked as resolved.

@tbzatek
Copy link
Contributor

tbzatek commented Mar 9, 2023

I'm posting my fixes to side branches as the official timberland one is used as a source for PoC and I still need to properly test my changes. I do plan to add some tests as well. There's still some work to do, for now the code lives at:
https://github.com/timberland-sig/libnvme/tree/timberlandmaster_final_v13-fixes
https://github.com/timberland-sig/nvme-cli/tree/timberlandmaster_final_v23-fixes

@tbzatek
Copy link
Contributor

tbzatek commented Mar 27, 2023

Thanks @johnmeneghini for merging this. One more fix in timberland-sig#6 to be tested & merged plus this branch needs to be rebased against upstream libnvme master.

@johnmeneghini
Copy link
Author

Next steps for this pull request:

  1. rebase this pull request to master
  2. rebase Added NBFT table support nvme-cli#1791 to master
  3. retest everything with NVMeoF / TCP boot support dracutdevs/dracut#2184

Following this I propose we mere this into libnvme. and continue to work on linux-nvme/nvme-cli#1791.

@igaw
Copy link
Collaborator

igaw commented Mar 28, 2023

@johnmeneghini thanks for the progress report. So I'll wait for the rebase of this PR. BTW, are you also squashing the commits too? I don't think we need to see the development history in upstream.

@johnmeneghini
Copy link
Author

@johnmeneghini thanks for the progress report. So I'll wait for the rebase of this PR. BTW, are you also squashing the commits too? I don't think we need to see the development history in upstream.

OK. Will do. I will squash and rebase now.

src/nvme/nbft.c Outdated Show resolved Hide resolved
@johnmeneghini

This comment was marked as outdated.

@mwilck
Copy link
Contributor

mwilck commented Mar 29, 2023

I am no longer able to boot my QEMU host with NVMe/TCP using these bits.

Hm, that's weird. My first thought was that you'd included Stuart's changes for the command line API, but apparently you didn't.

Have you tried just running nvme show-nbft on a system booted with the previous releases? If show-nbft still works, we probably have an issue with connect-nbft now?

@tbzatek
Copy link
Contributor

tbzatek commented Mar 29, 2023

I've tested the rebased branches and nvme show-nbft seems to be working fine, haven't noticed any difference in the output from the state of a week ago.

@johnmeneghini
Copy link
Author

johnmeneghini commented Mar 29, 2023 via email

@mwilck
Copy link
Contributor

mwilck commented Mar 29, 2023

I'm looking for help to fix the problem.

I'd love to help but I fear I won't have time for it today.

@tbzatek
Copy link
Contributor

tbzatek commented Mar 29, 2023

Another tiny change in PR timberland-sig#7 should fix the github actions checks.

@johnmeneghini
Copy link
Author

I have redone my work and retested. All tests are passing my nvme/tcp boot test on the rh-linux-poc and this branch is ready for final review. Once the final few issues are resolved, I think this branch can be merged.

@tbzatek
Copy link
Contributor

tbzatek commented Apr 3, 2023

I have redone my work and retested. All tests are passing my nvme/tcp boot test on the rh-linux-poc and this branch is ready for final review. Once the final few issues are resolved, I think this branch can be merged.

The patch from timberland-sig#7 doesn't seem to be included in your last rebase. The rest of the code looks okay.

src/nvme/nbft.c Outdated Show resolved Hide resolved
@johnmeneghini johnmeneghini requested a review from igaw April 4, 2023 16:37
Copy link
Collaborator

@igaw igaw left a comment

Choose a reason for hiding this comment

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

Sorry for the review delay. Was busy playing fire fighter.

doc/meson.build Outdated Show resolved Hide resolved
src/libnvme.map Outdated Show resolved Hide resolved
src/nvme/fabrics.h Outdated Show resolved Hide resolved
src/nvme/nbft.c Outdated Show resolved Hide resolved
src/nvme/nbft.c Outdated Show resolved Hide resolved
src/meson.build Outdated Show resolved Hide resolved
src/nvme/nbft.c Outdated Show resolved Hide resolved
src/nvme/nbft.c Show resolved Hide resolved
#define verify(condition, message) \
do { \
if (!(condition)) { \
nvme_msg(NULL, LOG_DEBUG, "file %s: " message "\n", \
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not really happy with printing on stdout in the library. In this case it's just for debugging. The fabrics parts of the library we avoided this problem by attaching a logging fd to the nvme_root_t object. Obviously, here it's a bit difficult as there is no context we could use to pass in a fd.

Copy link
Author

Choose a reason for hiding this comment

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

I agree. But it will take some work to get rid of this one. Even if I fix this here, there are many more places where nvme_msg is called. Maybe we can open an issue for this and move forward.

Functions calling this function: nvme_msg

  File   Function          Line
0 nbft.c verify             84 nvme_msg(NULL, LOG_DEBUG, "file %s: " message "\n", \
1 nbft.c __get_heap_obj     99 nvme_msg(NULL, LOG_DEBUG,
2 nbft.c __get_heap_obj    110 nvme_msg(NULL, LOG_DEBUG,
3 nbft.c __get_heap_obj    117 nvme_msg(NULL, LOG_DEBUG,
4 nbft.c read_ssns         231 nvme_msg(NULL, LOG_DEBUG,
5 nbft.c read_ssns         264 nvme_msg(NULL, LOG_DEBUG,
6 nbft.c read_ssns         282 nvme_msg(NULL, LOG_DEBUG,
7 nbft.c read_ssns         291 nvme_msg(NULL, LOG_DEBUG,
8 nbft.c read_hfi_info_tcp 335 nvme_msg(NULL, LOG_DEBUG,
9 nbft.c read_hfi          412 nvme_msg(NULL, LOG_DEBUG,
a nbft.c read_discovery    454 nvme_msg(NULL, LOG_DEBUG,
b nbft.c read_discovery    460 nvme_msg(NULL, LOG_DEBUG,
c nbft.c nvme_nbft_read    695 nvme_msg(NULL, LOG_ERR, "Failed to open %s: %s\n",
d nbft.c nvme_nbft_read    703 nvme_msg(NULL, LOG_ERR, "Failed to read from %s: %s\n",
e nbft.c nvme_nbft_read    715 nvme_msg(NULL, LOG_ERR, "Failed to allocate memory for NBFT table");
f nbft.c nvme_nbft_read    723 nvme_msg(NULL, LOG_ERR, "Failed to read from %s: %s\n",
g nbft.c nvme_nbft_read    737 nvme_msg(NULL, LOG_ERR, "Could not allocate memory for NBFT\n");
h nbft.c nvme_nbft_read    748 nvme_msg(NULL, LOG_ERR, "Failed to parse %s\n", filename);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, let's move forward and address this later.

src/nvme/nbft.c Show resolved Hide resolved
@johnmeneghini
Copy link
Author

johnmeneghini commented Apr 5, 2023 via email

@johnmeneghini johnmeneghini force-pushed the timberlandmaster_final_v13 branch 2 times, most recently from 8411348 to dd89897 Compare April 6, 2023 20:10
Added support for parsing and printing the contents
of the NBFT table (per NVMe-oF boot specification v1.0).

Signed-off-by: Stuart Hayes <stuart_hayes@dell.com>
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
Signed-off-by: John Meneghini <jmeneghi@redhat.com>
@johnmeneghini
Copy link
Author

I have squashed everything and re based onto v1.4.

@johnmeneghini johnmeneghini requested a review from igaw April 7, 2023 07:37
@igaw igaw merged commit 28ad0e9 into linux-nvme:master Apr 12, 2023
@igaw
Copy link
Collaborator

igaw commented Apr 12, 2023

Thanks everyone! Now, let's see what we have for nvme-cli :)

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.

None yet

6 participants