Lines 301-306
int newnfs_directio_allow_mmap = 1;
Link Here
|
301 |
SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_allow_mmap, CTLFLAG_RW, |
301 |
SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_allow_mmap, CTLFLAG_RW, |
302 |
&newnfs_directio_allow_mmap, 0, "Enable mmaped IO on file with O_DIRECT opens"); |
302 |
&newnfs_directio_allow_mmap, 0, "Enable mmaped IO on file with O_DIRECT opens"); |
303 |
|
303 |
|
|
|
304 |
static int lookupcnt = 0; |
305 |
SYSCTL_INT(_vfs_nfs, OID_AUTO, lookupcnt, CTLFLAG_RD, |
306 |
&lookupcnt, 0, " "); |
307 |
|
304 |
static uint64_t nfs_maxalloclen = 64 * 1024 * 1024; |
308 |
static uint64_t nfs_maxalloclen = 64 * 1024 * 1024; |
305 |
SYSCTL_U64(_vfs_nfs, OID_AUTO, maxalloclen, CTLFLAG_RW, |
309 |
SYSCTL_U64(_vfs_nfs, OID_AUTO, maxalloclen, CTLFLAG_RW, |
306 |
&nfs_maxalloclen, 0, "NFS max allocate/deallocate length"); |
310 |
&nfs_maxalloclen, 0, "NFS max allocate/deallocate length"); |
Lines 1014-1019
nfs_setattr(struct vop_setattr_args *ap)
Link Here
|
1014 |
struct vattr *vap = ap->a_vap; |
1018 |
struct vattr *vap = ap->a_vap; |
1015 |
int error = 0; |
1019 |
int error = 0; |
1016 |
u_quad_t tsize; |
1020 |
u_quad_t tsize; |
|
|
1021 |
struct timespec ts; |
1017 |
|
1022 |
|
1018 |
#ifndef nolint |
1023 |
#ifndef nolint |
1019 |
tsize = (u_quad_t)0; |
1024 |
tsize = (u_quad_t)0; |
Lines 1108-1118
nfs_setattr(struct vop_setattr_args *ap)
Link Here
|
1108 |
NFSUNLOCKNODE(np); |
1113 |
NFSUNLOCKNODE(np); |
1109 |
} |
1114 |
} |
1110 |
error = nfs_setattrrpc(vp, vap, ap->a_cred, td); |
1115 |
error = nfs_setattrrpc(vp, vap, ap->a_cred, td); |
1111 |
if (error && vap->va_size != VNOVAL) { |
1116 |
if (vap->va_size != VNOVAL) { |
1112 |
NFSLOCKNODE(np); |
1117 |
if (error == 0) { |
1113 |
np->n_size = np->n_vattr.na_size = tsize; |
1118 |
nanouptime(&ts); |
1114 |
vnode_pager_setsize(vp, tsize); |
1119 |
NFSLOCKNODE(np); |
1115 |
NFSUNLOCKNODE(np); |
1120 |
np->n_localmodtime = ts; |
|
|
1121 |
NFSUNLOCKNODE(np); |
1122 |
} else { |
1123 |
NFSLOCKNODE(np); |
1124 |
np->n_size = np->n_vattr.na_size = tsize; |
1125 |
vnode_pager_setsize(vp, tsize); |
1126 |
NFSUNLOCKNODE(np); |
1127 |
} |
1116 |
} |
1128 |
} |
1117 |
return (error); |
1129 |
return (error); |
1118 |
} |
1130 |
} |
Lines 1169-1175
nfs_lookup(struct vop_lookup_args *ap)
Link Here
|
1169 |
struct nfsfh *nfhp; |
1181 |
struct nfsfh *nfhp; |
1170 |
struct nfsvattr dnfsva, nfsva; |
1182 |
struct nfsvattr dnfsva, nfsva; |
1171 |
struct vattr vattr; |
1183 |
struct vattr vattr; |
1172 |
struct timespec nctime; |
1184 |
struct timespec nctime, ts; |
1173 |
uint32_t openmode; |
1185 |
uint32_t openmode; |
1174 |
|
1186 |
|
1175 |
*vpp = NULLVP; |
1187 |
*vpp = NULLVP; |
Lines 1293-1298
nfs_lookup(struct vop_lookup_args *ap)
Link Here
|
1293 |
|
1305 |
|
1294 |
newvp = NULLVP; |
1306 |
newvp = NULLVP; |
1295 |
NFSINCRGLOBAL(nfsstatsv1.lookupcache_misses); |
1307 |
NFSINCRGLOBAL(nfsstatsv1.lookupcache_misses); |
|
|
1308 |
nanouptime(&ts); |
1296 |
error = nfsrpc_lookup(dvp, cnp->cn_nameptr, cnp->cn_namelen, |
1309 |
error = nfsrpc_lookup(dvp, cnp->cn_nameptr, cnp->cn_namelen, |
1297 |
cnp->cn_cred, td, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, |
1310 |
cnp->cn_cred, td, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, |
1298 |
NULL, openmode); |
1311 |
NULL, openmode); |
Lines 1359-1364
nfs_lookup(struct vop_lookup_args *ap)
Link Here
|
1359 |
if (error) |
1372 |
if (error) |
1360 |
return (error); |
1373 |
return (error); |
1361 |
newvp = NFSTOV(np); |
1374 |
newvp = NFSTOV(np); |
|
|
1375 |
/* |
1376 |
* If n_localmodtime >= time before RPC, then |
1377 |
* a file modification operation, such as |
1378 |
* VOP_SETATTR() of size, has occurred while |
1379 |
* the Lookup RPC and acquisition of the vnode |
1380 |
* happened. As such, the attributes might |
1381 |
* be stale, with possibly an incorrect size. |
1382 |
*/ |
1383 |
NFSLOCKNODE(np); |
1384 |
if (timespecisset(&np->n_localmodtime) && |
1385 |
timespeccmp(&np->n_localmodtime, &ts, >=)) |
1386 |
{ lookupcnt++; |
1387 |
attrflag = 0; |
1388 |
} |
1389 |
NFSUNLOCKNODE(np); |
1362 |
if (attrflag) |
1390 |
if (attrflag) |
1363 |
(void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, |
1391 |
(void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, |
1364 |
0, 1); |
1392 |
0, 1); |
Lines 1418-1423
nfs_lookup(struct vop_lookup_args *ap)
Link Here
|
1418 |
if (error) |
1446 |
if (error) |
1419 |
return (error); |
1447 |
return (error); |
1420 |
newvp = NFSTOV(np); |
1448 |
newvp = NFSTOV(np); |
|
|
1449 |
/* |
1450 |
* If n_localmodtime >= time before RPC, then |
1451 |
* a file modification operation, such as |
1452 |
* VOP_SETATTR() of size, has occurred while |
1453 |
* the Lookup RPC and acquisition of the vnode |
1454 |
* happened. As such, the attributes might |
1455 |
* be stale, with possibly an incorrect size. |
1456 |
*/ |
1457 |
NFSLOCKNODE(np); |
1458 |
if (timespecisset(&np->n_localmodtime) && |
1459 |
timespeccmp(&np->n_localmodtime, &ts, >=)) |
1460 |
{ lookupcnt++; |
1461 |
attrflag = 0; |
1462 |
} |
1463 |
NFSUNLOCKNODE(np); |
1421 |
if (attrflag) |
1464 |
if (attrflag) |
1422 |
(void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, |
1465 |
(void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, |
1423 |
0, 1); |
1466 |
0, 1); |
Lines 3643-3653
nfs_allocate(struct vop_allocate_args *ap)
Link Here
|
3643 |
struct thread *td = curthread; |
3686 |
struct thread *td = curthread; |
3644 |
struct nfsvattr nfsva; |
3687 |
struct nfsvattr nfsva; |
3645 |
struct nfsmount *nmp; |
3688 |
struct nfsmount *nmp; |
|
|
3689 |
struct nfsnode *np; |
3646 |
off_t alen; |
3690 |
off_t alen; |
3647 |
int attrflag, error, ret; |
3691 |
int attrflag, error, ret; |
|
|
3692 |
struct timespec ts; |
3648 |
|
3693 |
|
3649 |
attrflag = 0; |
3694 |
attrflag = 0; |
3650 |
nmp = VFSTONFS(vp->v_mount); |
3695 |
nmp = VFSTONFS(vp->v_mount); |
|
|
3696 |
np = VTONFS(vp); |
3651 |
mtx_lock(&nmp->nm_mtx); |
3697 |
mtx_lock(&nmp->nm_mtx); |
3652 |
if (NFSHASNFSV4(nmp) && nmp->nm_minorvers >= NFSV42_MINORVERSION && |
3698 |
if (NFSHASNFSV4(nmp) && nmp->nm_minorvers >= NFSV42_MINORVERSION && |
3653 |
(nmp->nm_privflag & NFSMNTP_NOALLOCATE) == 0) { |
3699 |
(nmp->nm_privflag & NFSMNTP_NOALLOCATE) == 0) { |
Lines 3667-3672
nfs_allocate(struct vop_allocate_args *ap)
Link Here
|
3667 |
if (error == 0) { |
3713 |
if (error == 0) { |
3668 |
*ap->a_offset += alen; |
3714 |
*ap->a_offset += alen; |
3669 |
*ap->a_len -= alen; |
3715 |
*ap->a_len -= alen; |
|
|
3716 |
nanouptime(&ts); |
3717 |
NFSLOCKNODE(np); |
3718 |
np->n_localmodtime = ts; |
3719 |
NFSUNLOCKNODE(np); |
3670 |
} else if (error == NFSERR_NOTSUPP) { |
3720 |
} else if (error == NFSERR_NOTSUPP) { |
3671 |
mtx_lock(&nmp->nm_mtx); |
3721 |
mtx_lock(&nmp->nm_mtx); |
3672 |
nmp->nm_privflag |= NFSMNTP_NOALLOCATE; |
3722 |
nmp->nm_privflag |= NFSMNTP_NOALLOCATE; |
Lines 3701-3706
nfs_deallocate(struct vop_deallocate_args *ap)
Link Here
|
3701 |
off_t tlen, mlen; |
3751 |
off_t tlen, mlen; |
3702 |
int attrflag, error, ret; |
3752 |
int attrflag, error, ret; |
3703 |
bool clipped; |
3753 |
bool clipped; |
|
|
3754 |
struct timespec ts; |
3704 |
|
3755 |
|
3705 |
error = 0; |
3756 |
error = 0; |
3706 |
attrflag = 0; |
3757 |
attrflag = 0; |
Lines 3743-3748
nfs_deallocate(struct vop_deallocate_args *ap)
Link Here
|
3743 |
if (error == 0) { |
3794 |
if (error == 0) { |
3744 |
NFSCL_DEBUG(4, "dealloc: attrflag=%d na_size=%ju\n", |
3795 |
NFSCL_DEBUG(4, "dealloc: attrflag=%d na_size=%ju\n", |
3745 |
attrflag, (uintmax_t)nfsva.na_size); |
3796 |
attrflag, (uintmax_t)nfsva.na_size); |
|
|
3797 |
nanouptime(&ts); |
3798 |
NFSLOCKNODE(np); |
3799 |
np->n_localmodtime = ts; |
3800 |
NFSUNLOCKNODE(np); |
3746 |
if (attrflag != 0) { |
3801 |
if (attrflag != 0) { |
3747 |
if ((uint64_t)*ap->a_offset < nfsva.na_size) |
3802 |
if ((uint64_t)*ap->a_offset < nfsva.na_size) |
3748 |
*ap->a_offset += omin((off_t) |
3803 |
*ap->a_offset += omin((off_t) |