* [Qemu-devel] [PATCH 2/2] [block]: Skip refresh_total_sectors() for scsi-generic devices
@ 2010-05-15 13:30 Nicholas A. Bellinger
2010-05-16 13:30 ` [Qemu-devel] " Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Nicholas A. Bellinger @ 2010-05-15 13:30 UTC (permalink / raw)
To: Kevin Wolf, Christoph Hellwig, Gerd Hoffmann, Hannes Reinecke,
kvm-devel, qemu-devel
Cc: Nicholas Bellinger
From: Nicholas Bellinger <nab@linux-iscsi.org>
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.
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
block.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index 02a22f6..1053161 100644
--- a/block.c
+++ b/block.c
@@ -444,10 +444,15 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename,
}
bs->keep_read_only = bs->read_only = !(open_flags & BDRV_O_RDWR);
-
- ret = refresh_total_sectors(bs, bs->total_sectors);
- if (ret < 0) {
- goto free_and_fail;
+ /*
+ * For scsi-generic devices, do not call refresh_total_sectors() -> raw_getlength()
+ * because lseek() will return -ESPIPE.
+ */
+ if (!(bs->sg)) {
+ ret = refresh_total_sectors(bs, bs->total_sectors);
+ if (ret < 0) {
+ goto free_and_fail;
+ }
}
#ifndef _WIN32
--
1.5.6.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] Re: [PATCH 2/2] [block]: Skip refresh_total_sectors() for scsi-generic devices
2010-05-15 13:30 [Qemu-devel] [PATCH 2/2] [block]: Skip refresh_total_sectors() for scsi-generic devices Nicholas A. Bellinger
@ 2010-05-16 13:30 ` Christoph Hellwig
2010-05-17 1:53 ` Nicholas A. Bellinger
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2010-05-16 13:30 UTC (permalink / raw)
To: Nicholas A. Bellinger
Cc: Kevin Wolf, kvm-devel, qemu-devel, Hannes Reinecke,
Christoph Hellwig, Gerd Hoffmann
On Sat, May 15, 2010 at 06:30:59AM -0700, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
>
> 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?
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] Re: [PATCH 2/2] [block]: Skip refresh_total_sectors() for scsi-generic devices
2010-05-16 13:30 ` [Qemu-devel] " Christoph Hellwig
@ 2010-05-17 1:53 ` Nicholas A. Bellinger
0 siblings, 0 replies; 3+ messages in thread
From: Nicholas A. Bellinger @ 2010-05-17 1:53 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Kevin Wolf, qemu-devel, Gerd Hoffmann, kvm-devel, Hannes Reinecke
[-- Attachment #1: Type: text/plain, Size: 916 bytes --]
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 <nab@linux-iscsi.org>
> >
> > 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
[-- Attachment #2: 0002--block-Add-SG_IO-device-check-in-refresh_total_sec.patch --]
[-- Type: application/mbox, Size: 1119 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-17 1:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-15 13:30 [Qemu-devel] [PATCH 2/2] [block]: Skip refresh_total_sectors() for scsi-generic devices Nicholas A. Bellinger
2010-05-16 13:30 ` [Qemu-devel] " Christoph Hellwig
2010-05-17 1:53 ` Nicholas A. Bellinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).