FreeBSD Bugzilla – Attachment 224603 Details for
Bug 255523
vn_generic_copy_file_range copies holes to EOF slowly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
add support for a hole to eof to vn_generic_copy_range()
cpholetoeof.patch (text/plain), 2.87 KB, created by
Rick Macklem
on 2021-05-02 01:56:04 UTC
(
hide
)
Description:
add support for a hole to eof to vn_generic_copy_range()
Filename:
MIME Type:
Creator:
Rick Macklem
Created:
2021-05-02 01:56:04 UTC
Size:
2.87 KB
patch
obsolete
>--- sys/kern/vfs_vnops.c.sav 2021-05-01 07:58:23.141555000 -0700 >+++ sys/kern/vfs_vnops.c 2021-05-01 18:21:44.237271000 -0700 >@@ -3096,13 +3096,13 @@ vn_generic_copy_file_range(struct vnode *invp, off_t * > struct vnode *outvp, off_t *outoffp, size_t *lenp, unsigned int flags, > struct ucred *incred, struct ucred *outcred, struct thread *fsize_td) > { >- struct vattr va; >+ struct vattr va, inva; > struct mount *mp; > struct uio io; > off_t startoff, endoff, xfer, xfer2; > u_long blksize; > int error, interrupted; >- bool cantseek, readzeros, eof, lastblock; >+ bool cantseek, readzeros, eof, lastblock, holetoeof; > ssize_t aresid; > size_t copylen, len, rem, savlen; > char *dat; >@@ -3119,7 +3119,11 @@ vn_generic_copy_file_range(struct vnode *invp, off_t * > goto out; > if (VOP_PATHCONF(invp, _PC_MIN_HOLE_SIZE, &holein) != 0) > holein = 0; >+ if (holein > 0) >+ error = VOP_GETATTR(invp, &inva, incred); > VOP_UNLOCK(invp); >+ if (error != 0) >+ goto out; > > mp = NULL; > error = vn_start_write(outvp, &mp, V_WAIT); >@@ -3200,7 +3204,7 @@ vn_generic_copy_file_range(struct vnode *invp, off_t * > * Note that some file systems such as NFSv3, NFSv4.0 and NFSv4.1 may > * support holes on the server, but do not support FIOSEEKHOLE. > */ >- eof = false; >+ holetoeof = eof = false; > while (len > 0 && error == 0 && !eof && interrupted == 0) { > endoff = 0; /* To shut up compilers. */ > cantseek = true; >@@ -3209,8 +3213,7 @@ vn_generic_copy_file_range(struct vnode *invp, off_t * > > /* > * Find the next data area. If there is just a hole to EOF, >- * FIOSEEKDATA should fail and then we drop down into the >- * inner loop and create the hole on the outvp file. >+ * FIOSEEKDATA should fail with ENXIO. > * (I do not know if any file system will report a hole to > * EOF via FIOSEEKHOLE, but I am pretty sure FIOSEEKDATA > * will fail for those file systems.) >@@ -3219,10 +3222,16 @@ vn_generic_copy_file_range(struct vnode *invp, off_t * > * the code just falls through to the inner copy loop. > */ > error = EINVAL; >- if (holein > 0) >+ if (holein > 0) { > error = VOP_IOCTL(invp, FIOSEEKDATA, &startoff, 0, > incred, curthread); >- if (error == 0) { >+ if (error == ENXIO) { >+ startoff = endoff = inva.va_size; >+ eof = holetoeof = true; >+ error = 0; >+ } >+ } >+ if (error == 0 && !holetoeof) { > endoff = startoff; > error = VOP_IOCTL(invp, FIOSEEKHOLE, &endoff, 0, > incred, curthread); >@@ -3253,11 +3262,12 @@ vn_generic_copy_file_range(struct vnode *invp, off_t * > } > > if (error == 0 && *outoffp + xfer > >- va.va_size && xfer == len) >- /* Grow last block. */ >+ va.va_size && (xfer == len || holetoeof)) { >+ /* Grow output file (hole at end). */ > error = vn_write_outvp(outvp, dat, > *outoffp, xfer, blksize, true, > false, outcred); >+ } > if (error == 0) { > *inoffp += xfer; > *outoffp += xfer;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 255523
:
224599
| 224603