Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/ufs/ufs/ufs_dirhash.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/ufs/ufs/ufs_dirhash.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.1 retrieving revision 1.12.2.1 diff -u -p -r1.1 -r1.12.2.1 --- src/sys/ufs/ufs/ufs_dirhash.c 2005/01/23 19:37:05 1.1 +++ src/sys/ufs/ufs/ufs_dirhash.c 2007/03/12 06:01:10 1.12.2.1 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_dirhash.c,v 1.1 2005/01/23 19:37:05 rumble Exp $ */ +/* $NetBSD: ufs_dirhash.c,v 1.12.2.1 2007/03/12 06:01:10 rmind Exp $ */ /* * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. @@ -31,8 +31,6 @@ * This implements a hash-based lookup scheme for UFS directories. */ -#ifdef UFS_DIRHASH - #include #include #include @@ -63,7 +61,7 @@ static MALLOC_DEFINE(M_DIRHASH, "UFS dir static int ufs_dirhashminblks = 5; static int ufs_dirhashmaxmem = 2 * 1024 * 1024; -static int ufs_dirhashmem; +static int ufs_dirhashmem; static int ufs_dirhashcheck = 0; static int ufsdirhash_hash(struct dirhash *dh, const char *name, int namelen); @@ -76,8 +74,8 @@ static doff_t ufsdirhash_getprev(struct int dirblksiz); static int ufsdirhash_recycle(int wanted); -POOL_INIT(ufsdirhash_pool, DH_NBLKOFF * sizeof(daddr_t), 0, 0, 0, "ufsdirhash", - &pool_allocator_nointr); +static POOL_INIT(ufsdirhash_pool, DH_NBLKOFF * sizeof(daddr_t), 0, 0, 0, + "ufsdirhash", &pool_allocator_nointr); #define DIRHASHLIST_LOCK() do { } while (0) #define DIRHASHLIST_UNLOCK() do { } while (0) @@ -102,7 +100,7 @@ ufsdirhash_build(struct inode *ip) struct vnode *vp; doff_t bmask, pos; int dirblocks, i, j, memreqd, nblocks, narrays, nslots, slot; - const int needswap = UFS_MPNEEDSWAP(ip->i_ump); + const int needswap = UFS_MPNEEDSWAP(ip->i_ump); int dirblksiz = ip->i_ump->um_dirblksiz; /* Check if we can/should use dirhash. */ @@ -165,9 +163,9 @@ ufsdirhash_build(struct inode *ip) DIRHASHLIST_UNLOCK(); return (-1); } - MALLOC(dh->dh_hash, doff_t **, narrays * sizeof(dh->dh_hash[0]), + dh->dh_hash = (doff_t **)malloc(narrays * sizeof(dh->dh_hash[0]), M_DIRHASH, M_NOWAIT | M_ZERO); - MALLOC(dh->dh_blkfree, u_int8_t *, nblocks * sizeof(dh->dh_blkfree[0]), + dh->dh_blkfree = (u_int8_t *)malloc(nblocks * sizeof(dh->dh_blkfree[0]), M_DIRHASH, M_NOWAIT); if (dh->dh_hash == NULL || dh->dh_blkfree == NULL) goto fail; @@ -196,11 +194,15 @@ ufsdirhash_build(struct inode *ip) bmask = VFSTOUFS(vp->v_mount)->um_mountp->mnt_stat.f_iosize - 1; pos = 0; while (pos < ip->i_size) { + if ((curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD) + != 0) { + preempt(); + } /* If necessary, get the next directory block. */ if ((pos & bmask) == 0) { if (bp != NULL) brelse(bp); - if (VOP_BLKATOFF(vp, (off_t)pos, NULL, &bp) != 0) + if (ufs_blkatoff(vp, (off_t)pos, NULL, &bp) != 0) goto fail; } @@ -309,7 +311,7 @@ ufsdirhash_lookup(struct inode *ip, cons struct buf *bp; doff_t blkoff, bmask, offset, prevoff; int i, slot; - const int needswap = UFS_MPNEEDSWAP(ip->i_ump); + const int needswap = UFS_MPNEEDSWAP(ip->i_ump); int dirblksiz = ip->i_ump->um_dirblksiz; if ((dh = ip->i_dirhash) == NULL) @@ -377,9 +379,9 @@ restart: * We found an entry with the expected offset. This * is probably the entry we want, but if not, the * code below will turn off seqoff and retry. - */ + */ slot = i; - } else + } else dh->dh_seqopt = 0; } @@ -395,10 +397,10 @@ restart: if (bp != NULL) brelse(bp); blkoff = offset & ~bmask; - if (VOP_BLKATOFF(vp, (off_t)blkoff, NULL, &bp) != 0) + if (ufs_blkatoff(vp, (off_t)blkoff, NULL, &bp) != 0) return (EJUSTRETURN); } - dp = (struct direct *)(bp->b_data + (offset & bmask)); + dp = (struct direct *)((char *)bp->b_data + (offset & bmask)); if (dp->d_reclen == 0 || dp->d_reclen > dirblksiz - (offset & (dirblksiz - 1))) { /* Corrupted directory. */ @@ -478,7 +480,7 @@ ufsdirhash_findfree(struct inode *ip, in struct buf *bp; doff_t pos, slotstart; int dirblock, error, freebytes, i; - const int needswap = UFS_MPNEEDSWAP(ip->i_ump); + const int needswap = UFS_MPNEEDSWAP(ip->i_ump); int dirblksiz = ip->i_ump->um_dirblksiz; if ((dh = ip->i_dirhash) == NULL) @@ -504,7 +506,7 @@ ufsdirhash_findfree(struct inode *ip, in dh->dh_blkfree[dirblock] >= howmany(slotneeded, DIRALIGN)); DIRHASH_UNLOCK(dh); pos = dirblock * dirblksiz; - error = VOP_BLKATOFF(ip->i_vnode, (off_t)pos, (void *)&dp, &bp); + error = ufs_blkatoff(ip->i_vnode, (off_t)pos, (void *)&dp, &bp); if (error) return (-1); /* Find the first entry with free space. */ @@ -780,12 +782,12 @@ ufsdirhash_dirtrunc(struct inode *ip, do * a directory block matches its actual contents. Panics if a mismatch * is detected. * - * On entry, `buf' should point to the start of an in-core + * On entry, `sbuf' should point to the start of an in-core * DIRBLKSIZ-sized directory block, and `offset' should contain the * offset from the start of the directory of that block. */ void -ufsdirhash_checkblock(struct inode *ip, char *buf, doff_t offset) +ufsdirhash_checkblock(struct inode *ip, char *sbuf, doff_t offset) { struct dirhash *dh; struct direct *dp; @@ -810,7 +812,7 @@ ufsdirhash_checkblock(struct inode *ip, nfree = 0; for (i = 0; i < dirblksiz; i += dp->d_reclen) { - dp = (struct direct *)(buf + i); + dp = (struct direct *)(sbuf + i); if (dp->d_reclen == 0 || i + dp->d_reclen > dirblksiz) panic("ufsdirhash_checkblock: bad dir"); @@ -1057,7 +1059,7 @@ ufsdirhash_init() } void -ufsdirhash_done() +ufsdirhash_done(void) { KASSERT(TAILQ_EMPTY(&ufsdirhash_list)); #ifdef _LKM @@ -1067,7 +1069,7 @@ ufsdirhash_done() SYSCTL_SETUP(sysctl_vfs_ufs_setup, "sysctl vfs.ufs.dirhash subtree setup") { - struct sysctlnode *rnode, *cnode; + const struct sysctlnode *rnode, *cnode; sysctl_createv(clog, 0, NULL, &rnode, CTLFLAG_PERMANENT, @@ -1117,5 +1119,3 @@ SYSCTL_SETUP(sysctl_vfs_ufs_setup, "sysc NULL, 0, &ufs_dirhashcheck, 0, CTL_CREATE, CTL_EOL); } - -#endif /* UFS_DIRHASH */