X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=block%2Fblk-lib.c;h=c392029a104e0f233fb10022a323ee1ab7ed0118;hb=3f66116e89521ef71ab0d63dc07a639def88a577;hp=5d793e143f3c7145423c3cd84a859d8f07e97554;hpb=10d1f9e2ccfff40665a00ea0e0a0d11e54c9cbb1;p=~andy%2Flinux diff --git a/block/blk-lib.c b/block/blk-lib.c index 5d793e143f3..c392029a104 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -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); }