Work around the shortness of the size argument to

vnode_create_vobject() while preserving the binary ABI
to filesystem modules in RELENG_6: introduce a new function
vnode_create_vobject_off() that takes the size argument
as off_t; move all stock file systems to it; re-implement
the old vnode_create_vobject() using vnode_create_vobject_off()
so that old or binary-only FS modules can work w/o hitting the
bug.  The trick is to pass a size of 0 to vnode_create_vobject_off()
so that it will call VOP_GETATTR() and thus get the actual,
untruncated file size even if the calling module still uses
the old vnode_create_vobject().

PR:		kern/92243
Approved by:	re (scottl)
This commit is contained in:
yar 2006-02-20 00:53:15 +00:00
parent 5ae1a9f419
commit dbcb706f58
17 changed files with 39 additions and 17 deletions

View File

@ -929,7 +929,7 @@ msdosfs_fhtovp(mp, fhp, vpp)
return (error);
}
*vpp = DETOV(dep);
vnode_create_vobject(*vpp, dep->de_FileSize, curthread);
vnode_create_vobject_off(*vpp, dep->de_FileSize, curthread);
return (0);
}

View File

@ -221,7 +221,7 @@ msdosfs_open(ap)
} */ *ap;
{
struct denode *dep = VTODE(ap->a_vp);
vnode_create_vobject(ap->a_vp, dep->de_FileSize, ap->a_td);
vnode_create_vobject_off(ap->a_vp, dep->de_FileSize, ap->a_td);
return 0;
}

View File

@ -621,7 +621,7 @@ ntfs_fhtovp(
/* XXX as unlink/rmdir/mkdir/creat are not currently possible
* with NTFS, we don't need to check anything else for now */
*vpp = nvp;
vnode_create_vobject(nvp, VTOF(nvp)->f_size, curthread);
vnode_create_vobject_off(nvp, VTOF(nvp)->f_size, curthread);
return (0);
}

View File

@ -441,7 +441,7 @@ ntfs_open(ap)
printf("ntfs_open: %d\n",ip->i_number);
#endif
vnode_create_vobject(ap->a_vp, VTOF(ap->a_vp)->f_size, ap->a_td);
vnode_create_vobject_off(ap->a_vp, VTOF(ap->a_vp)->f_size, ap->a_td);
/*
* Files marked append-only must be opened for appending.

View File

@ -214,7 +214,7 @@ smbfs_open(ap)
}
if (error == 0) {
np->n_flag |= NOPEN;
vnode_create_vobject(ap->a_vp, vattr.va_size, ap->a_td);
vnode_create_vobject_off(ap->a_vp, vattr.va_size, ap->a_td);
}
smbfs_attr_cacheremove(vp);
return error;

View File

@ -692,7 +692,7 @@ udf_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
}
*vpp = nvp;
vnode_create_vobject(*vpp, 0, curthread);
vnode_create_vobject_off(*vpp, 0, curthread);
return (0);
}

View File

@ -147,7 +147,7 @@ g_vfs_open(struct vnode *vp, struct g_consumer **cpp, const char *fsname, int wr
g_wither_geom(gp, ENXIO);
return (error);
}
vnode_create_vobject(vp, pp->mediasize, curthread);
vnode_create_vobject_off(vp, pp->mediasize, curthread);
*cpp = cp;
bo = &vp->v_bufobj;
bo->bo_ops = g_vfs_bufops;

View File

@ -1085,7 +1085,7 @@ ext2_fhtovp(mp, fhp, vpp)
return (ESTALE);
}
*vpp = nvp;
vnode_create_vobject(*vpp, 0, curthread);
vnode_create_vobject_off(*vpp, 0, curthread);
return (0);
}

View File

@ -255,7 +255,7 @@ ext2_open(ap)
(ap->a_mode & (FWRITE | O_APPEND)) == FWRITE)
return (EPERM);
vnode_create_vobject(ap->a_vp, VTOI(ap->a_vp)->i_size, ap->a_td);
vnode_create_vobject_off(ap->a_vp, VTOI(ap->a_vp)->i_size, ap->a_td);
return (0);
}

View File

@ -154,7 +154,7 @@ reiserfs_open(struct vop_open_args *ap)
(ap->a_mode & (FWRITE | O_APPEND)) == FWRITE)
return (EPERM);
vnode_create_vobject(ap->a_vp, VTOI(ap->a_vp)->i_size, ap->a_td);
vnode_create_vobject_off(ap->a_vp, VTOI(ap->a_vp)->i_size, ap->a_td);
return (0);
}

View File

@ -618,7 +618,7 @@ cd9660_fhtovp(mp, fhp, vpp)
return (ESTALE);
}
*vpp = nvp;
vnode_create_vobject(*vpp, ip->i_size, curthread);
vnode_create_vobject_off(*vpp, ip->i_size, curthread);
return (0);
}

View File

@ -170,7 +170,7 @@ cd9660_open(ap)
{
struct iso_node *ip = VTOI(ap->a_vp);
vnode_create_vobject(ap->a_vp, ip->i_size, ap->a_td);
vnode_create_vobject_off(ap->a_vp, ip->i_size, ap->a_td);
return 0;
}

View File

@ -466,7 +466,7 @@ nfs_open(struct vop_open_args *ap)
np->n_directio_opens++;
}
np->ra_expect_lbn = 0;
vnode_create_vobject(vp, vattr.va_size, ap->a_td);
vnode_create_vobject_off(vp, vattr.va_size, ap->a_td);
return (0);
}

View File

@ -716,6 +716,7 @@ int vrefcnt(struct vnode *vp);
void v_addpollinfo(struct vnode *vp);
int vnode_create_vobject(struct vnode *vp, size_t size, struct thread *td);
int vnode_create_vobject_off(struct vnode *vp, off_t size, struct thread *td);
void vnode_destroy_vobject(struct vnode *vp);
extern struct vop_vector fifo_specops;

View File

@ -205,6 +205,6 @@ ufs_fhtovp(mp, ufhp, vpp)
return (ESTALE);
}
*vpp = nvp;
vnode_create_vobject(*vpp, DIP(ip, i_size), curthread);
vnode_create_vobject_off(*vpp, DIP(ip, i_size), curthread);
return (0);
}

View File

@ -245,7 +245,7 @@ ufs_open(struct vop_open_args *ap)
if ((ip->i_flags & APPEND) &&
(ap->a_mode & (FWRITE | O_APPEND)) == FWRITE)
return (EPERM);
vnode_create_vobject(vp, DIP(ip, i_size), ap->a_td);
vnode_create_vobject_off(vp, DIP(ip, i_size), ap->a_td);
return (0);
}

View File

@ -95,9 +95,30 @@ struct pagerops vnodepagerops = {
int vnode_pbuf_freecnt;
/* Create the VM system backing object for this vnode */
/*
* Compatibility function for RELENG_6, in which vnode_create_vobject()
* takes file size as size_t due to an oversight. The type may not just
* change to off_t because the ABI to 3rd party modules must be preserved
* for RELENG_6 lifetime.
*/
int
vnode_create_vobject(struct vnode *vp, size_t isize, struct thread *td)
vnode_create_vobject(struct vnode *vp, size_t isize __unused, struct thread *td)
{
/*
* Size of 0 will indicate to vnode_create_vobject_off()
* VOP_GETATTR() is to be called to get the actual size.
*/
return (vnode_create_vobject_off(vp, 0, td));
}
/*
* Create the VM system backing object for this vnode -- for RELENG_6 only.
* In HEAD, vnode_create_vobject() has been fixed to take file size as off_t
* and so it can be used as is.
*/
int
vnode_create_vobject_off(struct vnode *vp, off_t isize, struct thread *td)
{
vm_object_t object;
vm_ooffset_t size = isize;