DF-5171 / fix.diff
--- vcd.c.orig +++ vcd.c @@ -161,9 +161,27 @@ n = pwrite(sc->fd, bp->b_data, bp->b_bcount, bio->bio_offset); break; + case BUF_CMD_FLUSH: + /* + * Mirror vkd_doio() (vdisk.c:332-337): push any + * cached writes in the backing file to the store. + * HAMMER issues device flushes during mount + * recovery and on every flusher cycle + * (hammer_io_flush_sync, hammer_io.c:1985-2007). + */ + if (fsync(sc->fd) < 0) + n = -1; + else + n = bp->b_bcount; + break; default: - panic("vcd: bad b_cmd %d", bp->b_cmd); - break; /* not reached */ + /* + * Other commands (e.g. BUF_CMD_FREEBLKS/TRIM): + * nothing to do for a file-backed virtual CD. + * Complete the bio instead of panicking. + */ + n = bp->b_bcount; + break; } if (n != bp->b_bcount) { bp->b_error = EIO; |