From patchwork Sun Feb 14 07:35:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jevon Qiao X-Patchwork-Id: 582467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D4CD3140662 for ; Sun, 14 Feb 2016 18:36:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=mfBRZG3j; dkim-atps=neutral Received: from localhost ([::1]:48356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUrEC-0000fK-VR for incoming@patchwork.ozlabs.org; Sun, 14 Feb 2016 02:36:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUrDx-0000NI-A8 for qemu-devel@nongnu.org; Sun, 14 Feb 2016 02:36:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUrDu-0001Pq-4G for qemu-devel@nongnu.org; Sun, 14 Feb 2016 02:36:05 -0500 Received: from mail-pa0-x241.google.com ([2607:f8b0:400e:c03::241]:35922) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUrDt-0001Pm-Sr for qemu-devel@nongnu.org; Sun, 14 Feb 2016 02:36:02 -0500 Received: by mail-pa0-x241.google.com with SMTP id y7so962044paa.3 for ; Sat, 13 Feb 2016 23:36:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-type:content-transfer-encoding; bh=XVX+m8aKERYiUPUBA3zbh9M8+OUNGesm1TIIcWnGvEo=; b=mfBRZG3jGkfpUfTvJUAJwcpEQQ2CsVfLryypoWj62bwgvnS4uCDjAo1TEhPY2l5hIq eTdWSR37DjJOiypb37VGTRCylDj4ygOHdKHngthW5qObB+ZBMjoVBUrQUHl8xyoASn0N UY3mOxmp80C4r/WH65MaGf2lLK+9fG9a3Eet6b9a6+cqT0HgIfhsR0WMZcaOcLSgwYNd vcprFwSNbR2bJd1oxJukxqZvERCIg68Jaz9Wvs2zfCe3GgojaniTg5szbVjKJe89pTMz /HxQ25LJ6/4vJ/B5KoKWQ6jzSrCoZqjyWStaTLvPCc5s6jgMh/zMoNuxVDfZhjs+Iy/U /cBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-type:content-transfer-encoding; bh=XVX+m8aKERYiUPUBA3zbh9M8+OUNGesm1TIIcWnGvEo=; b=M2zjqDOcXACLdocz1emi+WDlH+PLhOXKetpHn4G45D2DtdqNY1FspC9kInpAT1LBpD vlORirCqxfaGAgEtKEMvUyV+GmZFg3v/z7xPvz/N7beEfnTxd9dBZibyecDOBV/a1EAi Anduj+N0FxvTjk/FAzA3Jyk+SHr9GSya110BxOy2c8tYfwanY3EPpzvLqezmnjeW5L2i iI/rq/bcgi9C5wMQ02axCA8eZG238eEfSsZZ9V9683wASdYtPye0V55Tv8JDrzCnz0TQ yqJUEZbRVP35PsHfYv+7tQpXEzWyL6dOIQ5LmPq1qwQ7nGX+rmL97RQ45zlufGHMT1At v5gQ== X-Gm-Message-State: AG10YOT8rjucTEhFfp8gY9m23FbkuI52kdlg5YpwaHg3ES0V2IbzBbusphRSegPBn3Iszw== X-Received: by 10.66.166.42 with SMTP id zd10mr14643013pab.159.1455435361085; Sat, 13 Feb 2016 23:36:01 -0800 (PST) Received: from Jevons-MacBook-Pro.local ([45.63.16.152]) by smtp.gmail.com with ESMTPSA id to9sm30161447pab.3.2016.02.13.23.35.49 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 13 Feb 2016 23:36:00 -0800 (PST) To: qemu-devel@nongnu.org, "ceph-devel@vger.kernel.org" From: Jevon Qiao Message-ID: <56C02E4F.6030303@gmail.com> Date: Sun, 14 Feb 2016 15:35:43 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::241 Cc: haomaiwang@gmail.com, mst@redhat.com, aneesh.kumar@linux.vnet.ibm.com, sage@newdream.net, gfarnum@redhat.com, gkurz@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 2/2] hw/9pfs: fix alignment issue when host filesystem block size is larger than client msize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The following patch is to fix alignment issue when host filesystem block size is larger than client msize. Thanks, Jevon 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(-) iounit = s->msize - P9_IOHDRSZ; -- 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; + } else { + iounit = stbuf.f_bsize; + unit = stbuf.f_bsize; + } + iounit *= (s->msize - P9_IOHDRSZ)/unit; } if (!iounit) {