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

NVMEDevice: optimize sector_size usage #12780

Merged
merged 1 commit into from Jan 6, 2017
Merged

Conversation

optimistyzy
Copy link
Contributor

spdk_nvme_ns_get_sector_size returns 32 bit size,
so we just use 32 bit size for sector_size.

Signed-off-by: optimistyzy optimistyzy@gmail.com

@optimistyzy
Copy link
Contributor Author

optimistyzy commented Jan 4, 2017

block_size = std::max(CEPH_PAGE_SIZE, spdk_nvme_ns_get_sector_size(ns));
size = spdk_nvme_ns_get_sector_size(ns) * spdk_nvme_ns_get_num_sectors(ns);
block_size = std::max(CEPH_PAGE_SIZE, sector_size);
size = sector_size * spdk_nvme_ns_get_num_sectors(ns);
Copy link
Contributor

Choose a reason for hiding this comment

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

sector_size is 32bit, spdk_nvme_ns_get_num_sectors returns 64bit. and the temp result may be 32bit or 64 bit, which depends on OS. If 32bit os, the result may over flow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liupan1111 The result is put in size (which is uint64_t), so...

spdk_nvme_ns_get_sector_size returns 32 bit size,
so we just use 32 bit size for sector_size.

Signed-off-by: optimistyzy <optimistyzy@gmail.com>
@optimistyzy
Copy link
Contributor Author

@yuyuyu101 @liupan1111 @tchaikov Could this patch and #12776 be merged? Thanks.

@yuyuyu101 yuyuyu101 merged commit 95bc52a into ceph:master Jan 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants