All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: axboe@kernel.dk
Cc: linux-kernel@vger.kernel.org
Subject: Resend: [PATCH] blkdev: fix blkdev_issue_zeroout return value
Date: Fri, 06 Aug 2010 14:42:48 +0400	[thread overview]
Message-ID: <87vd7o2f9z.fsf@dmon-lap.sw.ru> (raw)

[-- Attachment #1: Type: text/plain, Size: 240 bytes --]

Hi Jens,
Seems that my first mail was missed somewhere.  
I've found couple of trivial issues in blkdev_issue_zeroout()
implementation. Unfortunately I've miss during initial testing phase
because always called it with BARRIER|WAIT flags.


[-- Attachment #2: patch-1 --]
[-- Type: text/plain, Size: 1841 bytes --]

>From 5eb4d762ad8fe146ee638fb1b2d7730db3e3ca4b Mon Sep 17 00:00:00 2001
From: Dmitry Monakhov <dmonakhov@openvz.org>
Date: Tue, 27 Jul 2010 17:12:27 +0400
Subject: [PATCH] blkdev: fix blkdev_issue_zeroout return value

- 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@openvz.org>
---
 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

             reply	other threads:[~2010-08-06 10:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-06 10:42 Dmitry Monakhov [this message]
2010-08-06 10:51 ` Resend: [PATCH] blkdev: fix blkdev_issue_zeroout return value Jens Axboe
2010-08-06 10:56 ` Jens Axboe
2010-08-06 11:15   ` Dmitry Monakhov
2010-08-06 11:24     ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vd7o2f9z.fsf@dmon-lap.sw.ru \
    --to=dmonakhov@openvz.org \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.