HMP: Implement idle pull for HMP
[firefly-linux-kernel-4.4.55.git] / fs / bio-integrity.c
index 8c4c604c840df76309d325c301c50dc00b818bba..8fb42916d8a29812e349fdbfa980ef1c34056ce4 100644 (file)
@@ -97,9 +97,7 @@ void bio_integrity_free(struct bio *bio)
        struct bio_integrity_payload *bip = bio->bi_integrity;
        struct bio_set *bs = bio->bi_pool;
 
-       /* A cloned bio doesn't own the integrity metadata */
-       if (!bio_flagged(bio, BIO_CLONED) && !bio_flagged(bio, BIO_FS_INTEGRITY)
-           && bip->bip_buf != NULL)
+       if (bip->bip_owns_buf)
                kfree(bip->bip_buf);
 
        if (bs) {
@@ -386,6 +384,7 @@ int bio_integrity_prep(struct bio *bio)
                return -EIO;
        }
 
+       bip->bip_owns_buf = 1;
        bip->bip_buf = buf;
        bip->bip_size = len;
        bip->bip_sector = bio->bi_sector;
@@ -661,8 +660,8 @@ void bio_integrity_split(struct bio *bio, struct bio_pair *bp, int sectors)
        bp->bio1.bi_integrity = &bp->bip1;
        bp->bio2.bi_integrity = &bp->bip2;
 
-       bp->iv1 = bip->bip_vec[0];
-       bp->iv2 = bip->bip_vec[0];
+       bp->iv1 = bip->bip_vec[bip->bip_idx];
+       bp->iv2 = bip->bip_vec[bip->bip_idx];
 
        bp->bip1.bip_vec = &bp->iv1;
        bp->bip2.bip_vec = &bp->iv2;