Unlike other disk drivers, vnd(4) allows raw reads and writes of
partial blocks. E.g., if configured with a 512-byte sector size, it
will still allow commands like:
$ dd if=/dev/rvnd0c bs=42 skip=4096 count=1
(The same command will fail against /dev/rsd0c or if count=1 is
changed to count=2.)
Unfortunately, some of the distrib scripts currently rely on this
behavior (e.g., at least sgi and socppc). I'd like to suggest the
diff below to help identify any others without causing any breakage.
It simply prints to dmesg whenever a partial block read or write is
attempted; e.g., for the above dd(1) command I got:
vnd0: sloppy read from proc 6365 (dd): blkno 336 bcount 42
Once snapshots are building without this warning, we can remove the
current kludge code in vndstrategy() that deals with partial blocks.
I don't think this warning should be very noisy, but if it turns out
to cause problems, we can easily tweak it as appopriate (e.g., only
print N consecutive messages from the same pid).
ok?
Index: vnd.c
===================================================================
RCS file: /home/mdempsky/anoncvs/cvs/src/sys/dev/vnd.c,v
retrieving revision 1.148
diff -u -p -r1.148 vnd.c
--- vnd.c 18 Jul 2011 02:49:20 -0000 1.148
+++ vnd.c 25 Aug 2011 01:55:51 -0000
@@ -304,6 +304,15 @@ vndstrategy(struct buf *bp)
if (sc->sc_keyctx == NULL) {
u_int32_t secsize = sc->sc_dk.dk_label->d_secsize;
bp->b_bcount = ((origbcount + secsize - 1) & ~(secsize - 1));
+#ifdef DIAGNOSTIC
+ if (bp->b_bcount != origbcount) {
+ struct proc *pr = curproc;
+ printf("%s: sloppy %s from proc %d (%s): "
+ "blkno %lld bcount %ld\n", sc->sc_dev.dv_xname,
+ (bp->b_flags & B_READ) ? "read" : "write",
+ pr->p_pid, pr->p_comm, bp->b_blkno, origbcount);
+ }
+#endif
}
if (bounds_check_with_label(bp, sc->sc_dk.dk_label) == -1) {