Module Name: src
Committed By: pooka
Date: Mon Nov 1 16:27:08 UTC 2010
Modified Files:
src/tests/fs/common: fstest_puffs.c
Log Message:
Make the shovel threads resilient to file server exit.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/fs/common/fstest_puffs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/fs/common/fstest_puffs.c
diff -u src/tests/fs/common/fstest_puffs.c:1.5 src/tests/fs/common/fstest_puffs.c:1.6
--- src/tests/fs/common/fstest_puffs.c:1.5 Sun Oct 31 22:33:16 2010
+++ src/tests/fs/common/fstest_puffs.c Mon Nov 1 16:27:07 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: fstest_puffs.c,v 1.5 2010/10/31 22:33:16 pgoyette Exp $ */
+/* $NetBSD: fstest_puffs.c,v 1.6 2010/11/01 16:27:07 pooka Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -53,6 +53,8 @@
#define BUFSIZE (128*1024)
#define DTFS_DUMP "-o","dump"
+static bool mayquit = false;
+
/*
* Threads which shovel data between comfd and /dev/puffs.
* (cannot use polling since fd's are in different namespaces)
@@ -64,6 +66,7 @@
struct puffs_req *preq;
struct puffstestargs *args = arg;
char buf[BUFSIZE];
+ ssize_t n;
int comfd, puffsfd;
comfd = args->pta_servfd;
@@ -75,8 +78,6 @@
rump_pub_lwproc_newlwp(1);
for (;;) {
- ssize_t n;
-
n = rump_sys_read(puffsfd, buf, sizeof(*phdr));
if (n <= 0) {
fprintf(stderr, "readshovel r1 %zd / %d\n", n, errno);
@@ -107,7 +108,9 @@
}
}
- abort();
+ if (n != 0 && mayquit == false)
+ abort();
+ return NULL;
}
static void *
@@ -115,8 +118,10 @@
{
struct puffstestargs *args = arg;
struct putter_hdr *phdr;
+ struct puffs_req *preq;
char buf[BUFSIZE];
size_t toread;
+ ssize_t n;
int comfd, puffsfd;
rump_pub_lwproc_newlwp(1);
@@ -125,10 +130,10 @@
puffsfd = args->pta_rumpfd;
phdr = (struct putter_hdr *)buf;
+ preq = (void *)buf;
for (;;) {
uint64_t off;
- ssize_t n;
/*
* Need to write everything to the "kernel" in one chunk,
@@ -142,7 +147,7 @@
if (n <= 0) {
fprintf(stderr, "writeshovel read %zd / %d\n",
n, errno);
- break;
+ goto out;
}
off += n;
if (off >= sizeof(struct putter_hdr))
@@ -151,6 +156,13 @@
toread = off - sizeof(struct putter_hdr);
} while (toread);
+ if (__predict_false(
+ PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS
+ && preq->preq_optype == PUFFS_VFS_UNMOUNT)) {
+ if (preq->preq_rv == 0)
+ mayquit = true;
+ }
+
n = rump_sys_write(puffsfd, buf, phdr->pth_framelen);
if ((size_t)n != phdr->pth_framelen) {
fprintf(stderr, "writeshovel wr %zd / %d\n", n, errno);
@@ -158,7 +170,10 @@
}
}
- abort();
+ out:
+ if (n != 0)
+ abort();
+ return NULL;
}
static void