Commit 18edc8eaa68070771bdb2098260e44efe74de722

Authored by Dmitry Monakhov
Committed by Jens Axboe
1 parent 3383977fad

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>

Showing 1 changed file with 6 additions and 2 deletions Side-by-side Diff

... ... @@ -145,7 +145,7 @@
145 145 int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
146 146 sector_t nr_sects, gfp_t gfp_mask, unsigned long flags)
147 147 {
148   - int ret = 0;
  148 + int ret;
149 149 struct bio *bio;
150 150 struct bio_batch bb;
151 151 unsigned int sz, issued = 0;
152 152  
153 153  
... ... @@ -163,11 +163,14 @@
163 163 return ret;
164 164 }
165 165 submit:
  166 + ret = 0;
166 167 while (nr_sects != 0) {
167 168 bio = bio_alloc(gfp_mask,
168 169 min(nr_sects, (sector_t)BIO_MAX_PAGES));
169   - if (!bio)
  170 + if (!bio) {
  171 + ret = -ENOMEM;
170 172 break;
  173 + }
171 174  
172 175 bio->bi_sector = sector;
173 176 bio->bi_bdev = bdev;
... ... @@ -186,6 +189,7 @@
186 189 if (ret < (sz << 9))
187 190 break;
188 191 }
  192 + ret = 0;
189 193 issued++;
190 194 submit_bio(WRITE, bio);
191 195 }