vfs: Add "ioflag" and "cred" arguments to VOP_ALLOCATE

When the NFSv4.2 server does a VOP_ALLOCATE(), it needs
the operation to be done for the RPC's credential and not
td_ucred. It also needs the writing to be done synchronously.

This patch adds "ioflag" and "cred" arguments to VOP_ALLOCATE()
and modifies vop_stdallocate() to use these arguments.

The VOP_ALLOCATE.9 man page will be patched separately.

Reviewed by:	khng, kib
Differential Revision:	https://reviews.freebsd.org/D32865
This commit is contained in:
Rick Macklem 2021-11-06 13:26:43 -07:00
parent cc0b35259a
commit f0c9847a6c
5 changed files with 11 additions and 8 deletions

View File

@ -3731,7 +3731,7 @@ nfs_allocate(struct vop_allocate_args *ap)
if ((uint64_t)alen > nfs_maxalloclen)
alen = nfs_maxalloclen;
error = nfsrpc_allocate(vp, *ap->a_offset, alen,
&nfsva, &attrflag, td->td_ucred, td, NULL);
&nfsva, &attrflag, ap->a_cred, td, NULL);
}
if (error == 0) {
*ap->a_offset += alen;

View File

@ -6598,7 +6598,7 @@ nfsvno_allocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred,
*/
do {
olen = len;
error = VOP_ALLOCATE(vp, &off, &len);
error = VOP_ALLOCATE(vp, &off, &len, IO_SYNC, cred);
if (error == 0 && len > 0 && olen > len)
maybe_yield();
} while (error == 0 && len > 0 && olen > len);

View File

@ -963,7 +963,7 @@ vop_stdallocate(struct vop_allocate_args *ap)
len = *ap->a_len;
offset = *ap->a_offset;
error = VOP_GETATTR(vp, vap, td->td_ucred);
error = VOP_GETATTR(vp, vap, ap->a_cred);
if (error != 0)
goto out;
fsize = vap->va_size;
@ -1000,12 +1000,12 @@ vop_stdallocate(struct vop_allocate_args *ap)
*/
VATTR_NULL(vap);
vap->va_size = offset + len;
error = VOP_SETATTR(vp, vap, td->td_ucred);
error = VOP_SETATTR(vp, vap, ap->a_cred);
if (error != 0)
goto out;
VATTR_NULL(vap);
vap->va_size = fsize;
error = VOP_SETATTR(vp, vap, td->td_ucred);
error = VOP_SETATTR(vp, vap, ap->a_cred);
if (error != 0)
goto out;
}
@ -1031,7 +1031,7 @@ vop_stdallocate(struct vop_allocate_args *ap)
auio.uio_segflg = UIO_SYSSPACE;
auio.uio_rw = UIO_READ;
auio.uio_td = td;
error = VOP_READ(vp, &auio, 0, td->td_ucred);
error = VOP_READ(vp, &auio, ap->a_ioflag, ap->a_cred);
if (error != 0)
break;
if (auio.uio_resid > 0) {
@ -1052,7 +1052,7 @@ vop_stdallocate(struct vop_allocate_args *ap)
auio.uio_rw = UIO_WRITE;
auio.uio_td = td;
error = VOP_WRITE(vp, &auio, 0, td->td_ucred);
error = VOP_WRITE(vp, &auio, ap->a_ioflag, ap->a_cred);
if (error != 0)
break;

View File

@ -3466,7 +3466,8 @@ vn_fallocate(struct file *fp, off_t offset, off_t len, struct thread *td)
error = mac_vnode_check_write(td->td_ucred, fp->f_cred, vp);
if (error == 0)
#endif
error = VOP_ALLOCATE(vp, &offset, &len);
error = VOP_ALLOCATE(vp, &offset, &len, 0,
td->td_ucred);
VOP_UNLOCK(vp);
vn_finished_write(mp);

View File

@ -702,6 +702,8 @@ vop_allocate {
IN struct vnode *vp;
INOUT off_t *offset;
INOUT off_t *len;
IN int ioflag;
IN struct ucred *cred;
};