From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9zyM-000354-9N for qemu-devel@nongnu.org; Sun, 02 Feb 2014 11:33:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9zts-0001rP-EM for qemu-devel@nongnu.org; Sun, 02 Feb 2014 11:32:42 -0500 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:57692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9ztr-0001r5-Je for qemu-devel@nongnu.org; Sun, 02 Feb 2014 11:28:04 -0500 Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 3 Feb 2014 02:27:58 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 79FD52CE8051 for ; Mon, 3 Feb 2014 03:27:56 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s12G8dHl4981242 for ; Mon, 3 Feb 2014 03:08:40 +1100 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s12GRtY7026142 for ; Mon, 3 Feb 2014 03:27:55 +1100 From: "Aneesh Kumar K.V" In-Reply-To: <1390921707-15109-4-git-send-email-kirill.shutemov@linux.intel.com> References: <1390921707-15109-1-git-send-email-kirill.shutemov@linux.intel.com> <1390921707-15109-4-git-send-email-kirill.shutemov@linux.intel.com> Date: Sun, 02 Feb 2014 21:57:51 +0530 Message-ID: <87ha8h4gzc.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 4/4] hw/9pfs: fix P9_STATS_GEN handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Kirill A. Shutemov" , qemu-devel@nongnu.org, aliguori@amazon.com, mst@redhat.com Cc: armbru@redhat.com "Kirill A. Shutemov" writes: > Currently we fail getattr request altogether if we can't read > P9_STATS_GEN for some reason. It breaks valid use cases: > > E.g let's assume we have non-readable directory with execution bit set > on host and we export it to client over 9p On host we can chdir into > directory, but not open directory on read and list content. > > But if client will try to call getattr (as part of chdir(2)) for the > directory it will fail with -EACCES. It happens because we try to open > the directory on read to call ioctl(FS_IOC_GETVERSION), it fails and we > return the error code to client. > > It's excessive. The solution is to make P9_STATS_GEN failure non-fatal > for getattr request. Just don't set P9_STATS_GEN flag in result mask on > failure. > > Signed-off-by: Kirill A. Shutemov Reviewed-by: Aneesh Kumar K.V > --- > hw/9pfs/cofile.c | 4 ---- > hw/9pfs/virtio-9p.c | 12 ++++++++++-- > 2 files changed, 10 insertions(+), 6 deletions(-) > > diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c > index 194c1306c665..2efebf35710f 100644 > --- a/hw/9pfs/cofile.c > +++ b/hw/9pfs/cofile.c > @@ -38,10 +38,6 @@ int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t st_mode, > }); > v9fs_path_unlock(s); > } > - /* The ioctl may not be supported depending on the path */ > - if (err == -ENOTTY) { > - err = 0; > - } > return err; > } > > diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c > index 8cbb8ae32a03..83e4e9398347 100644 > --- a/hw/9pfs/virtio-9p.c > +++ b/hw/9pfs/virtio-9p.c > @@ -1080,10 +1080,18 @@ static void v9fs_getattr(void *opaque) > /* fill st_gen if requested and supported by underlying fs */ > if (request_mask & P9_STATS_GEN) { > retval = v9fs_co_st_gen(pdu, &fidp->path, stbuf.st_mode, &v9stat_dotl); > - if (retval < 0) { > + switch (retval) { > + case 0: > + /* we have valid st_gen: update result mask */ > + v9stat_dotl.st_result_mask |= P9_STATS_GEN; > + break; > + case -EINTR: > + /* request cancelled, e.g. by Tflush */ > goto out; > + default: > + /* failed to get st_gen: not fatal, ignore */ > + break; > } > - v9stat_dotl.st_result_mask |= P9_STATS_GEN; > } > retval = pdu_marshal(pdu, offset, "A", &v9stat_dotl); > if (retval < 0) { > -- > 1.8.5.2