VN - Remove use of IO_DIRECT, Improve lock performance for reads
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 3 Mar 2010 07:15:27 +0000 (23:15 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 3 Mar 2010 07:15:27 +0000 (23:15 -0800)
* Remove the use of IO_DIRECT.  This just doesn't work very well,
  particularly when the device backing the VN has a different logical
  block size than the device using VN.

  This will result in heavier use of the buffer cache and more
  (temporarily) duplicated data, but also has much better performance.

* Use LK_SHARED for VOP_READ()s instead of LK_EXCLUSIVE, which allows
  concurrent reads to be issued.

Reported-by: Vincent Stemen <vince.dragonfly@hightek.org>
sys/dev/disk/vn/vn.c

index 20ba904..9c3f50e 100644 (file)
@@ -353,11 +353,22 @@ vnstrategy(struct dev_strategy_args *ap)
                        auio.uio_rw = UIO_WRITE;
                auio.uio_resid = bp->b_bcount;
                auio.uio_td = curthread;
-               vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY);
-               if (bp->b_cmd == BUF_CMD_READ)
-                       error = VOP_READ(vn->sc_vp, &auio, IO_DIRECT | IO_RECURSE, vn->sc_cred);
-               else
-                       error = VOP_WRITE(vn->sc_vp, &auio, IO_DIRECT | IO_RECURSE, vn->sc_cred);
+
+               /*
+                * Don't use IO_DIRECT here, it really gets in the way
+                * due to typical blocksize differences between the
+                * fs backing the VN device and whatever is running on
+                * the VN device.
+                */
+               if (bp->b_cmd == BUF_CMD_READ) {
+                       vn_lock(vn->sc_vp, LK_SHARED | LK_RETRY);
+                       error = VOP_READ(vn->sc_vp, &auio, IO_RECURSE,
+                                        vn->sc_cred);
+               } else {
+                       vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY);
+                       error = VOP_WRITE(vn->sc_vp, &auio, IO_RECURSE,
+                                         vn->sc_cred);
+               }
                vn_unlock(vn->sc_vp);
                bp->b_resid = auio.uio_resid;
                if (error) {