Page MenuHomeFreeBSD

D2933.id6524.diff
No OneTemporary

D2933.id6524.diff

Index: usr.bin/ar/write.c
===================================================================
--- usr.bin/ar/write.c
+++ usr.bin/ar/write.c
@@ -41,6 +41,7 @@
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
+#include <unistd.h>
#include "ar.h"
@@ -61,6 +62,7 @@
static void free_obj(struct bsdar *bsdar, struct ar_obj *obj);
static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj,
struct ar_obj *pos);
+static void prefault_buffer(const char *buf, size_t s);
static void read_objs(struct bsdar *bsdar, const char *archive,
int checkargv);
static void write_archive(struct bsdar *bsdar, char mode);
@@ -551,11 +553,29 @@
}
/*
+ * Fault in the buffer prior to writing as a workaround for poor performance
+ * due to interaction with kernel fs deadlock avoidance code. See the comment
+ * prior to vn_io_fault_doio() in vfs_vnops.c for details of the issue.
+ */
+static void
+prefault_buffer(const char *buf, size_t s)
+{
+ volatile const char *p;
+ size_t page_size;
+
+ page_size = sysconf(_SC_PAGESIZE);
+ for (p = buf; p < buf + s;
+ p += page_size - ((uintptr_t)p & page_size - 1))
+ *p;
+}
+
+/*
* Wrapper for archive_write_data().
*/
static void
write_data(struct bsdar *bsdar, struct archive *a, const void *buf, size_t s)
{
+ prefault_buffer(buf, s);
if (archive_write_data(a, buf, s) != (ssize_t)s)
bsdar_errc(bsdar, EX_SOFTWARE, 0, "%s",
archive_error_string(a));

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 29, 11:13 PM (3 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32410273
Default Alt Text
D2933.id6524.diff (1 KB)

Event Timeline