version 1.2.4.2, 2005/04/29 11:29:39 |
version 1.5.2.1, 2005/10/20 03:00:31 |
|
|
* This implements a hash-based lookup scheme for UFS directories. |
* This implements a hash-based lookup scheme for UFS directories. |
*/ |
*/ |
|
|
#ifdef UFS_DIRHASH |
|
|
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/systm.h> |
#include <sys/systm.h> |
#include <sys/kernel.h> |
#include <sys/kernel.h> |
Line 200 ufsdirhash_build(struct inode *ip) |
|
Line 198 ufsdirhash_build(struct inode *ip) |
|
if ((pos & bmask) == 0) { |
if ((pos & bmask) == 0) { |
if (bp != NULL) |
if (bp != NULL) |
brelse(bp); |
brelse(bp); |
if (VOP_BLKATOFF(vp, (off_t)pos, NULL, &bp) != 0) |
if (UFS_BLKATOFF(vp, (off_t)pos, NULL, &bp) != 0) |
goto fail; |
goto fail; |
} |
} |
|
|
|
|
if (bp != NULL) |
if (bp != NULL) |
brelse(bp); |
brelse(bp); |
blkoff = offset & ~bmask; |
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); |
return (EJUSTRETURN); |
} |
} |
dp = (struct direct *)(bp->b_data + (offset & bmask)); |
dp = (struct direct *)(bp->b_data + (offset & bmask)); |
Line 504 ufsdirhash_findfree(struct inode *ip, in |
|
Line 502 ufsdirhash_findfree(struct inode *ip, in |
|
dh->dh_blkfree[dirblock] >= howmany(slotneeded, DIRALIGN)); |
dh->dh_blkfree[dirblock] >= howmany(slotneeded, DIRALIGN)); |
DIRHASH_UNLOCK(dh); |
DIRHASH_UNLOCK(dh); |
pos = dirblock * dirblksiz; |
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) |
if (error) |
return (-1); |
return (-1); |
/* Find the first entry with free space. */ |
/* Find the first entry with free space. */ |
Line 780 ufsdirhash_dirtrunc(struct inode *ip, do |
|
Line 778 ufsdirhash_dirtrunc(struct inode *ip, do |
|
* a directory block matches its actual contents. Panics if a mismatch |
* a directory block matches its actual contents. Panics if a mismatch |
* is detected. |
* 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 |
* DIRBLKSIZ-sized directory block, and `offset' should contain the |
* offset from the start of the directory of that block. |
* offset from the start of the directory of that block. |
*/ |
*/ |
void |
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 dirhash *dh; |
struct direct *dp; |
struct direct *dp; |
Line 810 ufsdirhash_checkblock(struct inode *ip, |
|
Line 808 ufsdirhash_checkblock(struct inode *ip, |
|
|
|
nfree = 0; |
nfree = 0; |
for (i = 0; i < dirblksiz; i += dp->d_reclen) { |
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) |
if (dp->d_reclen == 0 || i + dp->d_reclen > dirblksiz) |
panic("ufsdirhash_checkblock: bad dir"); |
panic("ufsdirhash_checkblock: bad dir"); |
|
|
Line 1057 ufsdirhash_init() |
|
Line 1055 ufsdirhash_init() |
|
} |
} |
|
|
void |
void |
ufsdirhash_done() |
ufsdirhash_done(void) |
{ |
{ |
KASSERT(TAILQ_EMPTY(&ufsdirhash_list)); |
KASSERT(TAILQ_EMPTY(&ufsdirhash_list)); |
#ifdef _LKM |
#ifdef _LKM |
Line 1067 ufsdirhash_done() |
|
Line 1065 ufsdirhash_done() |
|
|
|
SYSCTL_SETUP(sysctl_vfs_ufs_setup, "sysctl vfs.ufs.dirhash subtree setup") |
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, |
sysctl_createv(clog, 0, NULL, &rnode, |
CTLFLAG_PERMANENT, |
CTLFLAG_PERMANENT, |
Line 1117 SYSCTL_SETUP(sysctl_vfs_ufs_setup, "sysc |
|
Line 1115 SYSCTL_SETUP(sysctl_vfs_ufs_setup, "sysc |
|
NULL, 0, &ufs_dirhashcheck, 0, |
NULL, 0, &ufs_dirhashcheck, 0, |
CTL_CREATE, CTL_EOL); |
CTL_CREATE, CTL_EOL); |
} |
} |
|
|
#endif /* UFS_DIRHASH */ |
|