Fix for a bug in halt that could cause it not to wait until the changes were written if there was an ongoing write at the time halt was issued. Reference: /n/patches.lsub.org/patch/creepyhalt Date: Tue Apr 17 10:59:19 CES 2012 Signed-off-by: nemo@lsub.org --- /sys/src/cmd/creepy/9p.c Wed Apr 11 18:41:53 2012 +++ /sys/src/cmd/creepy/9p.c Tue Apr 17 10:45:14 2012 @@ -761,10 +761,6 @@ rpcworker9p(rpc, aux); else getworker(rpcworker9p, rpc, nil); - if(fs->halt){ - warn("halted"); - threadexitsall(nil); - } rpc = nil; } putcli(cli); --- /sys/src/cmd/creepy/cfg.c Fri Mar 30 14:03:12 2012 +++ /sys/src/cmd/creepy/cfg.c Tue Apr 17 10:45:27 2012 @@ -539,8 +539,8 @@ static void chalt(int, char**) { - fssync(); fs->halt = 1; + fssync(); } static void --- /sys/src/cmd/creepy/fsys.c Wed Apr 11 22:41:22 2012 +++ /sys/src/cmd/creepy/fsys.c Tue Apr 17 10:54:07 2012 @@ -12,21 +12,6 @@ Nfsops, }; - - -BUG: -issuing a halt calls a freeze and starts the write but does NOT -wait for the write to complete before killing all threads, so data -is lost because not everything is written. - -Check out that halt indeed waits for the write to complete!! - -freezing fs... -freezing fs... -fs frozen -writing fs... -creepy/9pix: /dev/sdC0/creepy: halted - Fsys *fs; uvlong maxfsz; @@ -606,6 +591,10 @@ fs->wtime = fstime(nsec()); xqunlock(&fs->fzlk); dZprint("fs written (2*%ld refs %ld data)\n", nr, nb); + if(fs->halt){ + warn("halted. exiting."); + threadexitsall(nil); + } } static void --- /sys/src/cmd/creepy/ix.c Wed Apr 11 18:42:56 2012 +++ /sys/src/cmd/creepy/ix.c Tue Apr 17 10:45:37 2012 @@ -641,10 +641,6 @@ rpcworkerix(rpc->c, aux); else getworker(rpcworkerix, rpc->c, nil); - if(fs->halt){ - fprint(2, "%s: halted\n", argv0); - threadexitsall(nil); - } } putcli(cli); dPprint("%s exiting\n", threadgetname());