From patchwork Sat May 15 13:30:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 99797 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4F57iRC002806 for ; Sat, 15 May 2010 05:07:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751454Ab0EOFHl (ORCPT ); Sat, 15 May 2010 01:07:41 -0400 Received: from smtp128.sbc.mail.sp1.yahoo.com ([69.147.65.187]:26893 "HELO smtp128.sbc.mail.sp1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751281Ab0EOFHl (ORCPT ); Sat, 15 May 2010 01:07:41 -0400 Received: (qmail 20578 invoked from network); 15 May 2010 05:07:40 -0000 Received: from adsl-70-231-246-220.dsl.snfc21.sbcglobal.net (nab@70.231.246.220 with login) by smtp128.sbc.mail.sp1.yahoo.com with SMTP; 14 May 2010 22:07:40 -0700 PDT X-Yahoo-SMTP: fzDSGlOswBCWnIOrNw7KwwK1j9PqyNbe5PtLKiS4dDU.UNl_t6bdEZu9tTLW X-YMail-OSG: WiFzkwkVM1lSgS_Frc4KKipAbvlaLpH1Hgxbpup7cZen03oiWJ9zp_TQzYtRaLcwR5veJK6m6UTbvrnw_CbYPi6Zf_.Mb7tBlkjp.Qj8l1BC1cpyq8tgx8gMIsQ3e.9SBknFjIqIubM53ixsxPXfmtJ_qmlQqv4XIzYP5QCIhdhtuF16cBNL.ROyEeUXI5Cgz9Ixjnu1eA7cuaSHHqpnZuVr1tetyERjuZSVC7Y92lK5Hty7JA7Xvu3t7_2KL7a8iZTxRYHxcQID2jsnjliizCah95LUz6k0OWjy9XnqA4TYO05S544rS.7XpKhI1rxIQGa78Nok4b7SaAG9VjnQF2dvCsPYOQU6jnpoGyeX81xkZg-- X-Yahoo-Newman-Property: ymail-3 From: "Nicholas A. Bellinger" To: Kevin Wolf , Christoph Hellwig , Gerd Hoffmann , Hannes Reinecke , kvm-devel , qemu-devel Cc: Nicholas Bellinger Subject: [PATCH 2/2] [block]: Skip refresh_total_sectors() for scsi-generic devices Date: Sat, 15 May 2010 06:30:59 -0700 Message-Id: <1273930259-12694-1-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.5.6.5 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 15 May 2010 05:07:44 +0000 (UTC) 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