public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Mike Snitzer <snitzer@redhat.com>
Cc: Ryan Harper <ryanh@us.ibm.com>,
	dm-devel@redhat.com, kvm@vger.kernel.org, john.cooper@redhat.com
Subject: Re: [PATCH] virtio-blk: put request that was created to retrieve the device id
Date: Sat, 9 Oct 2010 12:11:04 +1030	[thread overview]
Message-ID: <201010091211.05478.rusty@rustcorp.com.au> (raw)
In-Reply-To: <20100909210042.GA22092@redhat.com>

On Fri, 10 Sep 2010 06:30:42 am Mike Snitzer wrote:
> On Thu, Sep 09 2010 at  4:30pm -0400,
> Ryan Harper <ryanh@us.ibm.com> wrote:
> 
> > * Mike Snitzer <snitzer@redhat.com> [2010-09-09 15:15]:
> > > On Thu, Sep 09 2010 at  3:43pm -0400,
> > > Mike Snitzer <snitzer@redhat.com> wrote:
> > > # while true ; do cat /sys/block/vda/queue/nr_requests_used && cat /sys/block/vda/serial && date && sleep 1 ; done
> > > 10
> > > Thu Sep  9 16:04:40 EDT 2010
> > > 11
...
> > The qemu on the host isn't new enough to handle the request.  This
> > serial attribute should have had a feature bit with it (it did at one
> > point in one of the previous forms of the virtio-blk serial patch
> > series, but it isn't present now) so we don't expose the attribute
> > unless backend can handle the request type.
> 
> Be that as it may, it doesn't change the fact that the request created
> in virtblk_get_id (via blk_make_request) isn't being properly cleaned
> up.

Thanks for re-sending Mike.

This patch confused me at first, but it's correct.  Took me a few
minutes of checking though.

For those not familiar with the block layer, here are the key points:

1) blk_execute_rq waits for the request to finish.
2) blk_execute_rq grabs its own reference to the req.
3) Once qemu finishes with it and sends an interrupt blk_done()
   releases that reference via __blk_end_request_all()
4) As caller of blk_make_request, it is our responsibility to
   free it after it's finished, ie. after blk_execute_rq.

> This patch fixes the issue for me; Rusty and/or Christoph please
> review/advise.

Thanks, applied, and CC'd stable@kernel.org (it's in 2.6.35 as well).

From: Mike Snitzer <snitzer@redhat.com>
Subject: virtio-blk: fix request leak.

Must drop reference taken by blk_make_request().

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: stable@kernel.org # .35.x
---
 drivers/block/virtio_blk.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 1260628..831e75c 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -199,6 +199,7 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str)
 	struct virtio_blk *vblk = disk->private_data;
 	struct request *req;
 	struct bio *bio;
+	int err;
 
 	bio = bio_map_kern(vblk->disk->queue, id_str, VIRTIO_BLK_ID_BYTES,
 			   GFP_KERNEL);
@@ -212,7 +213,10 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str)
 	}
 
 	req->cmd_type = REQ_TYPE_SPECIAL;
-	return blk_execute_rq(vblk->disk->queue, vblk->disk, req, false);
+	err = blk_execute_rq(vblk->disk->queue, vblk->disk, req, false);
+	blk_put_request(req);
+
+	return err;
 }
 
 static int virtblk_locked_ioctl(struct block_device *bdev, fmode_t mode,

      parent reply	other threads:[~2010-10-09  1:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100902032246.GA31484@redhat.com>
2010-09-09 15:26 ` [REGRESSION][BISECTED] virtio-blk serial attribute causes guest to hang [Was: Re: [PATCH UPDATED 4/5] dm: implement REQ_FLUSH/FUA support for request-based dm] Mike Snitzer
2010-09-09 15:44   ` Ryan Harper
2010-09-09 15:57     ` Mike Snitzer
2010-09-09 16:03       ` Ryan Harper
2010-09-09 17:55         ` Mike Snitzer
2010-09-09 18:35           ` Ryan Harper
2010-09-09 19:15             ` Mike Snitzer
2010-09-09 19:43               ` Mike Snitzer
2010-09-09 20:14                 ` Mike Snitzer
2010-09-09 20:30                   ` Ryan Harper
2010-09-09 21:00                     ` [PATCH] virtio-blk: put request that was created to retrieve the device id Mike Snitzer
2010-09-09 21:15                       ` Christoph Hellwig
2010-09-17 14:58                         ` Ryan Harper
2010-09-21 21:00                           ` Christoph Hellwig
2010-10-08 16:06                             ` [2.6.36 REGRESSION] " Mike Snitzer
2010-10-09  1:41                       ` Rusty Russell [this message]

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=201010091211.05478.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=dm-devel@redhat.com \
    --cc=john.cooper@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=ryanh@us.ibm.com \
    --cc=snitzer@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox