-
Notifications
You must be signed in to change notification settings - Fork 132
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
libnvme: Fix the Reference Tag in copy command #455
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -666,8 +666,6 @@ struct nvme_dsm_args { | |
* @prinfow: Protection information field for write | ||
* @dtype: Directive type | ||
* @format: Descriptor format | ||
* @ilbrt_u64: Initial logical block reference tag - 8 byte | ||
* version required for enhanced protection info | ||
*/ | ||
struct nvme_copy_args { | ||
__u64 sdlba; | ||
|
@@ -677,7 +675,7 @@ struct nvme_copy_args { | |
int fd; | ||
__u32 timeout; | ||
__u32 nsid; | ||
__u32 ilbrt; | ||
__u64 ilbrt; | ||
int lr; | ||
int fua; | ||
__u16 nr; | ||
|
@@ -688,7 +686,6 @@ struct nvme_copy_args { | |
__u8 prinfow; | ||
__u8 dtype; | ||
__u8 format; | ||
__u64 ilbrt_u64; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this one too. |
||
}; | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,14 +401,16 @@ void nvme_init_copy_range_f1(struct nvme_copy_range_f1 *copy, __u16 *nlbs, | |
__u64 *slbas, __u64 *eilbrts, __u32 *elbatms, | ||
__u32 *elbats, __u16 nr) | ||
{ | ||
int i; | ||
int i, j; | ||
|
||
for (i = 0; i < nr; i++) { | ||
copy[i].nlb = cpu_to_le16(nlbs[i]); | ||
copy[i].slba = cpu_to_le64(slbas[i]); | ||
copy[i].elbt[2] = cpu_to_le64(eilbrts[i]); | ||
copy[i].elbatm = cpu_to_le16(elbatms[i]); | ||
copy[i].elbat = cpu_to_le16(elbats[i]); | ||
|
||
for (j = 0; j < 8; j++) | ||
copy[i].elbt[9 - j] = (eilbrts[i] >> (8 * j)) & 0xff; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this just a more complicated way of storing the eilbrt little-endian order in the last 8 bytes of elbt (as is removed above)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have verified the copy command with QEMU emulated NVMe device. On using previous logic, the controller received the eilbrt value as zero via format1. Hence, I stored the value byte by byte. Here observed the controller is receiving the appropriate value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which version of the nvme-cli and libnvme did you use? This might be caused by my brown bag release where I There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always I use the latest version of nvme-cli and libnvme. The issue was observed even before the above mentioned changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would have been too easy... |
||
} | ||
} | ||
|
||
|
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.
This breaks the API
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.
I have one more patch for nvme-cli to fix this issue. In that patch, this renamed ilbrt variable is handled. I hope the API will not break once it is merged.
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.
As far I can tell, libnvme is not just used by nvme-cli. This is why I keep repeating we can't break the API for the 1.x series of the library. For 2.x sure, I don't have any problems to modify the API.
BTW, I would suggest to open an in issue with the exact work description and queue it up for the 2.x library. I fear if we don't write it down, this will be lost.
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.
Hi @igaw
I missed to mention a point.
In
struct nvme_copy_args
,ilbrt
andilbrt_u64
are used to store the reference tag values of 32-bit and 64-bit respectively. Theilbrt_u64
is only assigned withcfg.ilbrt
value in nvme-cli. Whereasilbrt
is not assigned with any value. But, both the variables are handled innvme_copy()
libnvme. It seems fishy for me. That's why I tried to use singleilbrt
instead of two variable with different data type.