From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
qemu-devel@nongnu.org, aliguori@amazon.com, mst@redhat.com
Cc: armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/4] hw/9pfs: fix P9_STATS_GEN handling
Date: Sun, 02 Feb 2014 21:57:51 +0530 [thread overview]
Message-ID: <87ha8h4gzc.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1390921707-15109-4-git-send-email-kirill.shutemov@linux.intel.com>
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> 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 <kirill.shutemov@linux.intel.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
> 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
next prev parent reply other threads:[~2014-02-02 16:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-28 15:08 [Qemu-devel] [PATCH 1/4] hw/9pfs: fix error handing in local_ioc_getversion() Kirill A. Shutemov
2014-01-28 15:08 ` [Qemu-devel] [PATCH 2/4] hw/9pfs: handle undefined FS_IOC_GETVERSION case in handle_ioc_getversion() Kirill A. Shutemov
2014-02-02 16:20 ` Aneesh Kumar K.V
2014-01-28 15:08 ` [Qemu-devel] [PATCH 3/4] hw/9pfs: make get_st_gen() return ENOTTY error on special files Kirill A. Shutemov
2014-02-02 16:28 ` Aneesh Kumar K.V
2014-01-28 15:08 ` [Qemu-devel] [PATCH 4/4] hw/9pfs: fix P9_STATS_GEN handling Kirill A. Shutemov
2014-02-02 16:27 ` Aneesh Kumar K.V [this message]
2014-02-02 16:20 ` [Qemu-devel] [PATCH 1/4] hw/9pfs: fix error handing in local_ioc_getversion() Aneesh Kumar K.V
[not found] ` <878utx5tw1.fsf@linux.vnet.ibm.com>
[not found] ` <87bnyp4e7k.fsf@linux.vnet.ibm.com>
2014-02-02 21:32 ` [Qemu-devel] 9pfs troubles (was Re: [PATCH 1/4] hw/9pfs: fix error handing in local_ioc_getversion()) Michael S. Tsirkin
2014-02-03 9:35 ` Aneesh Kumar K.V
2014-02-03 11:03 ` Michael S. Tsirkin
2014-02-04 7:21 ` Aneesh Kumar K.V
2014-02-05 21:31 ` Michael S. Tsirkin
2014-02-06 12:58 ` Aneesh Kumar K.V
2014-02-06 13:24 ` Michael S. Tsirkin
2014-02-07 9:02 ` Greg Kurz
2014-02-09 12:05 ` Michael S. Tsirkin
2014-03-12 11:34 ` Michael S. Tsirkin
2014-03-17 9:12 ` Greg Kurz
2015-01-20 15:36 ` Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ha8h4gzc.fsf@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=aliguori@amazon.com \
--cc=armbru@redhat.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).