From patchwork Mon Jun 7 10:34:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sripathi Kodi X-Patchwork-Id: 104688 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o57AYdKF014106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 7 Jun 2010 10:35:19 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OLZf5-0005I1-HD; Mon, 07 Jun 2010 10:34:31 +0000 Received: from sfi-mx-1.v28.ch3.sourceforge.com ([172.29.28.121] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OLZf4-0005Hv-DH for v9fs-developer@lists.sourceforge.net; Mon, 07 Jun 2010 10:34:30 +0000 Received-SPF: pass (sfi-mx-1.v28.ch3.sourceforge.com: domain of in.ibm.com designates 202.81.31.148 as permitted sender) client-ip=202.81.31.148; envelope-from=sripathik@in.ibm.com; helo=e23smtp06.au.ibm.com; Received: from e23smtp06.au.ibm.com ([202.81.31.148]) by sfi-mx-1.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1OLZf2-0002xo-Pa for v9fs-developer@lists.sourceforge.net; Mon, 07 Jun 2010 10:34:30 +0000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [202.81.31.247]) by e23smtp06.au.ibm.com (8.14.4/8.13.1) with ESMTP id o57AYH2x011735 for ; Mon, 7 Jun 2010 20:34:17 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o57AYKBN1413124 for ; Mon, 7 Jun 2010 20:34:20 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o57AYKlt018981 for ; Mon, 7 Jun 2010 20:34:20 +1000 Received: from localhost ([9.124.35.92]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o57AYIw5018946; Mon, 7 Jun 2010 20:34:19 +1000 Date: Mon, 7 Jun 2010 16:04:17 +0530 From: Sripathi Kodi To: "Aneesh Kumar K. V" Message-ID: <20100607160417.7adfbc2e@in.ibm.com> In-Reply-To: <87r5kly4ta.fsf@linux.vnet.ibm.com> References: <20100528103843.4938.29265.stgit@localhost.localdomain> <87iq61frf7.fsf@linux.vnet.ibm.com> <20100603182902.2551f814@in.ibm.com> <87r5kntd54.fsf@linux.vnet.ibm.com> <4C0914DE.3050800@linux.vnet.ibm.com> <87r5kly4ta.fsf@linux.vnet.ibm.com> X-Mailer: Claws Mail 3.7.4 (GTK+ 2.18.6; i686-redhat-linux-gnu) Mime-Version: 1.0 X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 AWL AWL: From: address is in the auto white-list X-Headers-End: 1OLZf2-0002xo-Pa Cc: v9fs-developer@lists.sourceforge.net, qemu-devel@nongnu.org Subject: Re: [V9fs-developer] [Qemu-devel] Re: [PATCH] virtio-9p: getattr server implementation for 9P2000.L protocol. X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 07 Jun 2010 10:35:29 +0000 (UTC) ============= Fix block size of getattr call. Depends on Mohan's iounit patch. Signed-off-by: Sripathi Kodi --- fs/9p/vfs_inode.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 19067de..c01d33b 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -955,6 +955,8 @@ v9fs_vfs_getattr_dotl(struct vfsmount *mnt, struct dentry *dentry, v9fs_stat2inode_dotl(st, dentry->d_inode); generic_fillattr(dentry->d_inode, stat); + /* Change block size to what the server returned */ + stat->blksize = st->st_blksize; kfree(st); return 0; QEMU patch: =========== Fix block size of getattr call. Depends on Mohan's iounit patch. Signed-off-by: Sripathi Kodi --- hw/virtio-9p.c | 55 +++++++++++++++++++++++++++++++------------------------ hw/virtio-9p.h | 1 + 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index 4843820..d164ad3 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -1180,6 +1180,26 @@ out: qemu_free(vs); } +static int32_t get_iounit(V9fsState *s, V9fsString *name) +{ + struct statfs stbuf; + int32_t iounit = 0; + + /* + * iounit should be multiples of f_bsize (host filesystem block size + * and as well as less than (client msize - P9_IOHDRSZ)) + */ + if (!v9fs_do_statfs(s, name, &stbuf)) { + iounit = stbuf.f_bsize; + iounit *= (s->msize - P9_IOHDRSZ)/stbuf.f_bsize; + } + + if (!iounit) { + iounit = s->msize - P9_IOHDRSZ; + } + return iounit; +} + static void v9fs_getattr_post_lstat(V9fsState *s, V9fsStatStateDotl *vs, int err) { @@ -1188,7 +1208,15 @@ static void v9fs_getattr_post_lstat(V9fsState *s, V9fsStatStateDotl *vs, goto out; } + /* Recalculate block size and number of blocks based on iounit */ stat_to_v9stat_dotl(s, &vs->stbuf, &vs->v9stat_dotl); + vs->v9stat_dotl.st_blksize = get_iounit(s, &vs->fidp->path); + vs->v9stat_dotl.st_blocks = vs->v9stat_dotl.st_size / + vs->v9stat_dotl.st_blksize; + if (vs->v9stat_dotl.st_size % vs->v9stat_dotl.st_blksize) { + vs->v9stat_dotl.st_blocks++; + } + vs->offset += pdu_marshal(vs->pdu, vs->offset, "A", &vs->v9stat_dotl); err = vs->offset; @@ -1202,7 +1230,6 @@ static void v9fs_getattr(V9fsState *s, V9fsPDU *pdu) int32_t fid; V9fsStatStateDotl *vs; ssize_t err = 0; - V9fsFidState *fidp; vs = qemu_malloc(sizeof(*vs)); vs->pdu = pdu; @@ -1212,13 +1239,13 @@ static void v9fs_getattr(V9fsState *s, V9fsPDU *pdu) pdu_unmarshal(vs->pdu, vs->offset, "d", &fid); - fidp = lookup_fid(s, fid); - if (fidp == NULL) { + vs->fidp = lookup_fid(s, fid); + if (vs->fidp == NULL) { err = -ENOENT; goto out; } - err = v9fs_do_lstat(s, &fidp->path, &vs->stbuf); + err = v9fs_do_lstat(s, &vs->fidp->path, &vs->stbuf); v9fs_getattr_post_lstat(s, vs, err); return; @@ -1390,26 +1417,6 @@ out: v9fs_walk_complete(s, vs, err); } -static int32_t get_iounit(V9fsState *s, V9fsString *name) -{ - struct statfs stbuf; - int32_t iounit = 0; - - /* - * iounit should be multiples of f_bsize (host filesystem block size - * and as well as less than (client msize - P9_IOHDRSZ)) - */ - if (!v9fs_do_statfs(s, name, &stbuf)) { - iounit = stbuf.f_bsize; - iounit *= (s->msize - P9_IOHDRSZ)/stbuf.f_bsize; - } - - if (!iounit) { - iounit = s->msize - P9_IOHDRSZ; - } - return iounit; -} - static void v9fs_open_post_opendir(V9fsState *s, V9fsOpenState *vs, int err) { if (vs->fidp->dir == NULL) { diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h index 700666a..6b09b4b 100644 --- a/hw/virtio-9p.h +++ b/hw/virtio-9p.h @@ -211,6 +211,7 @@ typedef struct V9fsStatDotl { typedef struct V9fsStatStateDotl { V9fsPDU *pdu; size_t offset; + V9fsFidState *fidp; V9fsStatDotl v9stat_dotl; struct stat stbuf; } V9fsStatStateDotl;