From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Aneesh Kumar K.V" Subject: Re: [PATCH 2/2] hw/9pfs: fix alignment issue when host filesystem block size is larger than client msize Date: Sun, 14 Feb 2016 19:08:48 +0530 Message-ID: <87y4an8l93.fsf@linux.vnet.ibm.com> References: <56C02E4F.6030303@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <56C02E4F.6030303@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org To: Jevon Qiao , qemu-devel@nongnu.org, "ceph-devel@vger.kernel.org" Cc: sage@newdream.net, haomaiwang@gmail.com, gkurz@linux.vnet.ibm.com, gfarnum@redhat.com, mst@redhat.com List-Id: ceph-devel.vger.kernel.org Jevon Qiao writes: > The following patch is to fix alignment issue when host filesystem block > size > is larger than client msize. > > Thanks, > Jevon That is not the right format to send patch. You can send them as a series using git-send-email. > > From: Jevon Qiao > Date: Sun, 14 Feb 2016 15:11:08 +0800 > Subject: [PATCH] hw/9pfs: fix alignment issue when host filesystem block > size > is larger than client msize. > > Per the previous implementation, iounit will be assigned to be 0 after the > first if statement as (s->msize - P9_IOHDRSZ)/stbuf.f_bsize will be zero > when > host filesystem block size is larger than msize. Finally, iounit will be > equal > to s->msize - P9_IOHDRSZ, which is usually not aligned. > > Signed-off-by: Jevon Qiao > --- > hw/9pfs/virtio-9p.c | 19 ++++++++++++++++--- > 1 file changed, 16 insertions(+), 3 deletions(-) > > diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c > index f972731..005d3a8 100644 > --- a/hw/9pfs/virtio-9p.c > +++ b/hw/9pfs/virtio-9p.c > @@ -1326,7 +1326,7 @@ out_nofid: > static int32_t get_iounit(V9fsPDU *pdu, V9fsPath *path) > { > struct statfs stbuf; > - int32_t iounit = 0; > + int32_t iounit = 0, unit = 0; > V9fsState *s = pdu->s; > > /* > @@ -1334,8 +1334,21 @@ static int32_t get_iounit(V9fsPDU *pdu, V9fsPath > *path) > * and as well as less than (client msize - P9_IOHDRSZ)) > */ > if (!v9fs_co_statfs(pdu, path, &stbuf)) { > - iounit = stbuf.f_bsize; > - iounit *= (s->msize - P9_IOHDRSZ)/stbuf.f_bsize; > + /* > + * If host filesystem block size is larger than client msize, > + * we will use PAGESIZE as the unit. The reason why we choose > + * PAGESIZE is because the data will be splitted in terms of > + * PAGESIZE in the virtio layer. In this case, the final > + * iounit is equal to the value of ((msize/unit) - 1) * unit. > + */ > + if (stbuf.f_bsize > s->msize) { > + iounit = 4096; > + unit = 4096; What page size it should be guest or host ?. Also why 4096 ?. ppc64 use 64K page size. > + } else { > + iounit = stbuf.f_bsize; > + unit = stbuf.f_bsize; > + } > + iounit *= (s->msize - P9_IOHDRSZ)/unit; > } > if (!iounit) { > iounit = s->msize - P9_IOHDRSZ; > -- -aneesh From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUwtA-0003hl-Tt for qemu-devel@nongnu.org; Sun, 14 Feb 2016 08:39:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUwt7-000663-Lt for qemu-devel@nongnu.org; Sun, 14 Feb 2016 08:39:00 -0500 Received: from e32.co.us.ibm.com ([32.97.110.150]:34544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUwt7-00065z-FK for qemu-devel@nongnu.org; Sun, 14 Feb 2016 08:38:57 -0500 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 14 Feb 2016 06:38:56 -0700 Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id B2ADC19D8040 for ; Sun, 14 Feb 2016 06:26:51 -0700 (MST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u1EDcr3U31326404 for ; Sun, 14 Feb 2016 13:38:53 GMT Received: from d01av01.pok.ibm.com (localhost [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u1EDcqke020090 for ; Sun, 14 Feb 2016 08:38:53 -0500 From: "Aneesh Kumar K.V" In-Reply-To: <56C02E4F.6030303@gmail.com> References: <56C02E4F.6030303@gmail.com> Date: Sun, 14 Feb 2016 19:08:48 +0530 Message-ID: <87y4an8l93.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 2/2] hw/9pfs: fix alignment issue when host filesystem block size is larger than client msize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jevon Qiao , qemu-devel@nongnu.org, "ceph-devel@vger.kernel.org" Cc: sage@newdream.net, haomaiwang@gmail.com, gkurz@linux.vnet.ibm.com, gfarnum@redhat.com, mst@redhat.com Jevon Qiao writes: > The following patch is to fix alignment issue when host filesystem block > size > is larger than client msize. > > Thanks, > Jevon That is not the right format to send patch. You can send them as a series using git-send-email. > > From: Jevon Qiao > Date: Sun, 14 Feb 2016 15:11:08 +0800 > Subject: [PATCH] hw/9pfs: fix alignment issue when host filesystem block > size > is larger than client msize. > > Per the previous implementation, iounit will be assigned to be 0 after the > first if statement as (s->msize - P9_IOHDRSZ)/stbuf.f_bsize will be zero > when > host filesystem block size is larger than msize. Finally, iounit will be > equal > to s->msize - P9_IOHDRSZ, which is usually not aligned. > > Signed-off-by: Jevon Qiao > --- > hw/9pfs/virtio-9p.c | 19 ++++++++++++++++--- > 1 file changed, 16 insertions(+), 3 deletions(-) > > diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c > index f972731..005d3a8 100644 > --- a/hw/9pfs/virtio-9p.c > +++ b/hw/9pfs/virtio-9p.c > @@ -1326,7 +1326,7 @@ out_nofid: > static int32_t get_iounit(V9fsPDU *pdu, V9fsPath *path) > { > struct statfs stbuf; > - int32_t iounit = 0; > + int32_t iounit = 0, unit = 0; > V9fsState *s = pdu->s; > > /* > @@ -1334,8 +1334,21 @@ static int32_t get_iounit(V9fsPDU *pdu, V9fsPath > *path) > * and as well as less than (client msize - P9_IOHDRSZ)) > */ > if (!v9fs_co_statfs(pdu, path, &stbuf)) { > - iounit = stbuf.f_bsize; > - iounit *= (s->msize - P9_IOHDRSZ)/stbuf.f_bsize; > + /* > + * If host filesystem block size is larger than client msize, > + * we will use PAGESIZE as the unit. The reason why we choose > + * PAGESIZE is because the data will be splitted in terms of > + * PAGESIZE in the virtio layer. In this case, the final > + * iounit is equal to the value of ((msize/unit) - 1) * unit. > + */ > + if (stbuf.f_bsize > s->msize) { > + iounit = 4096; > + unit = 4096; What page size it should be guest or host ?. Also why 4096 ?. ppc64 use 64K page size. > + } else { > + iounit = stbuf.f_bsize; > + unit = stbuf.f_bsize; > + } > + iounit *= (s->msize - P9_IOHDRSZ)/unit; > } > if (!iounit) { > iounit = s->msize - P9_IOHDRSZ; > -- -aneesh