|
|
| version 1.11, 2004/03/23 22:54:32 | version 1.12, 2004/05/19 22:53:06 |
|---|---|
| Line 203 swapon(struct swapon_args *uap) | Line 203 swapon(struct swapon_args *uap) |
| vp = nd.ni_vp; | vp = nd.ni_vp; |
| if (vn_isdisk(vp, &error)) | if (vn_isdisk(vp, &error)) |
| error = swaponvp(td, vp, vp->v_rdev, 0); | error = swaponvp(td, vp, 0); |
| else if (vp->v_type == VREG && vp->v_tag == VT_NFS && | else if (vp->v_type == VREG && vp->v_tag == VT_NFS && |
| (error = VOP_GETATTR(vp, &attr, td)) == 0) { | (error = VOP_GETATTR(vp, &attr, td)) == 0) { |
| /* | /* |
| * Allow direct swapping to NFS regular files in the same | * Allow direct swapping to NFS regular files in the same |
| * way that nfs_mountroot() sets up diskless swapping. | * way that nfs_mountroot() sets up diskless swapping. |
| */ | */ |
| error = swaponvp(td, vp, NODEV, attr.va_size / DEV_BSIZE); | error = swaponvp(td, vp, attr.va_size / DEV_BSIZE); |
| } | } |
| if (error) | if (error) |
| Line 231 swapon(struct swapon_args *uap) | Line 231 swapon(struct swapon_args *uap) |
| * XXX locking when multiple swapon's run in parallel | * XXX locking when multiple swapon's run in parallel |
| */ | */ |
| int | int |
| swaponvp(struct thread *td, struct vnode *vp, dev_t dev, u_long nblks) | swaponvp(struct thread *td, struct vnode *vp, u_long nblks) |
| { | { |
| int index; | u_long aligned_nblks; |
| struct ucred *cred; | |
| struct swdevt *sp; | struct swdevt *sp; |
| swblk_t vsbase; | swblk_t vsbase; |
| long blk; | |
| swblk_t dvbase; | swblk_t dvbase; |
| dev_t dev; | |
| int index; | |
| int error; | int error; |
| u_long aligned_nblks; | long blk; |
| struct ucred *cred; | |
| KKASSERT(td->td_proc); | KKASSERT(td->td_proc); |
| cred = td->td_proc->p_ucred; | cred = td->td_proc->p_ucred; |
| Line 269 swaponvp(struct thread *td, struct vnode | Line 270 swaponvp(struct thread *td, struct vnode |
| if (error) | if (error) |
| return (error); | return (error); |
| /* | |
| * v_rdev is not valid until after the VOP_OPEN() call. dev_psize() | |
| * must be supported if a character device has been specified. | |
| */ | |
| if (vp->v_type == VCHR) | |
| dev = vp->v_rdev; | |
| else | |
| dev = NODEV; | |
| if (nblks == 0 && dev != NODEV && ((nblks = dev_dpsize(dev)) == -1)) { | if (nblks == 0 && dev != NODEV && ((nblks = dev_dpsize(dev)) == -1)) { |
| (void) VOP_CLOSE(vp, FREAD | FWRITE, td); | (void) VOP_CLOSE(vp, FREAD | FWRITE, td); |
| return (ENXIO); | return (ENXIO); |