85 int zfs_vdev_cache_max = 1<<14; /* 16KB */
86 int zfs_vdev_cache_size = 0;
87 int zfs_vdev_cache_bshift = 16;
88
89 #define VCBS (1 << zfs_vdev_cache_bshift) /* 64KB */
90
91 kstat_t *vdc_ksp = NULL;
92
93 typedef struct vdc_stats {
94 kstat_named_t vdc_stat_delegations;
95 kstat_named_t vdc_stat_hits;
96 kstat_named_t vdc_stat_misses;
97 } vdc_stats_t;
98
99 static vdc_stats_t vdc_stats = {
100 { "delegations", KSTAT_DATA_UINT64 },
101 { "hits", KSTAT_DATA_UINT64 },
102 { "misses", KSTAT_DATA_UINT64 }
103 };
104
105 #define VDCSTAT_BUMP(stat) atomic_add_64(&vdc_stats.stat.value.ui64, 1);
106
107 static int
108 vdev_cache_offset_compare(const void *a1, const void *a2)
109 {
110 const vdev_cache_entry_t *ve1 = a1;
111 const vdev_cache_entry_t *ve2 = a2;
112
113 if (ve1->ve_offset < ve2->ve_offset)
114 return (-1);
115 if (ve1->ve_offset > ve2->ve_offset)
116 return (1);
117 return (0);
118 }
119
120 static int
121 vdev_cache_lastused_compare(const void *a1, const void *a2)
122 {
123 const vdev_cache_entry_t *ve1 = a1;
124 const vdev_cache_entry_t *ve2 = a2;
125
|
85 int zfs_vdev_cache_max = 1<<14; /* 16KB */
86 int zfs_vdev_cache_size = 0;
87 int zfs_vdev_cache_bshift = 16;
88
89 #define VCBS (1 << zfs_vdev_cache_bshift) /* 64KB */
90
91 kstat_t *vdc_ksp = NULL;
92
93 typedef struct vdc_stats {
94 kstat_named_t vdc_stat_delegations;
95 kstat_named_t vdc_stat_hits;
96 kstat_named_t vdc_stat_misses;
97 } vdc_stats_t;
98
99 static vdc_stats_t vdc_stats = {
100 { "delegations", KSTAT_DATA_UINT64 },
101 { "hits", KSTAT_DATA_UINT64 },
102 { "misses", KSTAT_DATA_UINT64 }
103 };
104
105 #define VDCSTAT_BUMP(stat) atomic_inc_64(&vdc_stats.stat.value.ui64);
106
107 static int
108 vdev_cache_offset_compare(const void *a1, const void *a2)
109 {
110 const vdev_cache_entry_t *ve1 = a1;
111 const vdev_cache_entry_t *ve2 = a2;
112
113 if (ve1->ve_offset < ve2->ve_offset)
114 return (-1);
115 if (ve1->ve_offset > ve2->ve_offset)
116 return (1);
117 return (0);
118 }
119
120 static int
121 vdev_cache_lastused_compare(const void *a1, const void *a2)
122 {
123 const vdev_cache_entry_t *ve1 = a1;
124 const vdev_cache_entry_t *ve2 = a2;
125
|