diff options
author | Matthew Wilcox <matthew.r.wilcox@intel.com> | 2013-03-27 21:28:22 -0400 |
---|---|---|
committer | Matthew Wilcox <matthew.r.wilcox@intel.com> | 2013-04-16 15:05:22 -0400 |
commit | 063cc6d5591ea9c0631b81ac5c7b829d99738b2f (patch) | |
tree | 5a61528a0a76394666fdc42d6b51bf576a7c1002 /include | |
parent | acb7aa0db09b8abd38abeb84334a8a27a52fbb1b (diff) |
NVMe: Abstract out sector to block number conversion
Introduce nvme_block_nr() to help convert sectors to block numbers.
This fixes an integer overflow in the SCSI conversion layer, and it's
slightly less typing than opencoding it.
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Acked-by: Keith Busch <keith.busch@intel.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/nvme.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/nvme.h b/include/linux/nvme.h index aa575033dbe7..09f419d4da4e 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h | |||
@@ -566,6 +566,11 @@ struct nvme_iod { | |||
566 | struct scatterlist sg[0]; | 566 | struct scatterlist sg[0]; |
567 | }; | 567 | }; |
568 | 568 | ||
569 | static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector) | ||
570 | { | ||
571 | return (sector >> (ns->lba_shift - 9)); | ||
572 | } | ||
573 | |||
569 | /** | 574 | /** |
570 | * nvme_free_iod - frees an nvme_iod | 575 | * nvme_free_iod - frees an nvme_iod |
571 | * @dev: The device that the I/O was submitted to | 576 | * @dev: The device that the I/O was submitted to |