qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/4] 9p: get rid of readdir_r()
@ 2016-06-03  7:38 Greg Kurz
  2016-06-03  7:38 ` [Qemu-devel] [PATCH v2 1/4] 9p: drop useless out: label Greg Kurz
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Greg Kurz @ 2016-06-03  7:38 UTC (permalink / raw)
  To: Greg Kurz; +Cc: Eric Blake, Aneesh Kumar K.V, qemu-devel

The readdir_r() function has a broken design and should not be used anymore.
It is expected to be obsoleted in a future version of POSIX.1:

http://austingroupbugs.net/view.php?id=696#c2857

Glibc has already announced that 2.24 (scheduled for August 2016) will
deprecates readdir_r() and encourages people to use readdir() with
external synchronization instead.

This series replaces readdir_r() by readdir() and changes the internal API
in fsdev/file-op-9p.h to be readdir-like, like it was before commit
"5f524c1ebcc5 use readdir_r instead of readdir for reentrancy".

The 9p code runs in coroutines, called either:
- from the QEMU main-loop when ioventfd=on, which is the default, or
- from vCPU context when ioeventfd=off, with the qemu_global_mutex
  taken

All hypothetical critical sections around the use of readdir() are then
already serialized. This series introduces a serialization anyway for the
code to be fully independant from the context.

Since POSIX.1 will require readdir() to be thread-safe when employed on
different directory streams, and glibc already does that, the choice
was made to have per-directory locking. This is acceptable because VirtFS
support is disabled in configure for non-linux hosts.

Unsurprisingly, there is no contention and the locking/unlocking hasn't
any noticeable impact on performance.

Since early glibc-2.24 users are already encountering build breaks, I guess
this should go upstream sooner than later. I plan to issue a pull request
next week, or even before if possible.

Please comment !

Thanks.

---

Greg Kurz (4):
      9p: drop useless out: label
      9p: introduce the V9fsDir type
      9p: add locking to V9fsDir
      9p: switch back to readdir()


 fsdev/file-op-9p.h  |    3 +-
 hw/9pfs/9p-handle.c |   24 +++++++++-----------
 hw/9pfs/9p-local.c  |   36 ++++++++++++++++--------------
 hw/9pfs/9p-proxy.c  |   26 ++++++++++-----------
 hw/9pfs/9p-synth.c  |   23 ++++++++-----------
 hw/9pfs/9p-synth.h  |    1 +
 hw/9pfs/9p.c        |   62 ++++++++++++++++++++++++++++++---------------------
 hw/9pfs/9p.h        |   22 +++++++++++++++++-
 hw/9pfs/codir.c     |   10 +++++---
 hw/9pfs/coth.h      |    3 +-
 10 files changed, 119 insertions(+), 91 deletions(-)

--
Greg

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-03 12:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-03  7:38 [Qemu-devel] [PATCH v2 0/4] 9p: get rid of readdir_r() Greg Kurz
2016-06-03  7:38 ` [Qemu-devel] [PATCH v2 1/4] 9p: drop useless out: label Greg Kurz
2016-06-03  7:39 ` [Qemu-devel] [PATCH v2 2/4] 9p: introduce the V9fsDir type Greg Kurz
2016-06-03  7:39 ` [Qemu-devel] [PATCH v2 3/4] 9p: add locking to V9fsDir Greg Kurz
2016-06-03  7:40 ` [Qemu-devel] [PATCH v2 4/4] 9p: switch back to readdir() Greg Kurz
2016-06-03 12:45   ` Eric Blake

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).