Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Mar 2011 17:15:10 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        cvs-src-old@freebsd.org
Subject:   cvs commit: src/sys/ufs/ufs dirhash.h ufs_dirhash.c
Message-ID:  <201103181715.p2IHFNYS029013@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
jhb         2011-03-18 17:15:10 UTC

  FreeBSD src repository

  Modified files:        (Branch: RELENG_8)
    sys/ufs/ufs          dirhash.h ufs_dirhash.c 
  Log:
  SVN rev 219744 on 2011-03-18 17:15:10Z by jhb
  
  MFC 219384:
  The UFS dirhash code was attempting to update shared state in the dirhash
  from multiple threads while holding a shared lock during a lookup operation.
  This could result in incorrect ENOENT failures which could then be
  permanently stored in the name cache.
  
  Specifically, the dirhash code optimizes the case that a single thread is
  walking a directory sequentially opening (or stat'ing) each file.  It uses
  state in the dirhash structure to determine if a given lookup is using the
  optimization.  If the optimization fails, it disables it and restarts the
  lookup.  The problem arises when two threads both attempt the optimization
  and fail.  The first thread will restart the loop, but the second thread
  will incorrectly think that it did not try the optimization and will only
  examine a subset of the directory entires in its hash chain.  As a result,
  it may fail to find its directory entry and incorrectly fail with ENOENT.
  
  To make this safe for use with shared locks, simplify the state stored in
  the dirhash and move some of the state (the part that determines if the
  current thread is trying the optimization) into a local variable.  One
  result is that we will now try the optimization more often.  We still
  update the value under the shared lock, but it is a single atomic store
  similar to i_diroff that is stored in UFS directory i-nodes for the
  non-dirhash lookup.
  
  Revision  Changes    Path
  1.8.2.2   +0 -1      src/sys/ufs/ufs/dirhash.h
  1.33.2.3  +15 -17    src/sys/ufs/ufs/ufs_dirhash.c



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103181715.p2IHFNYS029013>