VOP_BALLOC was never really a VOP in the first place, so convert it

to UFS_BALLOC like the other "between UFS and FFS function interfaces".
This commit is contained in:
Poul-Henning Kamp 2001-04-29 12:36:52 +00:00
parent b7ebffbc08
commit 855aa097af
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=76132
14 changed files with 48 additions and 61 deletions

View File

@ -96,6 +96,7 @@ struct ufsmount {
int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */
struct malloc_type *um_malloctype; /* The inodes malloctype */
int um_i_effnlink_valid; /* i_effnlink valid? */
int (*um_balloc) __P((struct vnode *, off_t, int, struct ucred *, int, struct buf **));
int (*um_blkatoff) __P((struct vnode *, off_t, char **, struct buf **));
int (*um_truncate) __P((struct vnode *, off_t, int, struct ucred *, struct proc *));
int (*um_update) __P((struct vnode *, int));
@ -103,6 +104,7 @@ struct ufsmount {
int (*um_vfree) __P((struct vnode *, ino_t, int));
};
#define UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff)
#define UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
#define UFS_TRUNCATE(aa, bb, cc, dd, ee) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd, ee)
#define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)

View File

@ -96,6 +96,7 @@ struct ufsmount {
int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */
struct malloc_type *um_malloctype; /* The inodes malloctype */
int um_i_effnlink_valid; /* i_effnlink valid? */
int (*um_balloc) __P((struct vnode *, off_t, int, struct ucred *, int, struct buf **));
int (*um_blkatoff) __P((struct vnode *, off_t, char **, struct buf **));
int (*um_truncate) __P((struct vnode *, off_t, int, struct ucred *, struct proc *));
int (*um_update) __P((struct vnode *, int));
@ -103,6 +104,7 @@ struct ufsmount {
int (*um_vfree) __P((struct vnode *, ino_t, int));
};
#define UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff)
#define UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
#define UFS_TRUNCATE(aa, bb, cc, dd, ee) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd, ee)
#define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)

View File

@ -426,18 +426,6 @@ vop_advlock {
IN int flags;
};
#
#% balloc vp L L L
#
vop_balloc {
IN struct vnode *vp;
IN off_t startoffset;
IN int size;
IN struct ucred *cred;
IN int flags;
OUT struct buf **bpp;
};
#
#% reallocblks vp L L L
#

View File

@ -55,15 +55,8 @@
* the inode and the logical block number in a file.
*/
int
ffs_balloc(ap)
struct vop_balloc_args /* {
struct vnode *a_vp;
ufs_daddr_t a_lbn;
int a_size;
struct ucred *a_cred;
int a_flags;
struct buf *a_bpp;
} */ *ap;
ffs_balloc(struct vnode *a_vp, off_t a_startoffset, int a_size,
struct ucred *a_cred, int a_flags, struct buf **a_bpp)
{
struct inode *ip;
ufs_daddr_t lbn;
@ -81,18 +74,18 @@ ffs_balloc(ap)
int unwindidx = -1;
struct proc *p = curproc; /* XXX */
vp = ap->a_vp;
vp = a_vp;
ip = VTOI(vp);
fs = ip->i_fs;
lbn = lblkno(fs, ap->a_startoffset);
size = blkoff(fs, ap->a_startoffset) + ap->a_size;
lbn = lblkno(fs, a_startoffset);
size = blkoff(fs, a_startoffset) + a_size;
if (size > fs->fs_bsize)
panic("ffs_balloc: blk too big");
*ap->a_bpp = NULL;
*a_bpp = NULL;
if (lbn < 0)
return (EFBIG);
cred = ap->a_cred;
flags = ap->a_flags;
cred = a_cred;
flags = a_flags;
/*
* If the next write will extend the file into a new block,
@ -135,7 +128,7 @@ ffs_balloc(ap)
return (error);
}
bp->b_blkno = fsbtodb(fs, nb);
*ap->a_bpp = bp;
*a_bpp = bp;
return (0);
}
if (nb != 0) {
@ -182,7 +175,7 @@ ffs_balloc(ap)
}
ip->i_db[lbn] = dbtofsb(fs, bp->b_blkno);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
*ap->a_bpp = bp;
*a_bpp = bp;
return (0);
}
/*
@ -294,7 +287,7 @@ ffs_balloc(ap)
* If asked only for the indirect block, then return it.
*/
if (flags & B_METAONLY) {
*ap->a_bpp = bp;
*a_bpp = bp;
return (0);
}
/*
@ -329,7 +322,7 @@ ffs_balloc(ap)
bp->b_flags |= B_CLUSTEROK;
bdwrite(bp);
}
*ap->a_bpp = nbp;
*a_bpp = nbp;
return (0);
}
brelse(bp);
@ -343,7 +336,7 @@ ffs_balloc(ap)
nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
}
*ap->a_bpp = nbp;
*a_bpp = nbp;
return (0);
fail:
/*

View File

@ -55,7 +55,8 @@ struct vop_copyonwrite_args;
int ffs_alloc __P((struct inode *,
ufs_daddr_t, ufs_daddr_t, int, struct ucred *, ufs_daddr_t *));
int ffs_balloc __P((struct vop_balloc_args *));
int ffs_balloc __P((struct vnode *a_vp, off_t a_startoffset, int a_size,
struct ucred *a_cred, int a_flags, struct buf **a_bpp));
int ffs_blkatoff __P((struct vnode *, off_t, char **, struct buf **));
void ffs_blkfree __P((struct inode *, ufs_daddr_t, long));
ufs_daddr_t ffs_blkpref __P((struct inode *, ufs_daddr_t, int, ufs_daddr_t *));

View File

@ -214,7 +214,7 @@ ffs_truncate(vp, length, flags, cred, p)
aflags = B_CLRBUF;
if (flags & IO_SYNC)
aflags |= B_SYNC;
error = VOP_BALLOC(ovp, length - 1, 1,
error = UFS_BALLOC(ovp, length - 1, 1,
cred, aflags, &bp);
if (error)
return (error);
@ -244,7 +244,7 @@ ffs_truncate(vp, length, flags, cred, p)
aflags = B_CLRBUF;
if (flags & IO_SYNC)
aflags |= B_SYNC;
error = VOP_BALLOC(ovp, length - 1, 1, cred, aflags, &bp);
error = UFS_BALLOC(ovp, length - 1, 1, cred, aflags, &bp);
if (error) {
return (error);
}

View File

@ -161,7 +161,7 @@ ffs_snapshot(mp, snapfile)
* to set size to that of the filesystem.
*/
numblks = howmany(fs->fs_size, fs->fs_frag);
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)(numblks - 1)),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)(numblks - 1)),
fs->fs_bsize, KERNCRED, B_CLRBUF, &bp);
if (error)
goto out;
@ -182,7 +182,7 @@ ffs_snapshot(mp, snapfile)
* needing to be copied.
*/
for (blkno = NDADDR; blkno < numblks; blkno += NINDIR(fs)) {
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)blkno),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)blkno),
fs->fs_bsize, p->p_ucred, B_METAONLY, &ibp);
if (error)
goto out;
@ -193,7 +193,7 @@ ffs_snapshot(mp, snapfile)
panic("ffs_snapshot: lost direct block");
ip->i_db[iblkno] = BLK_NOCOPY;
} else {
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)iblkno),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)iblkno),
fs->fs_bsize, KERNCRED, B_METAONLY, &ibp);
if (error)
goto out;
@ -219,7 +219,7 @@ ffs_snapshot(mp, snapfile)
break;
if (i == inoblkcnt) {
inoblks[inoblkcnt++] = blkno;
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)blkno),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)blkno),
fs->fs_bsize, KERNCRED, 0, &nbp);
if (error)
goto out;
@ -230,7 +230,7 @@ ffs_snapshot(mp, snapfile)
* Allocate all cylinder group blocks.
*/
for (cg = 0; cg < fs->fs_ncg; cg++) {
error = VOP_BALLOC(vp, (off_t)(cgtod(fs, cg)) << fs->fs_fshift,
error = UFS_BALLOC(vp, (off_t)(cgtod(fs, cg)) << fs->fs_fshift,
fs->fs_bsize, KERNCRED, 0, &nbp);
if (error)
goto out;
@ -239,13 +239,13 @@ ffs_snapshot(mp, snapfile)
/*
* Allocate copies for the superblock and its summary information.
*/
if ((error = VOP_BALLOC(vp, (off_t)(SBOFF), SBSIZE, KERNCRED, 0, &nbp)))
if ((error = UFS_BALLOC(vp, (off_t)(SBOFF), SBSIZE, KERNCRED, 0, &nbp)))
goto out;
bawrite(nbp);
blkno = fragstoblks(fs, fs->fs_csaddr);
len = howmany(fs->fs_cssize, fs->fs_bsize);
for (loc = 0; loc < len; loc++) {
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)(blkno + loc)),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)(blkno + loc)),
fs->fs_bsize, KERNCRED, 0, &nbp);
if (error)
goto out;
@ -316,7 +316,7 @@ ffs_snapshot(mp, snapfile)
ip->i_db[loc] = BLK_NOCOPY;
}
}
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)(base + loc)),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)(base + loc)),
fs->fs_bsize, KERNCRED, B_METAONLY, &ibp);
if (error) {
brelse(bp);
@ -327,7 +327,7 @@ ffs_snapshot(mp, snapfile)
if (indiroff >= NINDIR(fs)) {
ibp->b_flags |= B_VALIDSUSPWRT;
bawrite(ibp);
error = VOP_BALLOC(vp,
error = UFS_BALLOC(vp,
lblktosize(fs, (off_t)(base + loc)),
fs->fs_bsize, KERNCRED, B_METAONLY, &ibp);
if (error) {
@ -349,7 +349,7 @@ ffs_snapshot(mp, snapfile)
/*
* Snapshot the superblock and its summary information.
*/
if ((error = VOP_BALLOC(vp, SBOFF, SBSIZE, KERNCRED, 0, &nbp)) != 0)
if ((error = UFS_BALLOC(vp, SBOFF, SBSIZE, KERNCRED, 0, &nbp)) != 0)
goto out1;
copy_fs = (struct fs *)(nbp->b_data + blkoff(fs, SBOFF));
bcopy(fs, copy_fs, fs->fs_sbsize);
@ -365,7 +365,7 @@ ffs_snapshot(mp, snapfile)
size = fs->fs_bsize;
space = fs->fs_csp;
for (loc = 0; loc <= len; loc++) {
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)(blkno + loc)),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)(blkno + loc)),
fs->fs_bsize, KERNCRED, 0, &nbp);
if (error)
goto out1;
@ -383,7 +383,7 @@ ffs_snapshot(mp, snapfile)
* the copies can can be expunged.
*/
for (loc = 0; loc < inoblkcnt; loc++) {
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)inoblks[loc]),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)inoblks[loc]),
fs->fs_bsize, KERNCRED, 0, &nbp);
if (error)
goto out1;
@ -424,7 +424,7 @@ ffs_snapshot(mp, snapfile)
* Set copied snapshot inode to be a zero length file.
*/
blkno = fragstoblks(fs, ino_to_fsba(fs, xp->i_number));
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)blkno),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)blkno),
fs->fs_bsize, KERNCRED, 0, &nbp);
if (error)
goto out1;
@ -563,7 +563,7 @@ snapacct(vp, oldblkp, lastblkp)
blkp = &ip->i_db[lbn];
ip->i_flag |= IN_CHANGE | IN_UPDATE;
} else {
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)lbn),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, B_METAONLY, &ibp);
if (error)
return (error);
@ -665,7 +665,7 @@ ffs_snapremove(vp)
ip->i_db[blkno] = 0;
}
for (blkno = NDADDR; blkno < fs->fs_size; blkno += NINDIR(fs)) {
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)blkno),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)blkno),
fs->fs_bsize, KERNCRED, B_METAONLY, &ibp);
if (error)
continue;
@ -732,7 +732,7 @@ ffs_snapblkfree(freeip, bno, size)
} else {
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
p->p_flag |= P_COWINPROGRESS;
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)lbn),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, B_METAONLY, &ibp);
p->p_flag &= ~P_COWINPROGRESS;
VOP_UNLOCK(vp, 0, p);
@ -815,7 +815,7 @@ ffs_snapblkfree(freeip, bno, size)
*/
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
p->p_flag |= P_COWINPROGRESS;
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)lbn),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, 0, &cbp);
p->p_flag &= ~P_COWINPROGRESS;
if (error) {
@ -974,13 +974,13 @@ ffs_copyonwrite(devvp, bp)
* We ensure that everything of our own that needs to be
* copied will be done at the time that ffs_snapshot is
* called. Thus we can skip the check here which can
* deadlock in doing the lookup in VOP_BALLOC.
* deadlock in doing the lookup in UFS_BALLOC.
*/
if (bp->b_vp == vp)
continue;
/*
* Check to see if block needs to be copied. We have to
* be able to do the VOP_BALLOC without blocking, otherwise
* be able to do the UFS_BALLOC without blocking, otherwise
* we may get in a deadlock with another process also
* trying to allocate. If we find outselves unable to
* get the buffer lock, we unlock the snapshot vnode,
@ -992,7 +992,7 @@ ffs_copyonwrite(devvp, bp)
blkno = ip->i_db[lbn];
} else {
p->p_flag |= P_COWINPROGRESS;
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)lbn),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, B_METAONLY | B_NOWAIT, &ibp);
p->p_flag &= ~P_COWINPROGRESS;
if (error) {
@ -1020,7 +1020,7 @@ ffs_copyonwrite(devvp, bp)
* the snapshot inode.
*/
p->p_flag |= P_COWINPROGRESS;
error = VOP_BALLOC(vp, lblktosize(fs, (off_t)lbn),
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, B_NOWAIT, &cbp);
p->p_flag &= ~P_COWINPROGRESS;
if (error) {

View File

@ -625,6 +625,7 @@ ffs_mountfs(devvp, mp, p, malloctype)
ump->um_update = ffs_update;
ump->um_valloc = ffs_valloc;
ump->um_vfree = ffs_vfree;
ump->um_balloc = ffs_balloc;
bcopy(bp->b_data, ump->um_fs, (u_int)fs->fs_sbsize);
if (fs->fs_sbsize < SBSIZE)
bp->b_flags |= B_INVAL | B_NOCACHE;

View File

@ -79,7 +79,6 @@ static struct vnodeopv_entry_desc ffs_vnodeop_entries[] = {
{ &vop_getpages_desc, (vop_t *) ffs_getpages },
{ &vop_putpages_desc, (vop_t *) ffs_putpages },
{ &vop_read_desc, (vop_t *) ffs_read },
{ &vop_balloc_desc, (vop_t *) ffs_balloc },
{ &vop_reallocblks_desc, (vop_t *) ffs_reallocblks },
{ &vop_write_desc, (vop_t *) ffs_write },
#ifdef UFS_EXTATTR

View File

@ -100,7 +100,6 @@ static struct vnodeopv_entry_desc ifs_vnodeop_entries[] = {
{ &vop_getpages_desc, (vop_t *) ffs_getpages },
{ &vop_putpages_desc, (vop_t *) ffs_putpages },
{ &vop_read_desc, (vop_t *) ffs_read },
{ &vop_balloc_desc, (vop_t *) ffs_balloc },
{ &vop_reallocblks_desc, (vop_t *) ffs_reallocblks },
{ &vop_write_desc, (vop_t *) ffs_write },

View File

@ -719,7 +719,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp)
flags = B_CLRBUF;
if (!DOINGSOFTDEP(dvp) && !DOINGASYNC(dvp))
flags |= B_SYNC;
if ((error = VOP_BALLOC(dvp, (off_t)dp->i_offset, DIRBLKSIZ,
if ((error = UFS_BALLOC(dvp, (off_t)dp->i_offset, DIRBLKSIZ,
cr, flags, &bp)) != 0) {
if (DOINGSOFTDEP(dvp) && newdirbp != NULL)
bdwrite(newdirbp);

View File

@ -484,7 +484,7 @@ WRITE(ap)
flags &= ~B_CLRBUF;
#endif
/* XXX is uio->uio_offset the right thing here? */
error = VOP_BALLOC(vp, uio->uio_offset, xfersize,
error = UFS_BALLOC(vp, uio->uio_offset, xfersize,
ap->a_cred, flags, &bp);
if (error != 0)
break;

View File

@ -1531,7 +1531,7 @@ ufs_mkdir(ap)
dirtemplate = *dtp;
dirtemplate.dot_ino = ip->i_number;
dirtemplate.dotdot_ino = dp->i_number;
if ((error = VOP_BALLOC(tvp, (off_t)0, DIRBLKSIZ, cnp->cn_cred,
if ((error = UFS_BALLOC(tvp, (off_t)0, DIRBLKSIZ, cnp->cn_cred,
B_CLRBUF, &bp)) != 0)
goto bad;
ip->i_size = DIRBLKSIZ;

View File

@ -96,6 +96,7 @@ struct ufsmount {
int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */
struct malloc_type *um_malloctype; /* The inodes malloctype */
int um_i_effnlink_valid; /* i_effnlink valid? */
int (*um_balloc) __P((struct vnode *, off_t, int, struct ucred *, int, struct buf **));
int (*um_blkatoff) __P((struct vnode *, off_t, char **, struct buf **));
int (*um_truncate) __P((struct vnode *, off_t, int, struct ucred *, struct proc *));
int (*um_update) __P((struct vnode *, int));
@ -103,6 +104,7 @@ struct ufsmount {
int (*um_vfree) __P((struct vnode *, ino_t, int));
};
#define UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff)
#define UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
#define UFS_TRUNCATE(aa, bb, cc, dd, ee) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd, ee)
#define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)