blkdev: fix blkdev_issue_zeroout return value

- If function called without barrier option retvalue is incorrect

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
This commit is contained in:
Dmitry Monakhov 2010-08-06 13:23:25 +02:00 committed by Jens Axboe
parent 3383977fad
commit 18edc8eaa6

View File

@ -145,7 +145,7 @@ static void bio_batch_end_io(struct bio *bio, int err)
int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
sector_t nr_sects, gfp_t gfp_mask, unsigned long flags) sector_t nr_sects, gfp_t gfp_mask, unsigned long flags)
{ {
int ret = 0; int ret;
struct bio *bio; struct bio *bio;
struct bio_batch bb; struct bio_batch bb;
unsigned int sz, issued = 0; unsigned int sz, issued = 0;
@ -163,11 +163,14 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
return ret; return ret;
} }
submit: submit:
ret = 0;
while (nr_sects != 0) { while (nr_sects != 0) {
bio = bio_alloc(gfp_mask, bio = bio_alloc(gfp_mask,
min(nr_sects, (sector_t)BIO_MAX_PAGES)); min(nr_sects, (sector_t)BIO_MAX_PAGES));
if (!bio) if (!bio) {
ret = -ENOMEM;
break; break;
}
bio->bi_sector = sector; bio->bi_sector = sector;
bio->bi_bdev = bdev; bio->bi_bdev = bdev;
@ -186,6 +189,7 @@ submit:
if (ret < (sz << 9)) if (ret < (sz << 9))
break; break;
} }
ret = 0;
issued++; issued++;
submit_bio(WRITE, bio); submit_bio(WRITE, bio);
} }