From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uwuyu-0002Yc-4y for qemu-devel@nongnu.org; Wed, 10 Jul 2013 10:03:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uwuyo-0000zv-5M for qemu-devel@nongnu.org; Wed, 10 Jul 2013 10:02:56 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:57854 helo=mx01.kamp.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Uwuyn-0000zg-Qp for qemu-devel@nongnu.org; Wed, 10 Jul 2013 10:02:50 -0400 Message-ID: <51DD697C.6010906@kamp.de> Date: Wed, 10 Jul 2013 16:02:36 +0200 From: Peter Lieven MIME-Version: 1.0 References: <1372338695-411-1-git-send-email-pl@kamp.de> <1372338695-411-12-git-send-email-pl@kamp.de> <20130710113829.GL3898@dhcp-200-207.str.redhat.com> In-Reply-To: <20130710113829.GL3898@dhcp-200-207.str.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv2 11/11] iscsi: assert that sectors are aligned to LUN blocksize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: pbonzini@redhat.com, ronniesahlberg@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com Am 10.07.2013 13:38, schrieb Kevin Wolf: > Am 27.06.2013 um 15:11 hat Peter Lieven geschrieben: >> 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. >> >> to avoid corruption we fail requests which are misaligned. >> >> Signed-off-by: Peter Lieven >> --- >> block/iscsi.c | 27 +++++++++++++++++++++++++++ >> 1 file changed, 27 insertions(+) >> >> diff --git a/block/iscsi.c b/block/iscsi.c >> index 0567b46..bff2e1f 100644 >> --- a/block/iscsi.c >> +++ b/block/iscsi.c >> @@ -298,6 +298,13 @@ static int64_t sector_lun2qemu(int64_t sector, IscsiLun *iscsilun) >> return sector * iscsilun->block_size / BDRV_SECTOR_SIZE; >> } >> >> +static int64_t is_request_lun_aligned(int64_t sector_num, int nb_sectors, >> + IscsiLun *iscsilun) > This should certainly return bool instead of int64_t? yes > >> +{ >> + return ((sector_num * BDRV_SECTOR_SIZE) % iscsilun->block_size || >> + (nb_sectors * BDRV_SECTOR_SIZE) % iscsilun->block_size) ? 0 : 1; > 'x ? 0 : 1' is usually written '!x'. ok > > Kevin