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
os/bluestore: fix NVMEDevice::open failure if serial number ends with a … #12956
Conversation
@yuyuyu101 @optimistyzy Please take a look. Thanks. |
could you give a example? |
The serial number I get: If without my fix, error will occur: |
@@ -798,7 +799,7 @@ int NVMEDevice::open(string p) | |||
derr << __func__ << " unable to read " << p << ": " << cpp_strerror(r) << dendl; | |||
return r; | |||
} | |||
while (r > 0 && !isalpha(buf[r-1])) { | |||
while (r > 0 && !isxdigit(buf[r-1])) { |
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.
what if digit is at the ending?
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.
Suppose that buf is "55cd2e414c93a4e2" and r is 16, the length of buf.
In the 'while' loop, --r set r to be 15, and the number "2" is ignored, then serial_number will be "55cd2e414c93a4e", which as the first parameter of manager.try_get().
As you know, after a long procedure, probe_cb() gets the same serial number("55cd2e414c93a4e2") via the interface of spdk_pci_device_get_serial_number(),
but now "55cd2e414c93a4e" is not equal to "55cd2e414c93a4e2", probe_cb() returns false.
@@ -798,7 +798,7 @@ int NVMEDevice::open(string p) | |||
derr << __func__ << " unable to read " << p << ": " << cpp_strerror(r) << dendl; | |||
return r; | |||
} | |||
while (r > 0 && !isalpha(buf[r-1])) { | |||
while (r > 0 && !isxdigit(buf[r-1])) { |
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.
wouldn't be the better approach to scan buf from the beginning while isxdigit? This will protect from all the potential garbage that might be at the end of the read buffer after the serial number.
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.
better implementation.
@liupan1111 please take a look. |
@liuhongtong , please modify your commit as the suggestion from |
… a number buf in effect is the serial number in ceph.conf and the serial number consists of 16 hexadecimal characters. 1. In order to avoid ignoring the numbers, scan buf with isxdigit. 2. In order to ignore all the potential garbage, scan buf from the beginning. Signed-off-by: Hongtong Liu <hongtong.liu@istuary.com>
Fix assert failure in ~Task(). Signed-off-by: Hongtong Liu <hongtong.liu@istuary.com>
2a9bb8e
to
97aa6ec
Compare
@ifed01 @liupan1111 modified. |
lgtm |
@yuyuyu101 please merge it. |
…number
The serial number consists of 16 hexadecimal characters.
If the serial number ends with a number, manager.try_get()
will deliver the truncated serial number.
Signed-off-by: Hongtong Liu hongtong.liu@istuary.com