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.27 retrieving revision 1.35.2.1 diff -u -p -r1.27 -r1.35.2.1 --- src/sys/ufs/ufs/ufs_dirhash.c 2008/07/03 09:56:15 1.27 +++ src/sys/ufs/ufs/ufs_dirhash.c 2014/05/18 17:46:22 1.35.2.1 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_dirhash.c,v 1.27 2008/07/03 09:56:15 ad Exp $ */ +/* $NetBSD: ufs_dirhash.c,v 1.35.2.1 2014/05/18 17:46:22 rmind Exp $ */ /* * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_dirhash.c,v 1.27 2008/07/03 09:56:15 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_dirhash.c,v 1.35.2.1 2014/05/18 17:46:22 rmind Exp $"); /* * This implements a hash-based lookup scheme for UFS directories. @@ -140,13 +140,13 @@ ufsdirhash_build(struct inode *ip) } /* Don't hash removed directories. */ - if (ip->i_ffs_effnlink == 0) + if (ip->i_nlink == 0) return (-1); vp = ip->i_vnode; /* Allocate 50% more entries than this dir size could ever need. */ KASSERT(ip->i_size >= dirblksiz); - nslots = ip->i_size / DIRECTSIZ(1); + nslots = ip->i_size / UFS_DIRECTSIZ(1); nslots = (nslots * 3 + 1) / 2; narrays = howmany(nslots, DH_NBLKOFF); nslots = narrays * DH_NBLKOFF; @@ -239,7 +239,7 @@ ufsdirhash_build(struct inode *ip) slot = WRAPINCR(slot, dh->dh_hlen); dh->dh_hused++; DH_ENTRY(dh, slot) = pos; - ufsdirhash_adjfree(dh, pos, -DIRSIZ(0, ep, needswap), + ufsdirhash_adjfree(dh, pos, -UFS_DIRSIZ(0, ep, needswap), dirblksiz); } pos += ep->d_reclen; @@ -316,7 +316,7 @@ ufsdirhash_free(struct inode *ip) * If successful, the directory offset is stored in *offp, and a * pointer to a struct buf containing the entry is stored in *bpp. If * prevoffp is non-NULL, the offset of the previous entry within - * the DIRBLKSIZ-sized block is stored in *prevoffp (if the entry + * the UFS_DIRBLKSIZ-sized block is stored in *prevoffp (if the entry * is the first in a block, the start of the block is used). */ int @@ -416,7 +416,7 @@ restart: brelse(bp, 0); blkoff = offset & ~bmask; if (ufs_blkatoff(vp, (off_t)blkoff, - NULL, &bp, true) != 0) { + NULL, &bp, false) != 0) { DIRHASH_UNLOCK(dh); return (EJUSTRETURN); } @@ -430,7 +430,7 @@ restart: return (EJUSTRETURN); } if (dp->d_namlen == namelen && - bcmp(dp->d_name, name, namelen) == 0) { + memcmp(dp->d_name, name, namelen) == 0) { /* Found. Get the prev offset if needed. */ if (prevoffp != NULL) { if (offset & (dirblksiz - 1)) { @@ -448,7 +448,7 @@ restart: /* Check for sequential access, and update offset. */ if (dh->dh_seqopt == 0 && dh->dh_seqoff == offset) dh->dh_seqopt = 1; - dh->dh_seqoff = offset + DIRSIZ(0, dp, needswap); + dh->dh_seqoff = offset + UFS_DIRSIZ(0, dp, needswap); DIRHASH_UNLOCK(dh); *bpp = bp; @@ -483,7 +483,7 @@ restart: * the offset of the directory entry that begins the free space. * This will either be the offset of an existing entry that has free * space at the end, or the offset of an entry with d_ino == 0 at - * the start of a DIRBLKSIZ block. + * the start of a UFS_DIRBLKSIZ block. * * To use the space, the caller may need to compact existing entries in * the directory. The total number of bytes in all of the entries involved @@ -540,7 +540,7 @@ ufsdirhash_findfree(struct inode *ip, in brelse(bp, 0); return (-1); } - if (dp->d_ino == 0 || dp->d_reclen > DIRSIZ(0, dp, needswap)) + if (dp->d_ino == 0 || dp->d_reclen > UFS_DIRSIZ(0, dp, needswap)) break; i += dp->d_reclen; dp = (struct direct *)((char *)dp + dp->d_reclen); @@ -557,7 +557,7 @@ ufsdirhash_findfree(struct inode *ip, in while (i < dirblksiz && freebytes < slotneeded) { freebytes += dp->d_reclen; if (dp->d_ino != 0) - freebytes -= DIRSIZ(0, dp, needswap); + freebytes -= UFS_DIRSIZ(0, dp, needswap); if (dp->d_reclen == 0) { DIRHASH_UNLOCK(dh); brelse(bp, 0); @@ -655,7 +655,7 @@ ufsdirhash_add(struct inode *ip, struct DH_ENTRY(dh, slot) = offset; /* Update the per-block summary info. */ - ufsdirhash_adjfree(dh, offset, -DIRSIZ(0, dirp, needswap), dirblksiz); + ufsdirhash_adjfree(dh, offset, -UFS_DIRSIZ(0, dirp, needswap), dirblksiz); DIRHASH_UNLOCK(dh); } @@ -690,7 +690,7 @@ ufsdirhash_remove(struct inode *ip, stru ufsdirhash_delslot(dh, slot); /* Update the per-block summary info. */ - ufsdirhash_adjfree(dh, offset, DIRSIZ(0, dirp, needswap), dirblksiz); + ufsdirhash_adjfree(dh, offset, UFS_DIRSIZ(0, dirp, needswap), dirblksiz); DIRHASH_UNLOCK(dh); } @@ -724,7 +724,7 @@ ufsdirhash_move(struct inode *ip, struct /* * Inform dirhash that the directory has grown by one block that - * begins at offset (i.e. the new length is offset + DIRBLKSIZ). + * begins at offset (i.e. the new length is offset + UFS_DIRBLKSIZ). */ void ufsdirhash_newblk(struct inode *ip, doff_t offset) @@ -868,7 +868,7 @@ ufsdirhash_checkblock(struct inode *ip, /* Check that the entry exists (will panic if it doesn't). */ ufsdirhash_findslot(dh, dp->d_name, dp->d_namlen, offset + i); - nfree += dp->d_reclen - DIRSIZ(0, dp, needswap); + nfree += dp->d_reclen - UFS_DIRSIZ(0, dp, needswap); } if (i != dirblksiz) panic("ufsdirhash_checkblock: bad dir end"); @@ -1000,7 +1000,7 @@ ufsdirhash_delslot(struct dirhash *dh, i /* * Given a directory entry and its offset, find the offset of the - * previous entry in the same DIRBLKSIZ-sized block. Returns an + * previous entry in the same UFS_DIRBLKSIZ-sized block. Returns an * offset, or -1 if there is no previous entry in the block or some * other problem occurred. */ @@ -1086,7 +1086,7 @@ ufsdirhash_recycle(int wanted) /* Account for the returned memory, and repeat if necessary. */ DIRHASHLIST_LOCK(); - ufs_dirhashmem -= mem; + atomic_add_int(&ufs_dirhashmem, -mem); } /* Success. */ return (0); @@ -1099,16 +1099,10 @@ ufsdirhash_sysctl_init(void) sysctl_createv(&ufsdirhash_sysctl_log, 0, NULL, &rnode, CTLFLAG_PERMANENT, - CTLTYPE_NODE, "vfs", NULL, - NULL, 0, NULL, 0, - CTL_VFS, CTL_EOL); - - sysctl_createv(&ufsdirhash_sysctl_log, 0, &rnode, &rnode, - CTLFLAG_PERMANENT, CTLTYPE_NODE, "ufs", SYSCTL_DESCR("ufs"), NULL, 0, NULL, 0, - CTL_CREATE, CTL_EOL); + CTL_VFS, CTL_CREATE, CTL_EOL); sysctl_createv(&ufsdirhash_sysctl_log, 0, &rnode, &rnode, CTLFLAG_PERMANENT, @@ -1147,7 +1141,7 @@ ufsdirhash_sysctl_init(void) } void -ufsdirhash_init() +ufsdirhash_init(void) { mutex_init(&ufsdirhash_lock, MUTEX_DEFAULT, IPL_NONE);