1. 02 5月, 2018 1 次提交
  2. 20 2月, 2018 1 次提交
  3. 02 2月, 2018 3 次提交
    • G
      tests: virtio-9p: add FLUSH operation test · 357e2f7f
      Greg Kurz 提交于
      The idea is to send a victim request that will possibly block in the
      server and to send a flush request to cancel the victim request.
      
      This patch adds two test to verifiy that:
      - the server does not reply to a victim request that was actually
        cancelled
      - the server replies to the flush request after replying to the
        victim request if it could not cancel it
      
      9p request cancellation reference:
      
      http://man.cat-v.org/plan_9/5/flushSigned-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      (groug, change the test to only write a single byte to avoid
              any alignment or endianess consideration)
      357e2f7f
    • K
      9pfs: Correctly handle cancelled requests · fc78d5ee
      Keno Fischer 提交于
      # Background
      
      I was investigating spurious non-deterministic EINTR returns from
      various 9p file system operations in a Linux guest served from the
      qemu 9p server.
      
       ## EINTR, ERESTARTSYS and the linux kernel
      
      When a signal arrives that the Linux kernel needs to deliver to user-space
      while a given thread is blocked (in the 9p case waiting for a reply to its
      request in 9p_client_rpc -> wait_event_interruptible), it asks whatever
      driver is currently running to abort its current operation (in the 9p case
      causing the submission of a TFLUSH message) and return to user space.
      In these situations, the error message reported is generally ERESTARTSYS.
      If the userspace processes specified SA_RESTART, this means that the
      system call will get restarted upon completion of the signal handler
      delivery (assuming the signal handler doesn't modify the process state
      in complicated ways not relevant here). If SA_RESTART is not specified,
      ERESTARTSYS gets translated to EINTR and user space is expected to handle
      the restart itself.
      
       ## The 9p TFLUSH command
      
      The 9p TFLUSH commands requests that the server abort an ongoing operation.
      The man page [1] specifies:
      
      ```
      If it recognizes oldtag as the tag of a pending transaction, it should
      abort any pending response and discard that tag.
      [...]
      When the client sends a Tflush, it must wait to receive the corresponding
      Rflush before reusing oldtag for subsequent messages. If a response to the
      flushed request is received before the Rflush, the client must honor the
      response as if it had not been flushed, since the completed request may
      signify a state change in the server
      ```
      
      In particular, this means that the server must not send a reply with the
      orignal tag in response to the cancellation request, because the client is
      obligated to interpret such a reply as a coincidental reply to the original
      request.
      
       # The bug
      
      When qemu receives a TFlush request, it sets the `cancelled` flag on the
      relevant pdu. This flag is periodically checked, e.g. in
      `v9fs_co_name_to_path`, and if set, the operation is aborted and the error
      is set to EINTR. However, the server then violates the spec, by returning
      to the client an Rerror response, rather than discarding the message
      entirely. As a result, the client is required to assume that said Rerror
      response is a result of the original request, not a result of the
      cancellation and thus passes the EINTR error back to user space.
      This is not the worst thing it could do, however as discussed above, the
      correct error code would have been ERESTARTSYS, such that user space
      programs with SA_RESTART set get correctly restarted upon completion of
      the signal handler.
      Instead, such programs get spurious EINTR results that they were not
      expecting to handle.
      
      It should be noted that there are plenty of user space programs that do not
      set SA_RESTART and do not correctly handle EINTR either. However, that is
      then a userspace bug. It should also be noted that this bug has been
      mitigated by a recent commit to the Linux kernel [2], which essentially
      prevents the kernel from sending Tflush requests unless the process is about
      to die (in which case the process likely doesn't care about the response).
      Nevertheless, for older kernels and to comply with the spec, I believe this
      change is beneficial.
      
       # Implementation
      
      The fix is fairly simple, just skipping notification of a reply if
      the pdu was previously cancelled. We do however, also notify the transport
      layer that we're doing this, so it can clean up any resources it may be
      holding. I also added a new trace event to distinguish
      operations that caused an error reply from those that were cancelled.
      
      One complication is that we only omit sending the message on EINTR errors in
      order to avoid confusing the rest of the code (which may assume that a
      client knows about a fid if it sucessfully passed it off to pud_complete
      without checking for cancellation status). This does mean that if the server
      acts upon the cancellation flag, it always needs to set err to EINTR. I
      believe this is true of the current code.
      
      [1] https://9fans.github.io/plan9port/man/man9/flush.html
      [2] https://github.com/torvalds/linux/commit/9523feac272ccad2ad8186ba4fcc891Signed-off-by: NKeno Fischer <keno@juliacomputing.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      [groug, send a zero-sized reply instead of detaching the buffer]
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Acked-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NStefano Stabellini <sstabellini@kernel.org>
      fc78d5ee
    • G
      9pfs: drop v9fs_register_transport() · 066eb006
      Greg Kurz 提交于
      No good reasons to do this outside of v9fs_device_realize_common().
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NStefano Stabellini <sstabellini@kernel.org>
      066eb006
  4. 08 1月, 2018 4 次提交
  5. 07 11月, 2017 1 次提交
  6. 16 10月, 2017 1 次提交
  7. 20 9月, 2017 3 次提交
    • J
      9pfs: check the size of transport buffer before marshaling · 772a7369
      Jan Dakinevich 提交于
      v9fs_do_readdir_with_stat() should check for a maximum buffer size
      before an attempt to marshal gathered data. Otherwise, buffers assumed
      as misconfigured and the transport would be broken.
      
      The patch brings v9fs_do_readdir_with_stat() in conformity with
      v9fs_do_readdir() behavior.
      Signed-off-by: NJan Dakinevich <jan.dakinevich@gmail.com>
      [groug, regression caused my commit 8d37de41 # 2.10]
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      772a7369
    • J
      9pfs: fix name_to_path assertion in v9fs_complete_rename() · 4d8bc733
      Jan Dakinevich 提交于
      The third parameter of v9fs_co_name_to_path() must not contain `/'
      character.
      
      The issue is most likely related to 9p2000.u protocol only.
      Signed-off-by: NJan Dakinevich <jan.dakinevich@gmail.com>
      [groug, regression caused by commit f57f5878 # 2.10]
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      4d8bc733
    • J
      9pfs: fix readdir() for 9p2000.u · 6069537f
      Jan Dakinevich 提交于
      If the client is using 9p2000.u, the following occurs:
      
      $ cd ${virtfs_shared_dir}
      $ mkdir -p a/b/c
      $ ls a/b
      ls: cannot access 'a/b/a': No such file or directory
      ls: cannot access 'a/b/b': No such file or directory
      a  b  c
      
      instead of the expected:
      
      $ ls a/b
      c
      
      This is a regression introduced by commit f57f5878;
      local_name_to_path() now resolves ".." and "." in paths,
      and v9fs_do_readdir_with_stat()->stat_to_v9stat() then
      copies the basename of the resulting path to the response.
      With the example above, this means that "." and ".." are
      turned into "b" and "a" respectively...
      
      stat_to_v9stat() currently assumes it is passed a full
      canonicalized path and uses it to do two different things:
      1) to pass it to v9fs_co_readlink() in case the file is a symbolic
         link
      2) to set the name field of the V9fsStat structure to the basename
         part of the given path
      
      It only has two users: v9fs_stat() and v9fs_do_readdir_with_stat().
      
      v9fs_stat() really needs 1) and 2) to be performed since it starts
      with the full canonicalized path stored in the fid. It is different
      for v9fs_do_readdir_with_stat() though because the name we want to
      put into the V9fsStat structure is the d_name field of the dirent
      actually (ie, we want to keep the "." and ".." special names). So,
      we only need 1) in this case.
      
      This patch hence adds a basename argument to stat_to_v9stat(), to
      be used to set the name field of the V9fsStat structure, and moves
      the basename logic to v9fs_stat().
      Signed-off-by: NJan Dakinevich <jan.dakinevich@gmail.com>
      (groug, renamed old name argument to path and updated changelog)
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      6069537f
  8. 05 9月, 2017 1 次提交
  9. 13 7月, 2017 1 次提交
    • A
      Convert error_report() to warn_report() · 3dc6f869
      Alistair Francis 提交于
      Convert all uses of error_report("warning:"... to use warn_report()
      instead. This helps standardise on a single method of printing warnings
      to the user.
      
      All of the warnings were changed using these two commands:
          find ./* -type f -exec sed -i \
            's|error_report(".*warning[,:] |warn_report("|Ig' {} +
      
      Indentation fixed up manually afterwards.
      
      The test-qdev-global-props test case was manually updated to ensure that
      this patch passes make check (as the test cases are case sensitive).
      Signed-off-by: NAlistair Francis <alistair.francis@xilinx.com>
      Suggested-by: NThomas Huth <thuth@redhat.com>
      Cc: Jeff Cody <jcody@redhat.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Lieven <pl@kamp.de>
      Cc: Josh Durgin <jdurgin@redhat.com>
      Cc: "Richard W.M. Jones" <rjones@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Cc: Peter Crosthwaite <crosthwaite.peter@gmail.com>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
      Cc: Greg Kurz <groug@kaod.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Peter Chubb <peter.chubb@nicta.com.au>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Marcel Apfelbaum <marcel@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: David Gibson <david@gibson.dropbear.id.au>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: Marcelo Tosatti <mtosatti@redhat.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Cornelia Huck <cohuck@redhat.com>
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Acked-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Acked-by: NGreg Kurz <groug@kaod.org>
      Acked-by: NCornelia Huck <cohuck@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed by: Peter Chubb <peter.chubb@data61.csiro.au>
      Acked-by: NMax Reitz <mreitz@redhat.com>
      Acked-by: NMarcel Apfelbaum <marcel@redhat.com>
      Message-Id: <e1cfa2cd47087c248dd24caca9c33d9af0c499b0.1499866456.git.alistair.francis@xilinx.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      3dc6f869
  10. 29 6月, 2017 3 次提交
  11. 25 5月, 2017 3 次提交
  12. 17 5月, 2017 1 次提交
  13. 05 4月, 2017 2 次提交
    • G
      9pfs: clear migration blocker at session reset · 6d54af0e
      Greg Kurz 提交于
      The migration blocker survives a device reset: if the guest mounts a 9p
      share and then gets rebooted with system_reset, it will be unmigratable
      until it remounts and umounts the 9p share again.
      
      This happens because the migration blocker is supposed to be cleared when
      we put the last reference on the root fid, but virtfs_reset() wrongly calls
      free_fid() instead of put_fid().
      
      This patch fixes virtfs_reset() so that it honor the way fids are supposed
      to be manipulated: first get a reference and later put it back when you're
      done.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NLi Qiang <liqiang6-s@360.cn>
      6d54af0e
    • G
      9pfs: fix multiple flush for same request · 18adde86
      Greg Kurz 提交于
      If a client tries to flush the same outstanding request several times, only
      the first flush completes. Subsequent ones keep waiting for the request
      completion in v9fs_flush() and, therefore, leak a PDU. This will cause QEMU
      to hang when draining active PDUs the next time the device is reset.
      
      Let have each flush request wake up the next one if any. The last waiter
      frees the cancelled PDU.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      18adde86
  14. 28 3月, 2017 1 次提交
    • L
      9pfs: fix file descriptor leak · d63fb193
      Li Qiang 提交于
      The v9fs_create() and v9fs_lcreate() functions are used to create a file
      on the backend and to associate it to a fid. The fid shouldn't be already
      in-use, otherwise both functions may silently leak a file descriptor or
      allocated memory. The current code doesn't check that.
      
      This patch ensures that the fid isn't already associated to anything
      before using it.
      Signed-off-by: NLi Qiang <liqiang6-s@360.cn>
      (reworded the changelog, Greg Kurz)
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      d63fb193
  15. 21 3月, 2017 1 次提交
    • G
      9pfs: don't try to flush self and avoid QEMU hang on reset · d5f2af7b
      Greg Kurz 提交于
      According to the 9P spec [*], when a client wants to cancel a pending I/O
      request identified by a given tag (uint16), it must send a Tflush message
      and wait for the server to respond with a Rflush message before reusing this
      tag for another I/O. The server may still send a completion message for the
      I/O if it wasn't actually cancelled but the Rflush message must arrive after
      that.
      
      QEMU hence waits for the flushed PDU to complete before sending the Rflush
      message back to the client.
      
      If a client sends 'Tflush tag oldtag' and tag == oldtag, QEMU will then
      allocate a PDU identified by tag, find it in the PDU list and wait for
      this same PDU to complete... i.e. wait for a completion that will never
      happen. This causes a tag and ring slot leak in the guest, and a PDU
      leak in QEMU, all of them limited by the maximal number of PDUs (128).
      But, worse, this causes QEMU to hang on device reset since v9fs_reset()
      wants to drain all pending I/O.
      
      This insane behavior is likely to denote a bug in the client, and it would
      deserve an Rerror message to be sent back. Unfortunately, the protocol
      allows it and requires all flush requests to suceed (only a Tflush response
      is expected).
      
      The only option is to detect when we have to handle a self-referencing
      flush request and report success to the client right away.
      
      [*] http://man.cat-v.org/plan_9/5/flushReported-by: NAl Viro <viro@ZenIV.linux.org.uk>
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      d5f2af7b
  16. 28 2月, 2017 2 次提交
  17. 21 2月, 2017 1 次提交
  18. 25 1月, 2017 4 次提交
  19. 04 1月, 2017 5 次提交
  20. 23 11月, 2016 1 次提交