Page MenuHomeFreeBSD

D31829.diff
No OneTemporary

D31829.diff

diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -3162,6 +3162,7 @@
size_t copylen, len, rem, savlen;
char *dat;
long holein, holeout;
+ struct timespec curts, endts;
holein = holeout = 0;
savlen = len = *lenp;
@@ -3258,7 +3259,15 @@
* in the inner loop where the data copying is done.
* Note that some file systems such as NFSv3, NFSv4.0 and NFSv4.1 may
* support holes on the server, but do not support FIOSEEKHOLE.
+ * The kernel flag COPY_FILE_RANGE_TIMEO1SEC is used to indicate
+ * that this function should return after 1second with a partial
+ * completion.
*/
+ if ((flags & COPY_FILE_RANGE_TIMEO1SEC) != 0) {
+ getnanouptime(&endts);
+ endts.tv_sec++;
+ } else
+ timespecclear(&endts);
holetoeof = eof = false;
while (len > 0 && error == 0 && !eof && interrupted == 0) {
endoff = 0; /* To shut up compilers. */
@@ -3327,8 +3336,17 @@
*inoffp += xfer;
*outoffp += xfer;
len -= xfer;
- if (len < savlen)
+ if (len < savlen) {
interrupted = sig_intr();
+ if (timespecisset(&endts) &&
+ interrupted == 0) {
+ getnanouptime(&curts);
+ if (timespeccmp(&curts,
+ &endts, >=))
+ interrupted =
+ EINTR;
+ }
+ }
}
}
copylen = MIN(len, endoff - startoff);
@@ -3391,8 +3409,17 @@
*outoffp += xfer;
copylen -= xfer;
len -= xfer;
- if (len < savlen)
+ if (len < savlen) {
interrupted = sig_intr();
+ if (timespecisset(&endts) &&
+ interrupted == 0) {
+ getnanouptime(&curts);
+ if (timespeccmp(&curts,
+ &endts, >=))
+ interrupted =
+ EINTR;
+ }
+ }
}
}
xfer = blksize;
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -616,6 +616,10 @@
#define VN_OPEN_NAMECACHE 0x00000004
#define VN_OPEN_INVFS 0x00000008
+/* copy_file_range kernel flags */
+#define COPY_FILE_RANGE_KFLAGS 0xff000000
+#define COPY_FILE_RANGE_TIMEO1SEC 0x01000000 /* Return after 1sec. */
+
/*
* Public vnode manipulation functions.
*/

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 24, 2:10 PM (16 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17760309
Default Alt Text
D31829.diff (2 KB)

Event Timeline