Bug 31966

Summary: `offset == dh->dh_seqopt' in ufsdirhash_lookup() is wrong?
Product: Base System Reporter: KOIE Hidetaka <koie>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description KOIE Hidetaka 2001-11-14 04:40:00 UTC
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;
                 ...
Comment 1 iedowse 2001-11-14 12:51:03 UTC
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
Comment 2 iedowse freebsd_committer freebsd_triage 2001-11-14 15:23:57 UTC
State Changed
From-To: open->closed


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