From patchwork Sat Jun 22 20:58:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 253433 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 359652C0411 for ; Sun, 23 Jun 2013 07:01:01 +1000 (EST) Received: from localhost ([::1]:57232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqUvb-0002ha-3D for incoming@patchwork.ozlabs.org; Sat, 22 Jun 2013 17:00:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqUtp-0008Re-CB for qemu-devel@nongnu.org; Sat, 22 Jun 2013 16:59:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UqUtk-0005fJ-IA for qemu-devel@nongnu.org; Sat, 22 Jun 2013 16:59:09 -0400 Received: from ssl.dlhnet.de ([91.198.192.8]:54241 helo=ssl.dlh.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqUtk-0005f8-9Q for qemu-devel@nongnu.org; Sat, 22 Jun 2013 16:59:04 -0400 Received: from localhost (localhost [127.0.0.1]) by ssl.dlh.net (Postfix) with ESMTP id BD82914AF5B; Sat, 22 Jun 2013 22:59:03 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at ssl.dlh.net Received: from ssl.dlh.net ([127.0.0.1]) by localhost (ssl.dlh.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NEjurgZEbO4W; Sat, 22 Jun 2013 22:58:59 +0200 (CEST) Received: from trinity64-ssd (unknown [82.141.7.8]) by ssl.dlh.net (Postfix) with ESMTP id 1EAC114AF9B; Sat, 22 Jun 2013 22:58:44 +0200 (CEST) Received: by trinity64-ssd (Postfix, from userid 1000) id 119F2202117; Sat, 22 Jun 2013 22:58:44 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org Date: Sat, 22 Jun 2013 22:58:31 +0200 Message-Id: <1371934712-11714-8-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1371934712-11714-1-git-send-email-pl@kamp.de> References: <1371934712-11714-1-git-send-email-pl@kamp.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 91.198.192.8 Cc: Kevin Wolf , pbonzini@redhat.com, Peter Lieven , ronniesahlberg@gmail.com, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 7/8] iscsi: assert that sectors are aligned to LUN blocksize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org if the blocksize of an iSCSI LUN is bigger than the BDRV_SECTOR_SIZE it is possible that sector_num or nb_sectors are not correctly alligned. for now assert that there is no misalignment to avoid data corruption. Signed-off-by: Peter Lieven --- block/iscsi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/iscsi.c b/block/iscsi.c index 683692a..2c410b1 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -249,6 +249,7 @@ iscsi_aio_write16_cb(struct iscsi_context *iscsi, int status, static int64_t sector_qemu2lun(int64_t sector, IscsiLun *iscsilun) { + assert((sector * BDRV_SECTOR_SIZE) % iscsilun->block_size == 0); return sector * BDRV_SECTOR_SIZE / iscsilun->block_size; } @@ -269,6 +270,8 @@ iscsi_aio_writev_acb(IscsiAIOCB *acb) acb->status = -EINPROGRESS; acb->buf = NULL; + assert((acb->nb_sectors * BDRV_SECTOR_SIZE) % acb->iscsilun->block_size == 0); + /* this will allow us to get rid of 'buf' completely */ size = acb->nb_sectors * BDRV_SECTOR_SIZE; @@ -618,6 +621,8 @@ static int iscsi_aio_discard_acb(IscsiAIOCB *acb) { acb->buf = NULL; list[0].lba = sector_qemu2lun(acb->sector_num, acb->iscsilun); + + assert((acb->nb_sectors * BDRV_SECTOR_SIZE) % acb->iscsilun->block_size == 0); list[0].num = acb->nb_sectors * BDRV_SECTOR_SIZE / acb->iscsilun->block_size; acb->task = iscsi_unmap_task(iscsi, acb->iscsilun->lun, @@ -947,6 +952,8 @@ coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, iTask.complete = 0; iTask.bs = bs; + assert((nb_sectors * BDRV_SECTOR_SIZE) % iscsilun->block_size == 0); + list[0].lba = sector_qemu2lun(sector_num, iscsilun); list[0].num = nb_sectors * BDRV_SECTOR_SIZE / iscsilun->block_size;