From patchwork Sun Sep 12 21:42:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 64563 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 918A0B6F0D for ; Mon, 13 Sep 2010 07:44:26 +1000 (EST) Received: from localhost ([127.0.0.1]:54838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OuuLW-0005k5-S2 for incoming@patchwork.ozlabs.org; Sun, 12 Sep 2010 17:44:23 -0400 Received: from [140.186.70.92] (port=48409 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OuuKK-0005ia-Ab for qemu-devel@nongnu.org; Sun, 12 Sep 2010 17:43:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OuuKG-0003NU-G5 for qemu-devel@nongnu.org; Sun, 12 Sep 2010 17:43:08 -0400 Received: from verein.lst.de ([213.95.11.210]:56475) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OuuKG-0003MD-81 for qemu-devel@nongnu.org; Sun, 12 Sep 2010 17:43:04 -0400 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id o8CLguWY004884 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Sun, 12 Sep 2010 23:42:56 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o8CLguvl004883; Sun, 12 Sep 2010 23:42:56 +0200 Date: Sun, 12 Sep 2010 23:42:56 +0200 From: Christoph Hellwig To: qemu-devel@nongnu.org Message-ID: <20100912214256.GA4854@lst.de> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Scanned-By: MIMEDefang 2.39 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 1/5] use qemu_blockalign consistently X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use qemu_blockalign for all allocations in the block layer. This allows increasing the required alignment, which is need to support O_DIRECT on devices with large block sizes. Signed-off-by: Christoph Hellwig Index: qemu/hw/scsi-disk.c =================================================================== --- qemu.orig/hw/scsi-disk.c 2010-09-12 14:42:40.942759377 -0300 +++ qemu/hw/scsi-disk.c 2010-09-12 14:43:04.694759377 -0300 @@ -70,14 +70,15 @@ struct SCSIDiskState char *serial; }; -static SCSIDiskReq *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun) +static SCSIDiskReq *scsi_new_request(SCSIDiskState *s, uint32_t tag, + uint32_t lun) { SCSIRequest *req; SCSIDiskReq *r; - req = scsi_req_alloc(sizeof(SCSIDiskReq), d, tag, lun); + req = scsi_req_alloc(sizeof(SCSIDiskReq), &s->qdev, tag, lun); r = DO_UPCAST(SCSIDiskReq, req, req); - r->iov.iov_base = qemu_memalign(512, SCSI_DMA_BUF_SIZE); + r->iov.iov_base = qemu_blockalign(s->bs, SCSI_DMA_BUF_SIZE); return r; } @@ -939,7 +940,7 @@ static int32_t scsi_send_command(SCSIDev } /* ??? Tags are not unique for different luns. We only implement a single lun, so this should not matter. */ - r = scsi_new_request(d, tag, lun); + r = scsi_new_request(s, tag, lun); outbuf = (uint8_t *)r->iov.iov_base; is_write = 0; DPRINTF("Command: lun=%d tag=0x%x data=0x%02x", lun, tag, buf[0]); Index: qemu/hw/sd.c =================================================================== --- qemu.orig/hw/sd.c 2010-09-12 14:31:04.387759376 -0300 +++ qemu/hw/sd.c 2010-09-12 14:43:04.695759377 -0300 @@ -440,7 +440,7 @@ SDState *sd_init(BlockDriverState *bs, i SDState *sd; sd = (SDState *) qemu_mallocz(sizeof(SDState)); - sd->buf = qemu_memalign(512, 512); + sd->buf = qemu_blockalign(bs, 512); sd->spi = is_spi; sd->enable = 1; sd_reset(sd, bs); Index: qemu/qemu-io.c =================================================================== --- qemu.orig/qemu-io.c 2010-09-12 14:31:04.394759376 -0300 +++ qemu/qemu-io.c 2010-09-12 14:43:04.699759377 -0300 @@ -61,7 +61,7 @@ static void *qemu_io_alloc(size_t len, i if (misalign) len += MISALIGN_OFFSET; - buf = qemu_memalign(512, len); + buf = qemu_blockalign(bs, len); memset(buf, pattern, len); if (misalign) buf += MISALIGN_OFFSET; Index: qemu/qemu-nbd.c =================================================================== --- qemu.orig/qemu-nbd.c 2010-09-12 14:31:04.401759376 -0300 +++ qemu/qemu-nbd.c 2010-09-12 14:43:04.706759377 -0300 @@ -446,7 +446,7 @@ int main(int argc, char **argv) max_fd = sharing_fds[0]; nb_fds++; - data = qemu_memalign(512, NBD_BUFFER_SIZE); + data = qemu_blockalign(bs, NBD_BUFFER_SIZE); if (data == NULL) errx(EXIT_FAILURE, "Cannot allocate data buffer"); Index: qemu/posix-aio-compat.c =================================================================== --- qemu.orig/posix-aio-compat.c 2010-09-12 14:42:46.725759377 -0300 +++ qemu/posix-aio-compat.c 2010-09-12 14:43:04.711759377 -0300 @@ -270,7 +270,7 @@ static ssize_t handle_aiocb_rw(struct qe * Ok, we have to do it the hard way, copy all segments into * a single aligned buffer. */ - buf = qemu_memalign(512, aiocb->aio_nbytes); + buf = qemu_blockalign(aiocb->common.bs, aiocb->aio_nbytes); if (aiocb->aio_type & QEMU_AIO_WRITE) { char *p = buf; int i;