From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53347 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ODpWs-0003WX-7Y for qemu-devel@nongnu.org; Sun, 16 May 2010 21:54:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ODpWq-0003df-Mn for qemu-devel@nongnu.org; Sun, 16 May 2010 21:54:02 -0400 Received: from smtp126.sbc.mail.sp1.yahoo.com ([69.147.65.185]:29943) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1ODpWq-0003dY-8v for qemu-devel@nongnu.org; Sun, 16 May 2010 21:54:00 -0400 From: "Nicholas A. Bellinger" In-Reply-To: <20100516133022.GB27075@lst.de> References: <1273930259-12694-1-git-send-email-nab@linux-iscsi.org> <20100516133022.GB27075@lst.de> Content-Type: multipart/mixed; boundary="=-TQkD3mXueGypiNN/4dF4" Date: Sun, 16 May 2010 18:53:54 -0700 Message-Id: <1274061234.7348.19.camel@haakon2.linux-iscsi.org> Mime-Version: 1.0 Subject: [Qemu-devel] Re: [PATCH 2/2] [block]: Skip refresh_total_sectors() for scsi-generic devices List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoph Hellwig Cc: Kevin Wolf , qemu-devel , Gerd Hoffmann , kvm-devel , Hannes Reinecke --=-TQkD3mXueGypiNN/4dF4 Content-Type: text/plain Content-Transfer-Encoding: 7bit On Sun, 2010-05-16 at 15:30 +0200, Christoph Hellwig wrote: > On Sat, May 15, 2010 at 06:30:59AM -0700, Nicholas A. Bellinger wrote: > > From: Nicholas Bellinger > > > > This patch adds a BlockDriverState->sg check in block.c:bdrv_common_open() > > to skip the new refresh_total_sectors() call once we know we are working with > > a scsi-generic device. > > > > We go ahead and skip this call for scsi-generic devices because > > block/raw-posix.c:raw_getlength() -> lseek() will return -ESPIPE. > > How about moving that check into refresh_total_sectors? Sounds good, attached is updated patch #2: [PATCH 2/2] [block]: Add SG_IO device check in refresh_total_sectors() Also, I am using the options in .vimrc to follow QEMU's indent style: set smartindent set tabstop=4 set shiftwidth=4 set expandtab I assume this is what should be used when sending QEMU patches, yes..? Best, --nab --=-TQkD3mXueGypiNN/4dF4 Content-Disposition: attachment; filename=0002--block-Add-SG_IO-device-check-in-refresh_total_sec.patch Content-Type: application/mbox; name=0002--block-Add-SG_IO-device-check-in-refresh_total_sec.patch Content-Transfer-Encoding: 7bit >>From 8f4cbec758867e51839d2f3f270fc06907a97dd5 Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Sun, 16 May 2010 18:28:35 -0700 Subject: [PATCH 2/2] [block]: Add SG_IO device check in refresh_total_sectors() This patch adds a special case check for scsi-generic devices in refresh_total_sectors() to skip the subsequent BlockDriver->bdrv_getlength() that will be returning -ESPIPE from block/raw-posic.c:raw_getlength() for BlockDriverState->sg=1 devices. Signed-off-by: Nicholas A. Bellinger --- block.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index f419ee6..7917712 100644 --- a/block.c +++ b/block.c @@ -364,6 +364,10 @@ static int refresh_total_sectors(BlockDriverState *bs, int64_t hint) { BlockDriver *drv = bs->drv; + /* Do not attempt drv->bdrv_getlength() on scsi-generic devices */ + if (bs->sg) + return 0; + /* query actual device if possible, otherwise just trust the hint */ if (drv->bdrv_getlength) { int64_t length = drv->bdrv_getlength(bs); -- 1.5.6.5 --=-TQkD3mXueGypiNN/4dF4--