diff options
| author | Rick Macklem <rmacklem@FreeBSD.org> | 2021-08-29 23:46:27 +0000 |
|---|---|---|
| committer | Rick Macklem <rmacklem@FreeBSD.org> | 2021-09-15 23:01:41 +0000 |
| commit | e5d000b333830ad2795ec3a265b3d2f499b4065c (patch) | |
| tree | 763e1182d7bc87da7ef4a807604e9666dfbb0bd6 | |
| parent | aac5428f48ef8267a77efeffa821d00da86ee705 (diff) | |
nfsd: Make loop calling VOP_ALLOCATE() iterate until done
The NFSv4.2 Deallocate operation loops on VOP_DEALLOCATE()
while progress is being made (remaining length decreasing).
This patch changes the loop on VOP_ALLOCATE() for the NFSv4.2
Allocate operation do the same, instead of stopping after
an arbitrary 20 iterations.
(cherry picked from commit 13914e51eb8de6fe9f627c9c1d48c09880b2607e)
| -rw-r--r-- | sys/fs/nfsserver/nfs_nfsdport.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index efe9aac7a136..f48e57e449c9 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -6399,7 +6399,8 @@ int nfsvno_allocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred, NFSPROC_T *p) { - int error, trycnt; + int error; + off_t olen; ASSERT_VOP_ELOCKED(vp, "nfsvno_allocate vp"); /* @@ -6410,15 +6411,17 @@ nfsvno_allocate(struct vnode *vp, off_t off, off_t len, struct ucred *cred, NULL, NULL, NULL, NULL, &len, 0, NULL); if (error != ENOENT) return (error); - error = 0; /* - * Do the actual VOP_ALLOCATE(), looping a reasonable number of - * times to achieve completion. + * Do the actual VOP_ALLOCATE(), looping so long as + * progress is being made, to achieve completion. */ - trycnt = 0; - while (error == 0 && len > 0 && trycnt++ < 20) + do { + olen = len; error = VOP_ALLOCATE(vp, &off, &len); + if (error == 0 && len > 0 && olen > len) + maybe_yield(); + } while (error == 0 && len > 0 && olen > len); if (error == 0 && len > 0) error = NFSERR_IO; NFSEXITCODE(error); |
