From owner-cvs-src-old@FreeBSD.ORG Fri Mar 18 17:15:24 2011 Return-Path: Delivered-To: cvs-src-old@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D9C81065670 for ; Fri, 18 Mar 2011 17:15:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id F369C8FC12 for ; Fri, 18 Mar 2011 17:15:23 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.4/8.14.4) with ESMTP id p2IHFNfe029014 for ; Fri, 18 Mar 2011 17:15:23 GMT (envelope-from jhb@repoman.freebsd.org) Received: (from svn2cvs@localhost) by repoman.freebsd.org (8.14.4/8.14.4/Submit) id p2IHFNYS029013 for cvs-src-old@freebsd.org; Fri, 18 Mar 2011 17:15:23 GMT (envelope-from jhb@repoman.freebsd.org) Message-Id: <201103181715.p2IHFNYS029013@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: svn2cvs set sender to jhb@repoman.freebsd.org using -f From: John Baldwin Date: Fri, 18 Mar 2011 17:15:10 +0000 (UTC) To: cvs-src-old@freebsd.org X-FreeBSD-CVS-Branch: RELENG_8 Subject: cvs commit: src/sys/ufs/ufs dirhash.h ufs_dirhash.c X-BeenThere: cvs-src-old@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: **OBSOLETE** CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Mar 2011 17:15:24 -0000 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