Let the NFS client notice a file's size changing as a modification.
This avoids presenting invalid data to the client's applications when the file is modified, and then extended within the window of the resolution of the modifcation timestamp. Reviewed By: iedowse PR: kern/64091
This commit is contained in:
parent
5027176b20
commit
7c8ca9400e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=128263
@ -432,13 +432,15 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
|
||||
error = VOP_GETATTR(vp, &vattr, cred, td);
|
||||
if (error)
|
||||
return (error);
|
||||
if (np->n_mtime != vattr.va_mtime.tv_sec) {
|
||||
if ((np->n_flag & NSIZECHANGED)
|
||||
|| (np->n_mtime != vattr.va_mtime.tv_sec)) {
|
||||
if (vp->v_type == VDIR)
|
||||
(nmp->nm_rpcops->nr_invaldir)(vp);
|
||||
error = nfs_vinvalbuf(vp, V_SAVE, cred, td, 1);
|
||||
if (error)
|
||||
return (error);
|
||||
np->n_mtime = vattr.va_mtime.tv_sec;
|
||||
np->n_flag &= ~NSIZECHANGED;
|
||||
}
|
||||
}
|
||||
do {
|
||||
|
@ -601,12 +601,19 @@ nfs_loadattrcache(struct vnode **vpp, struct mbuf **mdp, caddr_t *dposp,
|
||||
vap->va_size = np->n_size;
|
||||
np->n_attrstamp = 0;
|
||||
} else if (np->n_flag & NMODIFIED) {
|
||||
if (vap->va_size < np->n_size)
|
||||
/*
|
||||
* We've modified the file: Use the larger
|
||||
* of our size, and the server's size.
|
||||
*/
|
||||
if (vap->va_size < np->n_size) {
|
||||
vap->va_size = np->n_size;
|
||||
else
|
||||
} else {
|
||||
np->n_size = vap->va_size;
|
||||
np->n_flag |= NSIZECHANGED;
|
||||
}
|
||||
} else {
|
||||
np->n_size = vap->va_size;
|
||||
np->n_flag |= NSIZECHANGED;
|
||||
}
|
||||
vnode_pager_setsize(vp, np->n_size);
|
||||
} else {
|
||||
|
@ -149,6 +149,7 @@ struct nfsnode {
|
||||
#define NCHG 0x0400 /* Special file times changed */
|
||||
#define NCREATED 0x0800 /* Opened by nfs_create() */
|
||||
#define NTRUNCATE 0x1000 /* Opened by nfs_setattr() */
|
||||
#define NSIZECHANGED 0x2000 /* File size has changed: need cache inval */
|
||||
|
||||
/*
|
||||
* Convert between nfsnode pointers and vnode pointers
|
||||
|
Loading…
Reference in New Issue
Block a user