l2arc: pass correct size to trim requests

b_size is a logical size of a buffer in memory, b_asize is its physical
size that accounts for possible compression.
Currently the latter is the best approximation for the allocated, on-disk
size.

L2ARC TRIM support was committed a few weeks before L2ARC compression
was imported, so originally the code was correct, because b_size was
the size.

Further thoughts.  Given that the cache device is being overwritten
in a circular fashion it is not clear if a TRIM per each evicted L2ARC
buffer has any benefits.
Maybe it would be sufficient to issue a single trim request for the whole
device when it is loaded, e.g. after a bootup, or when it is unloaded, e.g.
before a shutdown.  At least as long as L2ARC is not persistent across
reboots.

Discussed with:	smh
MFC after:	19 says
This commit is contained in:
Andriy Gapon 2015-06-17 12:28:13 +00:00
parent f0516b3c96
commit 6470c31911

View File

@ -1826,7 +1826,7 @@ arc_hdr_destroy(arc_buf_hdr_t *hdr)
if (l2hdr != NULL) {
trim_map_free(l2hdr->b_dev->l2ad_vdev, l2hdr->b_daddr,
hdr->b_size, 0);
l2hdr->b_asize, 0);
list_remove(l2hdr->b_dev->l2ad_buflist, hdr);
arc_buf_l2_cdata_free(hdr);
ARCSTAT_INCR(arcstat_l2_size, -hdr->b_size);
@ -3868,7 +3868,7 @@ arc_release(arc_buf_t *buf, void *tag)
vdev_space_update(l2hdr->b_dev->l2ad_vdev,
-l2hdr->b_asize, 0, 0);
trim_map_free(l2hdr->b_dev->l2ad_vdev, l2hdr->b_daddr,
hdr->b_size, 0);
l2hdr->b_asize, 0);
kmem_free(l2hdr, sizeof (l2arc_buf_hdr_t));
ARCSTAT_INCR(arcstat_l2_size, -buf_size);
mutex_exit(&l2arc_buflist_mtx);
@ -4813,7 +4813,7 @@ l2arc_write_done(zio_t *zio)
bytes_dropped += abl2->b_asize;
hdr->b_l2hdr = NULL;
trim_map_free(abl2->b_dev->l2ad_vdev, abl2->b_daddr,
hdr->b_size, 0);
abl2->b_asize, 0);
kmem_free(abl2, sizeof (l2arc_buf_hdr_t));
ARCSTAT_INCR(arcstat_l2_size, -hdr->b_size);
}