+/*
+ * Convert a number of 512B sectors to a number of pages.
+ * The result is limited to a number of pages that can fit into a BIO.
+ * Also make sure that the result is always at least 1 (page) for the cases
+ * where nr_sects is lower than the number of sectors in a page.
+ */
+static unsigned int __blkdev_sectors_to_bio_pages(sector_t nr_sects)
+{
+ sector_t bytes = (nr_sects << 9) + PAGE_SIZE - 1;
+
+ return min(bytes >> PAGE_SHIFT, (sector_t)BIO_MAX_PAGES);
+}
+