From patchwork Wed Dec 23 15:21:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avishay Traeger1 X-Patchwork-Id: 69560 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBNFLU7N016558 for ; Wed, 23 Dec 2009 15:21:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756233AbZLWPV2 (ORCPT ); Wed, 23 Dec 2009 10:21:28 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756225AbZLWPV2 (ORCPT ); Wed, 23 Dec 2009 10:21:28 -0500 Received: from mtagate4.de.ibm.com ([195.212.17.164]:59262 "EHLO mtagate4.de.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756223AbZLWPV1 (ORCPT ); Wed, 23 Dec 2009 10:21:27 -0500 Received: from d12nrmr1507.megacenter.de.ibm.com (d12nrmr1507.megacenter.de.ibm.com [9.149.167.1]) by mtagate4.de.ibm.com (8.13.1/8.13.1) with ESMTP id nBNFLQDa030704 for ; Wed, 23 Dec 2009 15:21:26 GMT Received: from d12av06.megacenter.de.ibm.com (d12av06.megacenter.de.ibm.com [9.149.165.230]) by d12nrmr1507.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id nBNFLQGn1827048 for ; Wed, 23 Dec 2009 16:21:26 +0100 Received: from d12av06.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av06.megacenter.de.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id nBNFLPdI010470 for ; Wed, 23 Dec 2009 16:21:25 +0100 Received: from d12mc102.megacenter.de.ibm.com (d12mc102.megacenter.de.ibm.com [9.149.167.114]) by d12av06.megacenter.de.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id nBNFLPGR010467; Wed, 23 Dec 2009 16:21:25 +0100 Subject: [PATCH 1/2] virtio-blk: add max sectors feature (virtio_blk driver) X-KeepSent: 67D6809E:115A2813-C2257695:0053288C; type=4; name=$KeepSent To: kvm@vger.kernel.org, qemu-devel@nongnu.org Cc: Rusty Russell , Anthony Liguori X-Mailer: Lotus Notes Release 8.0.1 February 07, 2008 Message-ID: From: Avishay Traeger1 Date: Wed, 23 Dec 2009 17:21:25 +0200 X-MIMETrack: Serialize by Router on D12MC102/12/M/IBM(Release 8.5|December 05, 2008) at 23/12/2009 17:21:25 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 51042f0..e68ea8a 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -351,8 +351,14 @@ static int __devinit virtblk_probe(struct virtio_device *vdev) /* No need to bounce any requests */ blk_queue_bounce_limit(vblk->disk->queue, BLK_BOUNCE_ANY); - /* No real sector limit. */ - blk_queue_max_sectors(vblk->disk->queue, -1U); + /* Host can optionally specify maximum total sectors in an I/O. */ + err = virtio_config_val(vdev, VIRTIO_BLK_F_SECTOR_MAX, + offsetof(struct virtio_blk_config, sectors_max), + &v); + if (!err) + blk_queue_max_sectors(vblk->disk->queue, v); + else + blk_queue_max_sectors(vblk->disk->queue, -1U); /* Host can optionally specify maximum segment size and number of * segments. */ @@ -412,7 +418,7 @@ static struct virtio_device_id id_table[] = { static unsigned int features[] = { VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE, - VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_FLUSH + VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_FLUSH, VIRTIO_BLK_F_SECTOR_MAX }; /* diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h index fd294c5..2536d74 100644 --- a/include/linux/virtio_blk.h +++ b/include/linux/virtio_blk.h @@ -15,6 +15,7 @@ #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/ #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */ #define VIRTIO_BLK_F_FLUSH 9 /* Cache flush command support */ +#define VIRTIO_BLK_F_SECTOR_MAX 10 /* Maximum total sectors in an I/O */ struct virtio_blk_config { /* The capacity (in 512-byte sectors). */ @@ -31,6 +32,7 @@ struct virtio_blk_config { } geometry; /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */ __u32 blk_size; + __u32 sectors_max; } __attribute__((packed)); /*