[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 0/4] 9p: get rid of readdir_r()

From: Greg Kurz
Subject: [Qemu-devel] [PATCH v2 0/4] 9p: get rid of readdir_r()
Date: Fri, 03 Jun 2016 09:38:09 +0200
User-agent: StGit/0.17.1-dirty

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:


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

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 !



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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]