Hello,

Three more small patches like the previous round, for places where a
node is unlocked, or released, one time too many.

I found them by building libdiskfs and ext2fs with their mutexes made
PTHREAD_MUTEX_ERRORCHECK, and a macro around pthread_mutex_lock/unlock
that stops with a backtrace when either fails.  A default mutex does
not check its owner, so these unlocks normally go unnoticed, unless
another thread holds the lock at that moment and loses it, causing
difficult to untangle bugs.

With that, the system already blew up at boot: every lookup through a
translator (under /dev, /servers, ...) unlocked its directory twice
(patch 1).  Patch 2 is in --virtual-root; it shows with

  settrans -ca /tmp/vr /path/to/ext2fs.static --readonly \
    --virtual-root=. /dev/sd0

Patch 3 is in ext2fs: a lookup of ".." that fails to read the parent
released the directory, which its caller in a directory rename
released again.  That needs the parent's inode read to fail, so it is
rare.

If you would like, I can send the instrumentation as a patch too, so
that these bugs show up quickly in the future, for example behind a
configure option such as --enable-mutex-debug.

Thanks,

Milos Nikic (3):
  libdiskfs: Do not unlock the directory again after a translator lookup
  libdiskfs: Do not unlock the old root again with --virtual-root
  ext2fs: Keep the directory when a lookup of its parent fails

 ext2fs/dir.c             | 9 ++++++++-
 libdiskfs/dir-lookup.c   | 6 ++++++
 libdiskfs/init-startup.c | 6 ++++--
 3 files changed, 18 insertions(+), 3 deletions(-)

-- 
2.56.0


Reply via email to