@@ -871,6 +871,23 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
#define SECTOR_SIZE (1 << SECTOR_SHIFT)
#endif
+/**
+ * bytes_to_sectors - Convert size in bytes to number of sectors of 512 bytes
+ * @bytes: number of bytes to be converted to sectors
+ *
+ * Description:
+ * Kernel I/O operations are always made in "sectors". In order to set the
+ * correct number of sectors for a given number of bytes, we need to group the
+ * number of bytes in "sectors of 512 bytes" by shifting the size value by 9,
+ * which is the same than dividing the size by 512.
+ *
+ * Returns the number of sectors by the given number of bytes.
+ */
+static inline sector_t bytes_to_sectors(long long bytes)
+{
+ return bytes >> SECTOR_SHIFT;
+}
+
/*
* blk_rq_pos() : the current sector
* blk_rq_bytes() : bytes left in the entire request