Merge tag 'vfio-v4.6-rc1' of git://github.com/awilliam/linux-vfio
[linux-2.6-block.git] / drivers / block / drbd / drbd_worker.c
index eff716c27b1fdf53caa7440ac5bad755c271ad43..4d87499f0d54829bd22594f97202f77fdd533f2e 100644 (file)
@@ -274,51 +274,56 @@ void drbd_request_endio(struct bio *bio)
                complete_master_bio(device, &m);
 }
 
-void drbd_csum_ee(struct crypto_hash *tfm, struct drbd_peer_request *peer_req, void *digest)
+void drbd_csum_ee(struct crypto_ahash *tfm, struct drbd_peer_request *peer_req, void *digest)
 {
-       struct hash_desc desc;
+       AHASH_REQUEST_ON_STACK(req, tfm);
        struct scatterlist sg;
        struct page *page = peer_req->pages;
        struct page *tmp;
        unsigned len;
 
-       desc.tfm = tfm;
-       desc.flags = 0;
+       ahash_request_set_tfm(req, tfm);
+       ahash_request_set_callback(req, 0, NULL, NULL);
 
        sg_init_table(&sg, 1);
-       crypto_hash_init(&desc);
+       crypto_ahash_init(req);
 
        while ((tmp = page_chain_next(page))) {
                /* all but the last page will be fully used */
                sg_set_page(&sg, page, PAGE_SIZE, 0);
-               crypto_hash_update(&desc, &sg, sg.length);
+               ahash_request_set_crypt(req, &sg, NULL, sg.length);
+               crypto_ahash_update(req);
                page = tmp;
        }
        /* and now the last, possibly only partially used page */
        len = peer_req->i.size & (PAGE_SIZE - 1);
        sg_set_page(&sg, page, len ?: PAGE_SIZE, 0);
-       crypto_hash_update(&desc, &sg, sg.length);
-       crypto_hash_final(&desc, digest);
+       ahash_request_set_crypt(req, &sg, digest, sg.length);
+       crypto_ahash_finup(req);
+       ahash_request_zero(req);
 }
 
-void drbd_csum_bio(struct crypto_hash *tfm, struct bio *bio, void *digest)
+void drbd_csum_bio(struct crypto_ahash *tfm, struct bio *bio, void *digest)
 {
-       struct hash_desc desc;
+       AHASH_REQUEST_ON_STACK(req, tfm);
        struct scatterlist sg;
        struct bio_vec bvec;
        struct bvec_iter iter;
 
-       desc.tfm = tfm;
-       desc.flags = 0;
+       ahash_request_set_tfm(req, tfm);
+       ahash_request_set_callback(req, 0, NULL, NULL);
 
        sg_init_table(&sg, 1);
-       crypto_hash_init(&desc);
+       crypto_ahash_init(req);
 
        bio_for_each_segment(bvec, bio, iter) {
                sg_set_page(&sg, bvec.bv_page, bvec.bv_len, bvec.bv_offset);
-               crypto_hash_update(&desc, &sg, sg.length);
+               ahash_request_set_crypt(req, &sg, NULL, sg.length);
+               crypto_ahash_update(req);
        }
-       crypto_hash_final(&desc, digest);
+       ahash_request_set_crypt(req, NULL, digest, 0);
+       crypto_ahash_final(req);
+       ahash_request_zero(req);
 }
 
 /* MAYBE merge common code with w_e_end_ov_req */
@@ -337,7 +342,7 @@ static int w_e_send_csum(struct drbd_work *w, int cancel)
        if (unlikely((peer_req->flags & EE_WAS_ERROR) != 0))
                goto out;
 
-       digest_size = crypto_hash_digestsize(peer_device->connection->csums_tfm);
+       digest_size = crypto_ahash_digestsize(peer_device->connection->csums_tfm);
        digest = kmalloc(digest_size, GFP_NOIO);
        if (digest) {
                sector_t sector = peer_req->i.sector;
@@ -1113,7 +1118,7 @@ int w_e_end_csum_rs_req(struct drbd_work *w, int cancel)
                 * a real fix would be much more involved,
                 * introducing more locking mechanisms */
                if (peer_device->connection->csums_tfm) {
-                       digest_size = crypto_hash_digestsize(peer_device->connection->csums_tfm);
+                       digest_size = crypto_ahash_digestsize(peer_device->connection->csums_tfm);
                        D_ASSERT(device, digest_size == di->digest_size);
                        digest = kmalloc(digest_size, GFP_NOIO);
                }
@@ -1163,7 +1168,7 @@ int w_e_end_ov_req(struct drbd_work *w, int cancel)
        if (unlikely(cancel))
                goto out;
 
-       digest_size = crypto_hash_digestsize(peer_device->connection->verify_tfm);
+       digest_size = crypto_ahash_digestsize(peer_device->connection->verify_tfm);
        digest = kmalloc(digest_size, GFP_NOIO);
        if (!digest) {
                err = 1;        /* terminate the connection in case the allocation failed */
@@ -1235,7 +1240,7 @@ int w_e_end_ov_reply(struct drbd_work *w, int cancel)
        di = peer_req->digest;
 
        if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
-               digest_size = crypto_hash_digestsize(peer_device->connection->verify_tfm);
+               digest_size = crypto_ahash_digestsize(peer_device->connection->verify_tfm);
                digest = kmalloc(digest_size, GFP_NOIO);
                if (digest) {
                        drbd_csum_ee(peer_device->connection->verify_tfm, peer_req, digest);