Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/fs/common Make the shovel threads resilient to file se...
details: https://anonhg.NetBSD.org/src/rev/13e98e675b55
branches: trunk
changeset: 758314:13e98e675b55
user: pooka <pooka%NetBSD.org@localhost>
date: Mon Nov 01 16:27:07 2010 +0000
description:
Make the shovel threads resilient to file server exit.
diffstat:
tests/fs/common/fstest_puffs.c | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diffs (104 lines):
diff -r 4746908c165d -r 13e98e675b55 tests/fs/common/fstest_puffs.c
--- a/tests/fs/common/fstest_puffs.c Mon Nov 01 16:22:37 2010 +0000
+++ b/tests/fs/common/fstest_puffs.c Mon Nov 01 16:27:07 2010 +0000
@@ -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
Home |
Main Index |
Thread Index |
Old Index