dm-crypt: use __bio_add_page to add single page to clone bio
[linux-block.git] / block / blk.h
index 9f171b8f1e3402d938c3545db3caac8f7baf4c98..7ad7cb6ffa0135995c5fee6015f762801ad58767 100644 (file)
@@ -420,6 +420,18 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio,
                struct page *page, unsigned int len, unsigned int offset,
                unsigned int max_sectors, bool *same_page);
 
+/*
+ * Clean up a page appropriately, where the page may be pinned, may have a
+ * ref taken on it or neither.
+ */
+static inline void bio_release_page(struct bio *bio, struct page *page)
+{
+       if (bio_flagged(bio, BIO_PAGE_PINNED))
+               unpin_user_page(page);
+       else if (bio_flagged(bio, BIO_PAGE_REFFED))
+               put_page(page);
+}
+
 struct request_queue *blk_alloc_queue(int node_id);
 
 int disk_scan_partitions(struct gendisk *disk, fmode_t mode);