projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
reorganization to move ufsmount ops to be vnode ops
[unix-history]
/
usr
/
src
/
sys
/
ufs
/
ffs
/
ffs_inode.c
diff --git
a/usr/src/sys/ufs/ffs/ffs_inode.c
b/usr/src/sys/ufs/ffs/ffs_inode.c
index
374f291
..
46899e7
100644
(file)
--- a/
usr/src/sys/ufs/ffs/ffs_inode.c
+++ b/
usr/src/sys/ufs/ffs/ffs_inode.c
@@
-4,7
+4,7
@@
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)ffs_inode.c 7.4
1
(Berkeley) %G%
+ * @(#)ffs_inode.c 7.4
2
(Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
@@
-42,34
+42,30
@@
ffs_init()
* return the inode locked. Detection and handling of mount
* points must be done by the calling routine.
*/
* return the inode locked. Detection and handling of mount
* points must be done by the calling routine.
*/
-ffs_
iget(pip, ino, i
pp)
- struct
inode *pi
p;
+ffs_
vget(mntp, ino, v
pp)
+ struct
mount *mnt
p;
ino_t ino;
ino_t ino;
- struct
inode **i
pp;
+ struct
vnode **v
pp;
{
{
- extern struct vnodeops ffs_vnodeops;
+ extern struct vnodeops ffs_vnodeops
, ffs_specops, ffs_fifoops
;
register struct fs *fs;
register struct inode *ip;
register struct fs *fs;
register struct inode *ip;
+ struct ufsmount *ump;
struct buf *bp;
struct dinode *dp;
struct buf *bp;
struct dinode *dp;
- struct mount *mntp;
struct vnode *vp;
union ihead *ih;
dev_t dev;
int i, error;
struct vnode *vp;
union ihead *ih;
dev_t dev;
int i, error;
- mntp = ITOV(pip)->v_mount;
- fs = VFSTOUFS(mntp)->um_fs;
- if (ino < ROOTINO || ino >= fs->fs_ncg * fs->fs_ipg)
- return (EINVAL);
-
- dev = pip->i_dev;
- if ((*ipp = ufs_ihashget(dev, ino)) != NULL)
+ ump = VFSTOUFS(mntp);
+ dev = ump->um_dev;
+ if ((*vpp = ufs_ihashget(dev, ino)) != NULL)
return (0);
/* Allocate a new vnode/inode. */
if (error = getnewvnode(VT_UFS, mntp, &ffs_vnodeops, &vp)) {
return (0);
/* Allocate a new vnode/inode. */
if (error = getnewvnode(VT_UFS, mntp, &ffs_vnodeops, &vp)) {
- *
i
pp = NULL;
+ *
v
pp = NULL;
return (error);
}
ip = VTOI(vp);
return (error);
}
ip = VTOI(vp);
@@
-79,6
+75,8
@@
ffs_iget(pip, ino, ipp)
ip->i_mode = 0;
ip->i_diroff = 0;
ip->i_lockf = 0;
ip->i_mode = 0;
ip->i_diroff = 0;
ip->i_lockf = 0;
+ ip->i_dev = dev;
+ ip->i_number = ino;
#ifdef QUOTA
for (i = 0; i < MAXQUOTAS; i++)
ip->i_dquot[i] = NODQUOT;
#ifdef QUOTA
for (i = 0; i < MAXQUOTAS; i++)
ip->i_dquot[i] = NODQUOT;
@@
-89,14
+87,11
@@
ffs_iget(pip, ino, ipp)
* for old data structures to be purged or for the contents of the
* disk portion of this inode to be read.
*/
* for old data structures to be purged or for the contents of the
* disk portion of this inode to be read.
*/
- ip->i_dev = dev;
- ip->i_number = ino;
- ip->i_fs = fs; /* XXX KIRK?? */
- ip->i_devvp = VFSTOUFS(mntp)->um_devvp;
ufs_ihashins(ip);
/* Read in the disk contents for the inode, copy into the inode. */
ufs_ihashins(ip);
/* Read in the disk contents for the inode, copy into the inode. */
- if (error = bread(VFSTOUFS(mntp)->um_devvp, fsbtodb(fs, itod(fs, ino)),
+ fs = ump->um_fs;
+ if (error = bread(ump->um_devvp, fsbtodb(fs, itod(fs, ino)),
(int)fs->fs_bsize, NOCRED, &bp)) {
/*
* The inode does not contain anything useful, so it would
(int)fs->fs_bsize, NOCRED, &bp)) {
/*
* The inode does not contain anything useful, so it would
@@
-110,7
+105,7
@@
ffs_iget(pip, ino, ipp)
/* Unlock and discard unneeded inode. */
ufs_iput(ip);
brelse(bp);
/* Unlock and discard unneeded inode. */
ufs_iput(ip);
brelse(bp);
- *
i
pp = NULL;
+ *
v
pp = NULL;
return (error);
}
dp = bp->b_un.b_dino;
return (error);
}
dp = bp->b_un.b_dino;
@@
-122,12
+117,18
@@
ffs_iget(pip, ino, ipp)
* Initialize the vnode from the inode, check for aliases. In all
* cases re-init ip, the underlying vnode/inode may have changed.
*/
* Initialize the vnode from the inode, check for aliases. In all
* cases re-init ip, the underlying vnode/inode may have changed.
*/
- if (error = ufs_vinit(mntp, &vp)) {
+ if (error = ufs_vinit(mntp, &
ffs_specops, &ffs_fifoops, &
vp)) {
ufs_iput(ip);
ufs_iput(ip);
- *
i
pp = NULL;
+ *
v
pp = NULL;
return (error);
}
return (error);
}
+ /*
+ * Finish inode initialization now that aliasing has been resolved.
+ */
ip = VTOI(vp);
ip = VTOI(vp);
+ ip->i_fs = fs;
+ ip->i_devvp = ump->um_devvp;
+ VREF(ip->i_devvp);
/*
* Set up a generation number for this inode if it does not
/*
* Set up a generation number for this inode if it does not
@@
-140,13
+141,13
@@
ffs_iget(pip, ino, ipp)
if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
ip->i_flag |= IMOD;
}
if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
ip->i_flag |= IMOD;
}
- *
ipp = i
p;
+ *
vpp = v
p;
return (0);
}
/*
* Update the access, modified, and inode change times as specified
return (0);
}
/*
* Update the access, modified, and inode change times as specified
- * by the IACC, I
MOD, and ICHG flags respectively. The IUP
D flag
+ * by the IACC, I
UPD, and ICHG flags respectively. The IMO
D flag
* is used to specify that the inode needs to be updated but that
* the times have already been set. The access and modified times
* are taken from the second and third parameters; the inode change
* is used to specify that the inode needs to be updated but that
* the times have already been set. The access and modified times
* are taken from the second and third parameters; the inode change
@@
-154,27
+155,21
@@
ffs_iget(pip, ino, ipp)
* then wait for the disk write of the inode to complete.
*/
int
* then wait for the disk write of the inode to complete.
*/
int
-ffs_
iupdat(i
p, ta, tm, waitfor)
- register struct
inode *i
p;
+ffs_
update(v
p, ta, tm, waitfor)
+ register struct
vnode *v
p;
struct timeval *ta, *tm;
int waitfor;
{
struct buf *bp;
struct timeval *ta, *tm;
int waitfor;
{
struct buf *bp;
- struct
vnode *vp = ITOV(ip)
;
+ struct
inode *ip
;
struct dinode *dp;
register struct fs *fs;
struct dinode *dp;
register struct fs *fs;
- fs = ip->i_fs;
- if ((ip->i_flag & (IUPD|IACC|ICHG|IMOD)) == 0)
- return (0);
if (vp->v_mount->mnt_flag & MNT_RDONLY)
return (0);
if (vp->v_mount->mnt_flag & MNT_RDONLY)
return (0);
- error = bread(ip->i_devvp, fsbtodb(fs, itod(fs, ip->i_number)),
- (int)fs->fs_bsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
+ ip = VTOI(vp);
+ if ((ip->i_flag & (IUPD|IACC|ICHG|IMOD)) == 0)
+ return (0);
if (ip->i_flag&IACC)
ip->i_atime = ta->tv_sec;
if (ip->i_flag&IUPD)
if (ip->i_flag&IACC)
ip->i_atime = ta->tv_sec;
if (ip->i_flag&IUPD)
@@
-182,11
+177,18
@@
ffs_iupdat(ip, ta, tm, waitfor)
if (ip->i_flag&ICHG)
ip->i_ctime = time.tv_sec;
ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
if (ip->i_flag&ICHG)
ip->i_ctime = time.tv_sec;
ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD);
+
+ fs = ip->i_fs;
+ if (error = bread(ip->i_devvp, fsbtodb(fs, itod(fs, ip->i_number)),
+ (int)fs->fs_bsize, NOCRED, &bp)) {
+ brelse(bp);
+ return (error);
+ }
dp = bp->b_un.b_dino + itoo(fs, ip->i_number);
*dp = ip->i_din;
dp = bp->b_un.b_dino + itoo(fs, ip->i_number);
*dp = ip->i_din;
- if (waitfor)
{
+ if (waitfor)
return (bwrite(bp));
return (bwrite(bp));
-
}
else {
+ else {
bdwrite(bp);
return (0);
}
bdwrite(bp);
return (0);
}
@@
-201,12
+203,13
@@
ffs_iupdat(ip, ta, tm, waitfor)
*
* NB: triple indirect blocks are untested.
*/
*
* NB: triple indirect blocks are untested.
*/
-ffs_
itrunc(oi
p, length, flags)
- register struct
inode *oi
p;
+ffs_
truncate(ov
p, length, flags)
+ register struct
vnode *ov
p;
u_long length;
int flags;
{
register daddr_t lastblock;
u_long length;
int flags;
{
register daddr_t lastblock;
+ register struct inode *oip;
daddr_t bn, lbn, lastiblock[NIADDR];
register struct fs *fs;
register struct inode *ip;
daddr_t bn, lbn, lastiblock[NIADDR];
register struct fs *fs;
register struct inode *ip;
@@
-217,10
+220,11
@@
ffs_itrunc(oip, length, flags)
int aflags, error, allerror;
struct inode tip;
int aflags, error, allerror;
struct inode tip;
- vnode_pager_setsize(ITOV(oip), length);
+ vnode_pager_setsize(ovp, length);
+ oip = VTOI(ovp);
if (oip->i_size <= length) {
oip->i_flag |= ICHG|IUPD;
if (oip->i_size <= length) {
oip->i_flag |= ICHG|IUPD;
- error = ffs_
iupdat(oi
p, &time, &time, 1);
+ error = ffs_
update(ov
p, &time, &time, 1);
return (error);
}
/*
return (error);
}
/*
@@
-284,7
+288,7
@@
ffs_itrunc(oip, length, flags)
oip->i_db[i] = 0;
oip->i_flag |= ICHG|IUPD;
vinvalbuf(ITOV(oip), (length > 0));
oip->i_db[i] = 0;
oip->i_flag |= ICHG|IUPD;
vinvalbuf(ITOV(oip), (length > 0));
- allerror = ffs_
iupdat(oi
p, &time, &time, MNT_WAIT);
+ allerror = ffs_
update(ov
p, &time, &time, MNT_WAIT);
/*
* Indirect blocks first.
/*
* Indirect blocks first.