describe ap (Kirk); delete lfs_mntinvalbuf, lfs_vinvalbuf, add
[unix-history] / usr / src / sys / ufs / lfs / lfs_subr.c
/*
* Copyright (c) 1991 Regents of the University of California.
* All rights reserved.
*
* %sccs.include.redist.c%
*
* @(#)lfs_subr.c 7.13 (Berkeley) %G%
*/
#include <sys/param.h>
#include <sys/namei.h>
#include <sys/vnode.h>
#include <sys/buf.h>
#include <sys/mount.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
#include <ufs/lfs/lfs.h>
#include <ufs/lfs/lfs_extern.h>
/*
* Return buffer with the contents of block "offset" from the beginning of
* directory "ip". If "res" is non-zero, fill it in with a pointer to the
* remaining space in the directory.
*/
int
lfs_blkatoff(ap)
struct vop_blkatoff_args /* {
struct vnode *a_vp;
off_t a_offset;
char **a_res;
struct buf **a_bpp;
} */ *ap;
{
register struct lfs *fs;
struct inode *ip;
struct buf *bp;
daddr_t lbn;
int bsize, error;
ip = VTOI(ap->a_vp);
fs = ip->i_lfs;
lbn = lblkno(fs, ap->a_offset);
bsize = blksize(fs);
*ap->a_bpp = NULL;
if (error = bread(ap->a_vp, lbn, bsize, NOCRED, &bp)) {
brelse(bp);
return (error);
}
if (ap->a_res)
*ap->a_res = bp->b_un.b_addr + blkoff(fs, ap->a_offset);
*ap->a_bpp = bp;
return (0);
}
/*
* lfs_seglock --
* Single thread the segment writer.
*/
void
lfs_seglock(fs)
struct lfs *fs;
{
while (fs->lfs_seglock)
(void)tsleep(&fs->lfs_seglock, PRIBIO + 1, "lfs seglock", 0);
fs->lfs_seglock = 1;
}
/*
* lfs_segunlock --
* Single thread the segment writer.
*/
void
lfs_segunlock(fs)
struct lfs *fs;
{
fs->lfs_seglock = 0;
wakeup(&fs->lfs_seglock); /* XXX: May not be necessary. */
}