Received: from eggs.gnu.org ([208.118.235.92]:58288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhvTz-00044O-9K for qemu-devel@nongnu.org; Thu, 30 May 2013 01:33:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhvTu-0007M4-78 for qemu-devel@nongnu.org; Thu, 30 May 2013 01:33:03 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:33582 helo=linux-iscsi.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhvTu-0007Lb-0N for qemu-devel@nongnu.org; Thu, 30 May 2013 01:32:58 -0400 Message-ID: <1369892185.7364.134.camel@haakon3.risingtidesystems.com> From: "Nicholas A. Bellinger" Date: Wed, 29 May 2013 22:36:25 -0700 In-Reply-To: <1369888147.7364.124.camel@haakon3.risingtidesystems.com> References: <1366381460-6041-1-git-send-email-pbonzini@redhat.com> <1366381460-6041-7-git-send-email-pbonzini@redhat.com> <51A4590F.90503@linux.vnet.ibm.com> <51A4644A.6070002@redhat.com> <20130528083352.GA19799@hj.localdomain> <51A47244.9050203@linux.vnet.ibm.com> <51A5C4DB.9040307@linux.vnet.ibm.com> <51A61A74.7050508@us.ibm.com> <20130529221721.GC19601@hj.localdomain> <1369888147.7364.124.camel@haakon3.risingtidesystems.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the tcm_vhost Linux kernel module List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Asias He Cc: Anthony Liguori , "Michael S. Tsirkin" , qemu-devel@nongnu.org, target-devel , Badari Pulavarty , Paolo Bonzini , Wenchao Xia On Wed, 2013-05-29 at 21:29 -0700, Nicholas A. Bellinger wrote: > On Thu, 2013-05-30 at 06:17 +0800, Asias He wrote: > > On Wed, May 29, 2013 at 08:10:44AM -0700, Badari Pulavarty wrote: > > > On 05/29/2013 02:05 AM, Wenchao Xia wrote: > > > >=E4=BA=8E 2013-5-28 17:00, Wenchao Xia =E5=86=99=E9=81=93: >=20 > >=20 > > > > I have done a basic test of vhost-scsi, following is the result = I'd > > > >like to post, generally it seems fine: > > > > > > > >Result: > > > > fdisk/mkfs: fdisk can find it, mke2fs works fine. > > > > mount: can mount it. > > > > file I/O: dd 90M zero to a file in that disk succeed. > > >=20 > > >=20 > > >=20 > > > I tried without nested kvm. > > >=20 > > > > > > > >Issues: > > > > 1) in fdisk -l, sometime timeout with dmesg "end_request: I/O er= ror, > > > >dev fd0, sector 0", I guess it is caused by nested KVM that faile= d > > > >to kick host kernel? > > >=20 > > >=20 > > > I don't see this issue. Are you sure "fd0" is actually the scsi dev= ice ? > > > what is "fd0" ? > > >=20 > > > > 2) in fdisk -l, it shows 512 bytes larger than the parameter I > > > >specified in fd_dev_size parameter in configfs on host.(shows > > > >104858112 bytes, see the invocation script below) > > > > > > >=20 > > > I see the same. For some reason "fdisk -l" in the VM shows > > > 512-bytes more than the actual size for the file (on the host). > >=20 > > Hmm, interesting. Will look into it. > >=20 > > Nick, Any ideas here? > >=20 >=20 > Mmm, fd_get_blocks() is not returning the expected minus one logical > blocks with a !S_ISBLK() setup. >=20 > This is happening for every other backend ->get_blocks() call already, > and should be happening for the fd_dev_size case as well. >=20 > Applying the following to target-pending.git now. >=20 Actually sorry, that last patch is not correct.. Here's a better one to properly set fd_dev->fd_block_size at configure time, and use dev_attrib.block_size in fd_get_blocks() to allow for user defined block_sizes. Thanks, --nab commit 9e309f9307fe644dee8718980bfcb77de91ce38e Author: Nicholas Bellinger Date: Wed May 29 21:35:23 2013 -0700 target/file: Fix off-by-one READ_CAPACITY bug for !S_ISBLK export =20 This patch fixes a bug where FILEIO was incorrectly reporting the num= ber of logical blocks (+ 1) when using non struct block_device export mod= e. =20 It changes fd_get_blocks() to follow all other backend ->get_blocks()= cases, and reduces the calculated dev_size by one dev->dev_attrib.block_size number of bytes, and fixes the initial block_size assignment within fd_configure_device() =20 Reported-by: Wenchao Xia Reported-by: Badari Pulavarty Signed-off-by: Nicholas Bellinger diff --git a/drivers/target/target_core_file.c b/drivers/target/target_co= re_file.c index 1b1d544..b11890d 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -153,6 +153,7 @@ static int fd_configure_device(struct se_device *dev) struct request_queue *q =3D bdev_get_queue(inode->i_bdev)= ; unsigned long long dev_size; =20 + fd_dev->fd_block_size =3D bdev_logical_block_size(inode->= i_bdev); /* * Determine the number of bytes from i_size_read() minus * one (1) logical sector from underlying struct block_de= vice @@ -199,6 +200,7 @@ static int fd_configure_device(struct se_device *dev) goto fail; } =20 + fd_dev->fd_block_size =3D FD_BLOCKSIZE; /* * Limit UNMAP emulation to 8k Number of LBAs (NoLB) */ @@ -217,9 +219,7 @@ static int fd_configure_device(struct se_device *dev) dev->dev_attrib.max_write_same_len =3D 0x1000; } =20 - fd_dev->fd_block_size =3D dev->dev_attrib.hw_block_size; - - dev->dev_attrib.hw_block_size =3D FD_BLOCKSIZE; + dev->dev_attrib.hw_block_size =3D fd_dev->fd_block_size; dev->dev_attrib.hw_max_sectors =3D FD_MAX_SECTORS; dev->dev_attrib.hw_queue_depth =3D FD_MAX_DEVICE_QUEUE_DEPTH; =20 @@ -694,11 +694,12 @@ static sector_t fd_get_blocks(struct se_device *dev= ) * to handle underlying block_device resize operations. */ if (S_ISBLK(i->i_mode)) - dev_size =3D (i_size_read(i) - fd_dev->fd_block_size); + dev_size =3D i_size_read(i); else dev_size =3D fd_dev->fd_dev_size; =20 - return div_u64(dev_size, dev->dev_attrib.block_size); + return div_u64(dev_size - dev->dev_attrib.block_size, + dev->dev_attrib.block_size); } =20 static struct sbc_ops fd_sbc_ops =3D {