Add -p switch to "zpool get"
[zfs.git] / module / zfs / vdev_cache.c
index a4b3442..bf4ae7b 100644 (file)
  * 1<<zfs_vdev_cache_bshift byte reads by the vdev_cache (aka software
  * track buffer).  At most zfs_vdev_cache_size bytes will be kept in each
  * vdev's vdev_cache.
+ *
+ * TODO: Note that with the current ZFS code, it turns out that the
+ * vdev cache is not helpful, and in some cases actually harmful.  It
+ * is better if we disable this.  Once some time has passed, we should
+ * actually remove this to simplify the code.  For now we just disable
+ * it by setting the zfs_vdev_cache_size to zero.  Note that Solaris 11
+ * has made these same changes.
  */
 int zfs_vdev_cache_max = 1<<14;                        /* 16KB */
-int zfs_vdev_cache_size = 10ULL << 20;         /* 10MB */
+int zfs_vdev_cache_size = 0;
 int zfs_vdev_cache_bshift = 16;
 
 #define        VCBS (1 << zfs_vdev_cache_bshift)       /* 64KB */
@@ -170,7 +177,7 @@ vdev_cache_allocate(zio_t *zio)
                vdev_cache_evict(vc, ve);
        }
 
-       ve = kmem_zalloc(sizeof (vdev_cache_entry_t), KM_SLEEP);
+       ve = kmem_zalloc(sizeof (vdev_cache_entry_t), KM_PUSHPAGE);
        ve->ve_offset = offset;
        ve->ve_lastused = ddi_get_lbolt();
        ve->ve_data = zio_buf_alloc(VCBS);
@@ -244,7 +251,7 @@ int
 vdev_cache_read(zio_t *zio)
 {
        vdev_cache_t *vc = &zio->io_vd->vdev_cache;
-       vdev_cache_entry_t *ve, ve_search;
+       vdev_cache_entry_t *ve, *ve_search;
        uint64_t cache_offset = P2ALIGN(zio->io_offset, VCBS);
        ASSERTV(uint64_t cache_phase = P2PHASE(zio->io_offset, VCBS);)
        zio_t *fio;
@@ -267,8 +274,10 @@ vdev_cache_read(zio_t *zio)
 
        mutex_enter(&vc->vc_lock);
 
-       ve_search.ve_offset = cache_offset;
-       ve = avl_find(&vc->vc_offset_tree, &ve_search, NULL);
+       ve_search = kmem_alloc(sizeof(vdev_cache_entry_t), KM_PUSHPAGE);
+       ve_search->ve_offset = cache_offset;
+       ve = avl_find(&vc->vc_offset_tree, ve_search, NULL);
+       kmem_free(ve_search, sizeof(vdev_cache_entry_t));
 
        if (ve != NULL) {
                if (ve->ve_missed_update) {
@@ -414,3 +423,14 @@ vdev_cache_stat_fini(void)
                vdc_ksp = NULL;
        }
 }
+
+#if defined(_KERNEL) && defined(HAVE_SPL)
+module_param(zfs_vdev_cache_max, int, 0644);
+MODULE_PARM_DESC(zfs_vdev_cache_max, "Inflate reads small than max");
+
+module_param(zfs_vdev_cache_size, int, 0444);
+MODULE_PARM_DESC(zfs_vdev_cache_size, "Total size of the per-disk cache");
+
+module_param(zfs_vdev_cache_bshift, int, 0644);
+MODULE_PARM_DESC(zfs_vdev_cache_bshift, "Shift size to inflate reads too");
+#endif