From nobody@FreeBSD.org  Tue Nov 13 20:39:11 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id E155737B416
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 13 Nov 2001 20:39:10 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.4/8.11.4) id fAE4dAD14339;
	Tue, 13 Nov 2001 20:39:10 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200111140439.fAE4dAD14339@freefall.freebsd.org>
Date: Tue, 13 Nov 2001 20:39:10 -0800 (PST)
From: KOIE Hidetaka <koie@suri.co.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: `offset == dh->dh_seqopt' in ufsdirhash_lookup() is wrong?
X-Send-Pr-Version: www-1.0

>Number:         31966
>Category:       kern
>Synopsis:       `offset == dh->dh_seqopt' in ufsdirhash_lookup() is wrong?
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 13 20:40:00 PST 2001
>Closed-Date:    Wed Nov 14 07:23:57 PST 2001
>Last-Modified:  Wed Nov 14 07:25:14 PST 2001
>Originator:     KOIE Hidetaka
>Release:        NONE
>Organization:
SURIGIKEN
>Environment:
NONE
>Description:
I'm not using FreeBSD.
I'm reading DIRHASH codes to study. I'm looking ufs_dirhash.c rev 1.6.
The function ufsdirhash_lookup() has `Sequential access optimisation'.
I suppose that
                for (i = slot; (offset = DH_ENTRY(dh, i)) != DIRHASH_EMPTY;
                    i = WRAPINCR(i, dh->dh_hlen))
                        if (offset == dh->dh_seqopt)
                                break;
                if (offset == dh->dh_seqoff) {
                        slot = i;
                } else
                        dh->dh_seqopt = 0;
        }
should be 
                 ...
                        if (offset == dh->dh_seqoff)
                                break;
                 ...
>How-To-Repeat:
      
>Fix:
      
>Release-Note:
>Audit-Trail:

From: Ian Dowse <iedowse@maths.tcd.ie>
To: KOIE Hidetaka <koie@suri.co.jp>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/31966: `offset == dh->dh_seqopt' in ufsdirhash_lookup() is wrong? 
Date: Wed, 14 Nov 2001 12:51:03 +0000

 In message <200111140439.fAE4dAD14339@freefall.freebsd.org>, KOIE Hidetaka writ
 es:
 >I'm not using FreeBSD.
 >I'm reading DIRHASH codes to study. I'm looking ufs_dirhash.c rev 1.6.
 >The function ufsdirhash_lookup() has `Sequential access optimisation'.
 >I suppose that
 ...
 >                        if (offset == dh->dh_seqopt)
 ...
 >should be 
 ...
 >                        if (offset == dh->dh_seqoff)
 ...
 
 Oops, you are quite correct. This typo effectively disabled the
 sequential access optimisation entirely. I think apart from this,
 the bug was not harmful (the case where this code runs is where
 dh->dh_seqopt == 1, but no valid UFS directory can exist at offset
 1, so `offset' will never be 1). I will commit your proposed fix
 as soon as I have done a bit of testing.
 
 Thank you, KOIE-san, for finding this and pointing it out!
 
 Ian
State-Changed-From-To: open->closed 
State-Changed-By: iedowse 
State-Changed-When: Wed Nov 14 07:23:57 PST 2001 
State-Changed-Why:  

Committed in revision 1.7 of ufs_dirhash.c. Thanks for the bug report! 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31966 
>Unformatted:
