Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix deadlock when handling a P9_TFLUSH (issue 44)
This was a regression introduced recently with the threadpool reorganization. A lock was not dropped on successful flushing of a request, resulting in server deadlock. Added regression test kern/t35 for this. Also added a test user/t15 for another tflush problem (issue 45)
- Loading branch information
Showing
13 changed files
with
220 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# svnadmin create $PATH_MNTDIR/svnroot | ||
|
||
echo creating 100mb file | ||
dd if=/dev/zero of=$PATH_MNTDIR/file bs=1024k count=100 status=noxfer | ||
echo scrubbing | ||
scrub -s 100m $PATH_MNTDIR/file >/dev/null & | ||
echo interrupting | ||
sleep 0.5 | ||
kill -15 %1 | ||
wait %1 >/dev/null 2>&1 | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
kconjoin: diodmount exited with rc=0 | ||
creating 100mb file | ||
100+0 records in | ||
100+0 records out | ||
scrubbing | ||
interrupting | ||
kconjoin: t35 exited with rc=0 | ||
kconjoin: diod exited with rc=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
./tflush "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
tflush: sent 100 tversions | ||
tflush: sent 1 tflush | ||
tflush: received 100/101 responses | ||
conjoin: t15 exited with rc=0 | ||
conjoin: diod exited with rc=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/* tflush.c - issue 100 requests, flush one, read the responses */ | ||
|
||
#if HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
#include <pthread.h> | ||
#include <stdarg.h> | ||
#include <errno.h> | ||
#include <stdint.h> | ||
#include <inttypes.h> | ||
#include <assert.h> | ||
#include <signal.h> | ||
|
||
#include "9p.h" | ||
#include "npfs.h" | ||
#include "npclient.h" | ||
#include "npcimpl.h" | ||
|
||
#include "diod_log.h" | ||
#include "diod_auth.h" | ||
|
||
static void | ||
_flush_series (Npcfsys *fs, Npcfid *root); | ||
|
||
static void | ||
usage (void) | ||
{ | ||
fprintf (stderr, "Usage: tflush aname\n"); | ||
exit (1); | ||
} | ||
|
||
int | ||
main (int argc, char *argv[]) | ||
{ | ||
Npcfsys *fs; | ||
Npcfid *afid, *root; | ||
char *aname; | ||
int fd = 0; /* stdin */ | ||
uid_t uid = geteuid (); | ||
|
||
diod_log_init (argv[0]); | ||
|
||
if (argc != 2) | ||
usage (); | ||
aname = argv[1]; | ||
|
||
if (!(fs = npc_start (fd, 8192+24, 0))) | ||
errn_exit (np_rerror (), "npc_start"); | ||
if (!(afid = npc_auth (fs, aname, uid, diod_auth)) && np_rerror () != 0) | ||
errn_exit (np_rerror (), "npc_auth"); | ||
if (!(root = npc_attach (fs, afid, aname, uid))) | ||
errn_exit (np_rerror (), "npc_attach"); | ||
if (afid && npc_clunk (afid) < 0) | ||
errn_exit (np_rerror (), "npc_clunk afid"); | ||
|
||
_flush_series (fs, root); | ||
|
||
if (npc_clunk (root) < 0) | ||
errn_exit (np_rerror (), "npc_clunk root"); | ||
npc_finish (fs); | ||
|
||
diod_log_fini (); | ||
|
||
exit (0); | ||
} | ||
|
||
static void | ||
_alarm_clock (int sig) | ||
{ | ||
//msg ("alarm clock!"); | ||
} | ||
|
||
static void | ||
_flush_series (Npcfsys *fs, Npcfid *root) | ||
{ | ||
Npfcall *rc = NULL, *tc = NULL, *ac = NULL; | ||
u16 tag, flushtag; | ||
int n, i; | ||
struct sigaction sa; | ||
|
||
assert (fs->trans != NULL); | ||
|
||
sa.sa_flags = 0; | ||
sigemptyset(&sa.sa_mask); | ||
sa.sa_handler = _alarm_clock; | ||
if (sigaction (SIGALRM, &sa, NULL) < 0) | ||
err_exit ("sigaction"); | ||
|
||
/* write 100 tversions */ | ||
for (i = 0; i < 100; i++) { | ||
if (!(tc = np_create_tversion (fs->msize, "9P2000.L"))) | ||
msg_exit ("out of memory"); | ||
flushtag = tag = npc_get_id(fs->tagpool); | ||
np_set_tag(tc, tag); | ||
n = np_trans_write(fs->trans, tc->pkt, tc->size); | ||
if (n < 0) | ||
errn_exit (np_rerror (), "np_trans_write"); | ||
if (n != tc->size) | ||
msg_exit ("np_trans_write came up unexpectedly short"); | ||
//msg ("sent tversion tag %d", tc->tag); | ||
free(tc); | ||
} | ||
msg ("sent 100 tversions"); | ||
|
||
/* flush the most recent */ | ||
if (!(ac = np_create_tflush (flushtag))) | ||
msg_exit ("out of memory"); | ||
tag = npc_get_id(fs->tagpool); | ||
np_set_tag(ac, tag); | ||
n = np_trans_write(fs->trans, ac->pkt, ac->size); | ||
if (n < 0) | ||
errn_exit (np_rerror (), "np_trans_write"); | ||
if (n != ac->size) | ||
msg_exit ("np_trans_write came up unexpectedly short"); | ||
//msg ("sent tflush tag %d (flushing tag %d)", ac->tag, flushtag); | ||
free (ac); | ||
msg ("sent 1 tflush"); | ||
|
||
/* receive up to 101 responses with 1s timeout */ | ||
for (i = 0; i < 101; i++) { | ||
if (!(rc = malloc(sizeof(*rc) + fs->msize))) | ||
msg_exit ("out of memory"); | ||
rc->pkt = (u8*)rc + sizeof(*rc); | ||
alarm (1); | ||
n = np_trans_read(fs->trans, rc->pkt, fs->msize); | ||
if (n < 0) { | ||
if (errno == EINTR) | ||
break; | ||
errn_exit (np_rerror (), "np_trans_read"); | ||
} | ||
alarm (0); | ||
if (n == 0) | ||
msg_exit ("np_trans_read: unexpected EOF"); | ||
if (!np_deserialize (rc, rc->pkt)) | ||
msg_exit ("failed to deserialize response in one go"); | ||
//msg ("received tag %d", rc->tag); | ||
free(rc); | ||
//npc_put_id(fs->tagpool, rc->tag); | ||
} | ||
if (i == 100 || i == 101) | ||
msg ("received 100/101 respones"); | ||
else | ||
msg ("received %d responses", i); | ||
} | ||
|
||
/* | ||
* vi:tabstop=4 shiftwidth=4 expandtab | ||
*/ |