From patchwork Wed May 25 14:18:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 626194 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 3rFDtx3s6Hz9s9N for ; Thu, 26 May 2016 00:19:53 +1000 (AEST) Received: from localhost ([::1]:33238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Zf5-0008Vm-Bu for incoming@patchwork.ozlabs.org; Wed, 25 May 2016 10:19:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Ze9-0007gF-MN for qemu-devel@nongnu.org; Wed, 25 May 2016 10:18:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5Ze4-00020T-JO for qemu-devel@nongnu.org; Wed, 25 May 2016 10:18:52 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:59942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Ze4-0001yr-9B for qemu-devel@nongnu.org; Wed, 25 May 2016 10:18:48 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 May 2016 15:18:43 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 25 May 2016 15:18:38 +0100 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: gkurz@linux.vnet.ibm.com X-IBM-RcptTo: ericvh@gmail.com; lucho@ionkov.net; v9fs-developer@lists.sourceforge.net; qemu-devel@nongnu.org; rminnich@sandia.gov; seany@seanyseansean.com Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4F7C22190056; Wed, 25 May 2016 15:18:12 +0100 (BST) Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u4PEIcq57799204; Wed, 25 May 2016 14:18:38 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 788555203F; Wed, 25 May 2016 14:16:38 +0100 (BST) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 5576E52036; Wed, 25 May 2016 14:16:38 +0100 (BST) Received: from bahia.huguette.org (icon-9-164-163-22.megacenter.de.ibm.com [9.164.163.22]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 718BE220435; Wed, 25 May 2016 16:18:36 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 16:18:35 +0200 Message-ID: <146418539999.31132.7141368831414401393.stgit@bahia.huguette.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16052514-0021-0000-0000-00003BFB6ACE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.111 Subject: [Qemu-devel] [PATCH] 9p: getattr: use fstat if we have a fd X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lucho@ionkov.net, ericvh@gmail.com, "Aneesh Kumar K.V" , rminnich@sandia.gov, v9fs-developer@lists.sourceforge.net, seany@seanyseansean.com, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If we have an opened fd, it is better to call fstat() as the underlying file may have been unlinked and lstat() will fail. Signed-off-by: Greg Kurz --- This QEMU patch goes with the create-unlink-getattr fix at: http://git.kernel.org/cgit/linux/kernel/git/ericvh/v9fs.git/commit/?id=5eb393c464294b2183d526a25a344d7ae6ba8383 I could verify that a basic program doing open(O_CREAT)+unlink()+fstat() in the guest works as expected. Eric (or other v9fs maintainers), Is there a chance the above kernel patch gets pushed upstream in a near future ? Cheers. -- Greg hw/9pfs/9p.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 482a35ead51b..572aaf09930b 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1103,7 +1103,11 @@ static void v9fs_getattr(void *opaque) * Currently we only support BASIC fields in stat, so there is no * need to look at request_mask. */ - retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf); + if (fidp->fs.fd > 0) { + retval = v9fs_co_fstat(pdu, fidp, &stbuf); + } else { + retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf); + } if (retval < 0) { goto out; }