]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - block/blk-lib.c
KVM: x86: Fix SVM VMCB reset
[net-next-2.6.git] / block / blk-lib.c
index 5d793e143f3c7145423c3cd84a859d8f07e97554..c392029a104e0f233fb10022a323ee1ab7ed0118 100644 (file)
@@ -62,6 +62,12 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
                max_discard_sectors &= ~(disc_sects - 1);
        }
 
+       if (flags & BLKDEV_IFL_SECURE) {
+               if (!blk_queue_secdiscard(q))
+                       return -EOPNOTSUPP;
+               type |= DISCARD_SECURE;
+       }
+
        while (nr_sects && !ret) {
                bio = bio_alloc(gfp_mask, 1);
                if (!bio) {
@@ -145,7 +151,7 @@ static void bio_batch_end_io(struct bio *bio, int err)
 int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
                        sector_t nr_sects, gfp_t gfp_mask, unsigned long flags)
 {
-       int ret = 0;
+       int ret;
        struct bio *bio;
        struct bio_batch bb;
        unsigned int sz, issued = 0;
@@ -163,11 +169,14 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
                        return ret;
        }
 submit:
+       ret = 0;
        while (nr_sects != 0) {
                bio = bio_alloc(gfp_mask,
                                min(nr_sects, (sector_t)BIO_MAX_PAGES));
-               if (!bio)
+               if (!bio) {
+                       ret = -ENOMEM;
                        break;
+               }
 
                bio->bi_sector = sector;
                bio->bi_bdev   = bdev;
@@ -186,6 +195,7 @@ submit:
                        if (ret < (sz << 9))
                                break;
                }
+               ret = 0;
                issued++;
                submit_bio(WRITE, bio);
        }