qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/4] 9p: get rid of readdir_r()
@ 2016-06-02  8:51 Greg Kurz
  2016-06-02  8:52 ` [Qemu-devel] [PATCH 1/4] 9p: drop useless out: label Greg Kurz
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Greg Kurz @ 2016-06-02  8:51 UTC (permalink / raw)
  To: Greg Kurz; +Cc: 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.

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     |   12 ++++++----
 hw/9pfs/coth.h      |    3 +-
 10 files changed, 120 insertions(+), 92 deletions(-)

--
Greg

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

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

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-02  8:51 [Qemu-devel] [PATCH 0/4] 9p: get rid of readdir_r() Greg Kurz
2016-06-02  8:52 ` [Qemu-devel] [PATCH 1/4] 9p: drop useless out: label Greg Kurz
2016-06-02 19:57   ` Eric Blake
2016-06-02  8:52 ` [Qemu-devel] [PATCH 2/4] 9p: introduce the V9fsDir type Greg Kurz
2016-06-02 20:05   ` Eric Blake
2016-06-02  8:52 ` [Qemu-devel] [PATCH 3/4] 9p: add locking to V9fsDir Greg Kurz
2016-06-02 20:46   ` Eric Blake
2016-06-02  8:52 ` [Qemu-devel] [PATCH 4/4] 9p: switch back to readdir() Greg Kurz
2016-06-02 21:00   ` Eric Blake
2016-06-03  6:29     ` Greg Kurz
2016-06-02  9:33 ` [Qemu-devel] [PATCH 0/4] 9p: get rid of readdir_r() Peter Maydell
2016-06-02  9:42   ` Greg Kurz
2016-06-02 12:05     ` Peter Maydell
2016-06-02 13:59     ` Michael Fritscher
2016-06-02 15:47       ` Greg Kurz

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