From ddd9f6443658b50c866553befb9aa67319b6b876 Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Sat, 2 Nov 1991 01:28:50 -0800 Subject: [PATCH] move ENTRY macro into lfs.h; reorganize source, checkpoint before integration SCCS-vsn: sys/ufs/lfs/lfs_alloc.c 7.33 --- usr/src/sys/ufs/lfs/lfs_alloc.c | 181 +++++++++----------------------- 1 file changed, 50 insertions(+), 131 deletions(-) diff --git a/usr/src/sys/ufs/lfs/lfs_alloc.c b/usr/src/sys/ufs/lfs/lfs_alloc.c index b0c1d0de49..7319e984ca 100644 --- a/usr/src/sys/ufs/lfs/lfs_alloc.c +++ b/usr/src/sys/ufs/lfs/lfs_alloc.c @@ -4,38 +4,32 @@ * * %sccs.include.redist.c% * - * @(#)lfs_alloc.c 7.32 (Berkeley) %G% + * @(#)lfs_alloc.c 7.33 (Berkeley) %G% */ -#ifdef LOGFS -#include "param.h" -#include "kernel.h" -#include "buf.h" -#include "vnode.h" -#include "syslog.h" -#include "mount.h" -#include "../ufs/quota.h" -#include "../ufs/inode.h" -#include "../ufs/ufsmount.h" -#include "lfs.h" -#include "lfs_extern.h" - -/* Read in the block containing a specific inode from the ifile. */ -#define LFS_IENTRY(I, F, IN, BP) \ - if (bread((F)->lfs_ivnode, (IN) / IFPB(F) + (F)->lfs_segtabsz, \ - (F)->lfs_bsize, NOCRED, &BP)) \ - panic("lfs_ientry: read"); \ - (I) = (IFILE *)BP->b_un.b_addr + IN % IFPB(F); +#include +#include +#include +#include +#include +#include -/* - * Allocate a new inode. - */ -ino_t -lfs_ialloc(fs, pip, ipp, cred) - LFS *fs; +#include +#include +#include + +#include +#include + +/* Allocate a new inode. */ +/* ARGSUSED */ +int +lfs_ialloc(pip, notused, cred, ipp) INODE *pip, **ipp; + int notused; UCRED *cred; { + LFS *fs; BUF *bp; IFILE *ifp; INODE *ip; @@ -44,6 +38,7 @@ lfs_ialloc(fs, pip, ipp, cred) int error; /* Get the head of the freelist. */ + fs = pip->i_lfs; new_ino = fs->lfs_free; if (new_ino == LFS_UNUSED_INUM) { /* @@ -56,7 +51,9 @@ lfs_ialloc(fs, pip, ipp, cred) cred->cr_uid, fs->lfs_fsmnt); return (ENOSPC); } -printf("lfs_ialloc: allocate inode %d\n", new_ino); +#ifdef ALLOCPRINT + printf("lfs_ialloc: allocate inode %d\n", new_ino); +#endif /* Read the appropriate block from the ifile. */ LFS_IENTRY(ifp, fs, new_ino, bp); @@ -81,7 +78,7 @@ printf("lfs_ialloc: allocate inode %d\n", new_ino); ip->i_gen = nextgennumber; /* Insert into the inode hash table. */ - lfs_hqueue(ip); + ufs_ihashins(ip); /* Set superblock modified bit and increment file count. */ fs->lfs_fmod = 1; @@ -89,78 +86,6 @@ printf("lfs_ialloc: allocate inode %d\n", new_ino); return (0); } -/* Free an inode. */ -void -lfs_ifree(ip) - INODE *ip; -{ - BUF *bp; - IFILE *ifp; - LFS *fs; - ino_t ino; - -printf("lfs_ifree: free %d\n", ip->i_number); - /* Get the inode number and file system. */ - fs = ip->i_lfs; - ino = ip->i_number; - - /* - * Read the appropriate block from the ifile. Set the inode entry to - * unused, increment its version number and link it into the free chain. - */ - LFS_IENTRY(ifp, fs, ino, bp); - ifp->if_daddr = LFS_UNUSED_DADDR; - ++ifp->if_version; - ifp->if_nextfree = fs->lfs_free; - fs->lfs_free = ino; - - lfs_bwrite(bp); - - /* Set superblock modified bit and decrement file count. */ - fs->lfs_fmod = 1; - --fs->lfs_nfiles; -} - -/* Translate an inode number to a disk address. */ -daddr_t -itod(fs, ino) - LFS *fs; - ino_t ino; -{ - BUF *bp; - IFILE *ifp; - daddr_t iaddr; - - /* Read the appropriate block from the ifile. */ - LFS_IENTRY(ifp, fs, ino, bp); - - if (ifp->if_daddr == LFS_UNUSED_DADDR) - panic("itod: unused disk address"); - iaddr = ifp->if_daddr; - brelse(bp); - return (iaddr); -} - -/* Search a block for a specific dinode. */ -DINODE * -lfs_ifind(fs, ino, page) - LFS *fs; - ino_t ino; - void *page; -{ - register DINODE *dip; - register int cnt; - -printf("lfs_ifind: inode %d\n", ino); - dip = page; - for (cnt = INOPB(fs); cnt--; ++dip) - if (dip->di_inum == ino) - return (dip); - - panic("lfs_ifind: dinode %%u not found", ino); - /* NOTREACHED */ -} - /* Create a new vnode/inode pair and initialize what fields we can. */ int lfs_vcreate(mp, ino, vpp) @@ -172,7 +97,9 @@ lfs_vcreate(mp, ino, vpp) UFSMOUNT *ump; int error, i; -printf("lfs_vcreate: ino %d\n", ino); +#ifdef ALLOCPRINT + printf("lfs_vcreate: ino %d\n", ino); +#endif /* Create the vnode. */ if (error = getnewvnode(VT_LFS, mp, &lfs_vnodeops, vpp)) return (error); @@ -199,47 +126,39 @@ printf("lfs_vcreate: ino %d\n", ino); return (0); } -/* Return the current version number for a specific inode. */ -u_long -lfs_getversion(fs, ino) - LFS *fs; - ino_t ino; -{ - BUF *bp; - IFILE *ifp; - u_long version; - - /* - * Read the appropriate block from the ifile. Return the - * version number. - */ - LFS_IENTRY(ifp, fs, ino, bp); - version = ifp->if_version; - brelse(bp); - return (version); -} - -/* Set values in the ifile for the inode. */ +/* Free an inode. */ +/* ARGUSED */ void -lfs_iset(ip, daddr, atime) +lfs_ifree(ip, notused1, notused2) INODE *ip; - daddr_t daddr; - time_t atime; + ino_t notused1; + int notused2; { BUF *bp; IFILE *ifp; LFS *fs; ino_t ino; -printf("lfs_iset: setting ino %d daddr %lx time %lx\n", -ip->i_number, daddr, atime); - +#ifdef ALLOCPRINT + printf("lfs_ifree: free %d\n", ip->i_number); +#endif + /* Get the inode number and file system. */ fs = ip->i_lfs; ino = ip->i_number; + + /* + * Read the appropriate block from the ifile. Set the inode entry to + * unused, increment its version number and link it into the free chain. + */ LFS_IENTRY(ifp, fs, ino, bp); + ifp->if_daddr = LFS_UNUSED_DADDR; + ++ifp->if_version; + ifp->if_nextfree = fs->lfs_free; + fs->lfs_free = ino; - ifp->if_daddr = daddr; - ifp->if_st_atime = atime; lfs_bwrite(bp); + + /* Set superblock modified bit and decrement file count. */ + fs->lfs_fmod = 1; + --fs->lfs_nfiles; } -#endif /* LOGFS */ -- 2.20.1