From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Nicholas A. Bellinger" Subject: Re: [PATCH 2/2] [block]: Skip refresh_total_sectors() for scsi-generic devices Date: Sun, 16 May 2010 18:53:54 -0700 Message-ID: <1274061234.7348.19.camel@haakon2.linux-iscsi.org> References: <1273930259-12694-1-git-send-email-nab@linux-iscsi.org> <20100516133022.GB27075@lst.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-TQkD3mXueGypiNN/4dF4" Cc: Kevin Wolf , Gerd Hoffmann , Hannes Reinecke , kvm-devel , qemu-devel To: Christoph Hellwig Return-path: Received: from smtp126.sbc.mail.sp1.yahoo.com ([69.147.65.185]:29950 "HELO smtp126.sbc.mail.sp1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751945Ab0EQByA (ORCPT ); Sun, 16 May 2010 21:54:00 -0400 In-Reply-To: <20100516133022.GB27075@lst.de> Sender: kvm-owner@vger.kernel.org List-ID: --=-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--