version 1.39.2.9, 2005/11/10 14:12:39 |
version 1.40, 2003/08/07 16:34:45 |
|
|
#include <sys/cdefs.h> |
#include <sys/cdefs.h> |
__KERNEL_RCSID(0, "$NetBSD$"); |
__KERNEL_RCSID(0, "$NetBSD$"); |
|
|
#if defined(_KERNEL_OPT) |
|
#include "opt_ffs.h" |
|
#include "opt_quota.h" |
#include "opt_quota.h" |
#endif |
|
|
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/systm.h> |
#include <sys/systm.h> |
Line 56 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 53 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <ufs/ufs/inode.h> |
#include <ufs/ufs/inode.h> |
#include <ufs/ufs/ufsmount.h> |
#include <ufs/ufs/ufsmount.h> |
#include <ufs/ufs/ufs_extern.h> |
#include <ufs/ufs/ufs_extern.h> |
#ifdef UFS_DIRHASH |
|
#include <ufs/ufs/dirhash.h> |
|
#endif |
|
#ifdef UFS_EXTATTR |
|
#include <ufs/ufs/extattr.h> |
|
#endif |
|
|
|
#include <uvm/uvm.h> |
#include <uvm/uvm.h> |
|
|
Line 71 extern int prtactive; |
|
Line 62 extern int prtactive; |
|
* Last reference to an inode. If necessary, write or delete it. |
* Last reference to an inode. If necessary, write or delete it. |
*/ |
*/ |
int |
int |
ufs_inactive(void *v) |
ufs_inactive(v) |
|
void *v; |
{ |
{ |
struct vop_inactive_args /* { |
struct vop_inactive_args /* { |
struct vnode *a_vp; |
struct vnode *a_vp; |
struct lwp *a_l; |
struct proc *a_p; |
} */ *ap = v; |
} */ *ap = v; |
struct vnode *vp = ap->a_vp; |
struct vnode *vp = ap->a_vp; |
struct inode *ip = VTOI(vp); |
struct inode *ip = VTOI(vp); |
struct mount *mp; |
struct proc *p = ap->a_p; |
struct lwp *l = ap->a_l; |
|
mode_t mode; |
mode_t mode; |
int error = 0; |
int error = 0; |
|
|
Line 96 ufs_inactive(void *v) |
|
Line 87 ufs_inactive(void *v) |
|
softdep_releasefile(ip); |
softdep_releasefile(ip); |
|
|
if (ip->i_nlink <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { |
if (ip->i_nlink <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { |
vn_start_write(vp, &mp, V_WAIT | V_LOWER); |
|
#ifdef QUOTA |
#ifdef QUOTA |
if (!getinoquota(ip)) |
if (!getinoquota(ip)) |
(void)chkiq(ip, -1, NOCRED, 0); |
(void)chkiq(ip, -1, NOCRED, 0); |
#endif |
#endif |
#ifdef UFS_EXTATTR |
|
ufs_extattr_vnode_inactive(vp, p); |
|
#endif |
|
if (ip->i_size != 0) { |
if (ip->i_size != 0) { |
error = UFS_TRUNCATE(vp, (off_t)0, 0, NOCRED, l); |
error = VOP_TRUNCATE(vp, (off_t)0, 0, NOCRED, p); |
} |
} |
/* |
/* |
* Setting the mode to zero needs to wait for the inode |
* Setting the mode to zero needs to wait for the inode |
Line 120 ufs_inactive(void *v) |
|
Line 107 ufs_inactive(void *v) |
|
ip->i_flag |= IN_CHANGE | IN_UPDATE; |
ip->i_flag |= IN_CHANGE | IN_UPDATE; |
if (DOINGSOFTDEP(vp)) |
if (DOINGSOFTDEP(vp)) |
softdep_change_linkcnt(ip); |
softdep_change_linkcnt(ip); |
UFS_VFREE(vp, ip->i_number, mode); |
VOP_VFREE(vp, ip->i_number, mode); |
vn_finished_write(mp, V_LOWER); |
|
} |
} |
|
|
if (ip->i_flag & (IN_CHANGE | IN_UPDATE | IN_MODIFIED)) { |
if (ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFIED | IN_ACCESSED)) |
vn_start_write(vp, &mp, V_WAIT | V_LOWER); |
VOP_UPDATE(vp, NULL, NULL, 0); |
UFS_UPDATE(vp, NULL, NULL, 0); |
|
vn_finished_write(mp, V_LOWER); |
|
} |
|
out: |
out: |
VOP_UNLOCK(vp, 0); |
VOP_UNLOCK(vp, 0); |
/* |
/* |
|
|
*/ |
*/ |
|
|
if (ip->i_mode == 0) |
if (ip->i_mode == 0) |
vrecycle(vp, NULL, l); |
vrecycle(vp, NULL, p); |
return (error); |
return (error); |
} |
} |
|
|
|
|
* Reclaim an inode so that it can be used for other purposes. |
* Reclaim an inode so that it can be used for other purposes. |
*/ |
*/ |
int |
int |
ufs_reclaim(struct vnode *vp, struct lwp *l) |
ufs_reclaim(vp, p) |
|
struct vnode *vp; |
|
struct proc *p; |
{ |
{ |
struct inode *ip = VTOI(vp); |
struct inode *ip; |
struct mount *mp; |
|
|
|
if (prtactive && vp->v_usecount != 0) |
if (prtactive && vp->v_usecount != 0) |
vprint("ufs_reclaim: pushing active", vp); |
vprint("ufs_reclaim: pushing active", vp); |
|
|
vn_start_write(vp, &mp, V_WAIT | V_LOWER); |
|
UFS_UPDATE(vp, NULL, NULL, UPDATE_CLOSE); |
|
vn_finished_write(mp, V_LOWER); |
|
|
|
/* |
/* |
* Remove the inode from its hash chain. |
* Remove the inode from its hash chain. |
*/ |
*/ |
|
ip = VTOI(vp); |
ufs_ihashrem(ip); |
ufs_ihashrem(ip); |
/* |
/* |
* Purge old data structures associated with the inode. |
* Purge old data structures associated with the inode. |
Line 180 ufs_reclaim(struct vnode *vp, struct lwp |
|
Line 160 ufs_reclaim(struct vnode *vp, struct lwp |
|
} |
} |
} |
} |
#endif |
#endif |
#ifdef UFS_DIRHASH |
|
if (ip->i_dirhash != NULL) |
|
ufsdirhash_free(ip); |
|
#endif |
|
return (0); |
return (0); |
} |
} |
|
|
Line 195 ufs_reclaim(struct vnode *vp, struct lwp |
|
Line 171 ufs_reclaim(struct vnode *vp, struct lwp |
|
*/ |
*/ |
|
|
int |
int |
ufs_balloc_range(struct vnode *vp, off_t off, off_t len, struct ucred *cred, |
ufs_balloc_range(vp, off, len, cred, flags) |
int flags) |
struct vnode *vp; |
|
off_t off, len; |
|
struct ucred *cred; |
|
int flags; |
{ |
{ |
off_t oldeof, neweof, oldeob, oldeop, neweob, pagestart; |
off_t oldeof, neweof, oldeob, oldeop, neweob, pagestart; |
off_t eob; |
|
struct uvm_object *uobj; |
struct uvm_object *uobj; |
struct genfs_node *gp = VTOG(vp); |
struct genfs_node *gp = VTOG(vp); |
int i, delta, error, npages; |
int i, delta, error, npages; |
Line 242 ufs_balloc_range(struct vnode *vp, off_t |
|
Line 220 ufs_balloc_range(struct vnode *vp, off_t |
|
memset(pgs, 0, npages * sizeof(struct vm_page *)); |
memset(pgs, 0, npages * sizeof(struct vm_page *)); |
simple_lock(&uobj->vmobjlock); |
simple_lock(&uobj->vmobjlock); |
error = VOP_GETPAGES(vp, pagestart, pgs, &npages, 0, |
error = VOP_GETPAGES(vp, pagestart, pgs, &npages, 0, |
VM_PROT_WRITE, 0, |
VM_PROT_READ, 0, PGO_SYNCIO|PGO_PASTEOF); |
PGO_SYNCIO|PGO_PASTEOF|PGO_NOBLOCKALLOC|PGO_NOTIMESTAMP); |
|
if (error) { |
if (error) { |
return error; |
return error; |
} |
} |
Line 279 ufs_balloc_range(struct vnode *vp, off_t |
|
Line 256 ufs_balloc_range(struct vnode *vp, off_t |
|
* (since they now have backing store) and unbusy them. |
* (since they now have backing store) and unbusy them. |
*/ |
*/ |
|
|
GOP_SIZE(vp, off + len, &eob, GOP_SIZE_WRITE); |
|
simple_lock(&uobj->vmobjlock); |
simple_lock(&uobj->vmobjlock); |
for (i = 0; i < npages; i++) { |
for (i = 0; i < npages; i++) { |
|
pgs[i]->flags &= ~PG_RDONLY; |
if (error) { |
if (error) { |
pgs[i]->flags |= PG_RELEASED; |
pgs[i]->flags |= PG_RELEASED; |
} else if (off <= pagestart + (i << PAGE_SHIFT) && |
|
pagestart + ((i + 1) << PAGE_SHIFT) <= eob) { |
|
pgs[i]->flags &= ~PG_RDONLY; |
|
} |
} |
} |
} |
if (error) { |
if (error) { |