Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F112077547
D44309.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D44309.diff
View Options
diff --git a/sys/kern/vfs_vnops.c.sparse b/sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c.sparse
+++ b/sys/kern/vfs_vnops.c
@@ -3273,14 +3273,15 @@
struct vnode *outvp, off_t *outoffp, size_t *lenp, unsigned int flags,
struct ucred *incred, struct ucred *outcred, struct thread *fsize_td)
{
+ struct vattr inva;
struct mount *mp;
off_t startoff, endoff, xfer, xfer2;
u_long blksize;
int error, interrupted;
- bool cantseek, readzeros, eof, lastblock, holetoeof;
+ bool cantseek, readzeros, eof, lastblock, holetoeof, sparse;
ssize_t aresid, r = 0;
size_t copylen, len, savlen;
- off_t insize, outsize;
+ off_t outsize;
char *dat;
long holein, holeout;
struct timespec curts, endts;
@@ -3296,11 +3297,26 @@
goto out;
if (VOP_PATHCONF(invp, _PC_MIN_HOLE_SIZE, &holein) != 0)
holein = 0;
- error = vn_getsize_locked(invp, &insize, incred);
+ error = VOP_GETATTR(invp, &inva, incred);
+ if (error == 0 && inva.va_size > OFF_MAX)
+ error = EFBIG;
VOP_UNLOCK(invp);
if (error != 0)
goto out;
+ /*
+ * Use va_bytes >= va_size as a hint that the file does not have
+ * sufficient holes to justify the overhead of doing FIOSEEKHOLE.
+ * This hint does not work well for file systems doing compression
+ * and may fail when allocations for extended attributes increases
+ * the value of va_bytes to >= va_size.
+ */
+ sparse = true;
+ if (holein != 0 && inva.va_bytes >= inva.va_size) {
+ holein = 0;
+ sparse = false;
+ }
+
mp = NULL;
error = vn_start_write(outvp, &mp, V_WAIT);
if (error == 0)
@@ -3334,9 +3350,9 @@
error = vn_getsize_locked(outvp, &outsize, outcred);
if (error == 0 && outsize > *outoffp &&
*outoffp <= OFF_MAX - len && outsize <= *outoffp + len &&
- *inoffp < insize &&
- *outoffp <= OFF_MAX - (insize - *inoffp) &&
- outsize <= *outoffp + (insize - *inoffp)) {
+ *inoffp < inva.va_size &&
+ *outoffp <= OFF_MAX - (inva.va_size - *inoffp) &&
+ outsize <= *outoffp + (inva.va_size - *inoffp)) {
#ifdef MAC
error = mac_vnode_check_write(curthread->td_ucred,
outcred, outvp);
@@ -3354,7 +3370,7 @@
if (error != 0)
goto out;
- if (holein == 0 && holeout > 0) {
+ if (sparse && holein == 0 && holeout > 0) {
/*
* For this special case, the input data will be scanned
* for blocks of all 0 bytes. For these blocks, the
@@ -3425,7 +3441,7 @@
error = VOP_IOCTL(invp, FIOSEEKDATA, &startoff, 0,
incred, curthread);
if (error == ENXIO) {
- startoff = endoff = insize;
+ startoff = endoff = inva.va_size;
eof = holetoeof = true;
error = 0;
}
@@ -3488,6 +3504,8 @@
cantseek = false;
} else {
cantseek = true;
+ if (!sparse)
+ cantseek = false;
startoff = *inoffp;
copylen = len;
error = 0;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 13, 12:16 PM (18 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17121993
Default Alt Text
D44309.diff (2 KB)
Attached To
Mode
D44309: Use va_bytes >= va_size as a hint that a file is not sparse for vn_generic_copy_file_range()
Attached
Detach File
Event Timeline
Log In to Comment