OpenAFS Master Repository branch, master, updated. openafs-devel-1_9_2-649-gb9a70f6

Gerrit Code Review gerrit@openafs.org
Tue, 20 Oct 2026 15:36:33 -0400


The following commit has been merged in the master branch:
commit b33f8a1ef678e7b4d476cb090f86b39cb6777d71
Author: Andrew Deason <adeason@sinenomine.net>
Date:   Mon Aug 17 11:44:12 2026 -0500

    ptserver: Introduce -read-during-write
    
    Introduce the runtime flag -read-during-write to the ptserver, which
    makes pr_Preamble() use ubik_BeginTransReadAnyWrite() for read
    transactions (instead of ubik_BeginTransReadAny()), allowing reads to
    run while write transactions are in progress.
    
    To allow reads to safely run at the same time as writes, change
    pr_Preamble() to set ctx->cheader to a different database header
    (wr_cheader) for write transactions. This header data is copied back
    into rd_cheader when the write transaction commits (via
    ubik_SyncWriterCacheProc / pr_SyncCache()). This way, read transactions
    will not see modifications to the in-memory db header until a write
    transaction successfully commits.
    
    So, the general flow of cheader data looks like this:
    
    - A transaction calls ubik_CheckCache(UpdateCache).
    
    - ubik_CheckCache() calls UpdateCache(), which reads in the ptdb header
      into rd_cheader. Or, if the database hasn't changed since the last
      time we called UpdateCache(), we don't need to do anything and
      rd_cheader is already up to date.
    
    - For a read transaction, ctx->cheader is set to rd_cheader, and use
      that as our cheader for the rest of the transaction. If we are a write
      transaction, we copy rd_cheader to wr_cheader, set ctx->cheader to
      wr_cheader, and use that as our cheader for the transaction.
    
    - At the end of a write transaction (when it is committing), wr_cheader
      gets copied back into rd_cheader via ubik_SyncWriterCacheProc aka
      pr_SyncCache().
    
    - The next read transaction calls ubik_CheckCache(UpdateCache), and
      rd_cheader is already up to date, so UpdateCache is not called, but
      the read transaction can use rd_cheader.
    
    By default (when -read-during-write is not used), we don't use
    wr_cheader at all, and all transactions continue to use rd_cheader.
    While using wr_cheader should still work normally, this helps prevent
    unexpected bugs from affecting existing users that aren't using this new
    experimental -read-during-write mode.
    
    For now, also do not allow -read-during-write to be specified when
    SUPERGROUPS is defined. While there are no known specific problems with
    combining these two features, some aspects of SUPERGROUPS are iffy:
    
    - The pt_mywrite() hook reads from rd_cheader outside of an ubik
      transaction, and so it doesn't have a pt_ctx and the normal guarantees
      about cheader do not apply. pt_mywrite() is called when
      'cache_lock' is write-locked, so no other threads can be modifying
      rd_cheader at that time, but this seems very indirect and fragile.
    
    - The sg_found/sg_flagged globals in general are used like an ubik
      application cache, but don't use the ubik application cache protection
      scheme (ubik_CheckCache(), ubik_SyncWriterCacheProc).
    
    To avoid -read-during-write making these areas of concern even worse,
    just prevent -read-during-write with SUPERGROUPS for now.
    
    Change-Id: I12c0d6400359140b3c6642df7a5bde6029f7c6cc
    Reviewed-on: https://gerrit.openafs.org/17017
    Tested-by: BuildBot <buildbot@rampaginggeek.com>
    Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
    Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
    Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
    Reviewed-by: Andrew Deason <adeason@sinenomine.net>

 doc/man-pages/pod8/ptserver.pod.template | 27 ++++++++++++++++++
 src/ptserver/ptprototypes.h              |  1 +
 src/ptserver/ptserver.c                  | 24 +++++++++++++++-
 src/ptserver/ptubik.c                    |  7 +++++
 src/ptserver/ptutils.c                   | 47 +++++++++++++++++++++++++++++++-
 5 files changed, 104 insertions(+), 2 deletions(-)

-- 
OpenAFS Master Repository