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

Question modified about nvme_id_ns_flbas_to_lbaf_inuse() in src/nvme/util.h #805

Closed
benchuanggli opened this issue Apr 1, 2024 · 2 comments

Comments

@benchuanggli
Copy link
Contributor

I have a question about modifying 8db4b1f37e17a3b6f060311624655246563b553b the function nvme_id_ns_flbas_to_lbaf_inuse().

diff --git a/src/nvme/util.h b/src/nvme/util.h
index 0739cf2f..efdf9757 100644
--- a/src/nvme/util.h
+++ b/src/nvme/util.h
@@ -449,8 +449,8 @@ static inline void nvme_feature_decode_namespace_write_protect(__u32 value,
 
 static inline void nvme_id_ns_flbas_to_lbaf_inuse(__u8 flbas, __u8 *lbaf_inuse)
 {
-       *lbaf_inuse = (((flbas & NVME_NS_FLBAS_HIGHER_MASK) >> 1) |
-                       (flbas & NVME_NS_FLBAS_LOWER_MASK));
+       *lbaf_inuse = ((NVME_FLBAS_HIGHER(flbas) >> 1) |
+                       NVME_FLBAS_LOWER(flbas));
 }

After macro expansion about the FLBAS_HIGHER part

#define NVME_GET(value, name) \
        (((value) >> NVME_##name##_SHIFT) & NVME_##name##_MASK)

NVME_FLBAS_HIGHER(flbas) => 
=> NVME_GET(flbas, FLBAS_HIGHER)
=>  (((flbas) >> NVME_FLBAS_HIGHER_SHIFT) & NVME_FLBAS_HIGHER_MASK)

They should be unequal, right?
Is the previous one correct?

Thanks for your read.

@igaw
Copy link
Collaborator

igaw commented Apr 2, 2024

Yes, you are right. Sorry, I didn't catch this one.

@igaw igaw closed this as completed Apr 2, 2024
@benchuanggli
Copy link
Contributor Author

Maybe we need a test case for it #808.

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

No branches or pull requests

2 participants