[PATCH] blkdev: fix blkdev_issue_zeroout return value

From: Dmitry Monakhov
Date: Tue Jul 27 2010 - 09:12:27 EST


- If function called without barrier option retvalue is incorrect
- Add io_schedule() between loops


diff --git a/block/blk-lib.c b/block/blk-lib.c
index d0216b9..a8d6a21 100644

Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
---
block/blk-lib.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/block/blk-lib.c b/block/blk-lib.c
index d0216b9..a8d6a21 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -157,7 +157,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;
@@ -175,11 +175,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;
@@ -198,6 +201,7 @@ submit:
if (ret < (sz << 9))
break;
}
+ ret = 0;
issued++;
submit_bio(WRITE, bio);
}
@@ -218,15 +222,18 @@ submit:
/* One of bios in the batch was completed with error.*/
ret = -EIO;

- if (ret)
+ if (ret && ret != -ENOMEM)
goto out;

if (test_bit(BIO_EOPNOTSUPP, &bb.flags)) {
ret = -EOPNOTSUPP;
goto out;
}
- if (nr_sects != 0)
+ if (nr_sects != 0) {
+ if (ret == -ENOMEM)
+ io_schedule();
goto submit;
+ }
out:
return ret;
}
--
1.6.6.1


--=-=-=--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/