Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[superseded by #3451][RFC, l2arc accounting & checksum issue] l2arc-write-target-size.diff , cumulative patch #3433

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4965,8 +4965,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz,
{
arc_buf_hdr_t *ab, *ab_prev, *head;
list_t *list;
uint64_t write_asize, write_psize, write_sz, headroom,
buf_compress_minsz;
uint64_t write_asize, write_sz, headroom, buf_compress_minsz;
void *buf_data;
kmutex_t *list_lock = NULL;
boolean_t full;
Expand All @@ -4982,7 +4981,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz,
*headroom_boost = B_FALSE;

pio = NULL;
write_sz = write_asize = write_psize = 0;
write_sz = write_asize = 0;
full = B_FALSE;
head = kmem_cache_alloc(hdr_cache, KM_PUSHPAGE);
head->b_flags |= ARC_L2_WRITE_HEAD;
Expand Down Expand Up @@ -5021,6 +5020,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz,
l2arc_buf_hdr_t *l2hdr;
kmutex_t *hash_lock;
uint64_t buf_sz;
uint64_t buf_a_sz;

if (arc_warm == B_FALSE)
ab_prev = list_next(list, ab);
Expand Down Expand Up @@ -5049,7 +5049,15 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz,
continue;
}

if ((write_sz + ab->b_size) > target_sz) {
/*
* Assume that the buffer is not going to be compressed
* and could take more space on disk because of a larger
* disk block size.
*/
buf_sz = ab->b_size;
buf_a_sz = vdev_psize_to_asize(dev->l2ad_vdev, buf_sz);

if ((write_asize + buf_a_sz) > target_sz) {
full = B_TRUE;
mutex_exit(hash_lock);
break;
Expand Down Expand Up @@ -5094,7 +5102,6 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz,
l2hdr->b_tmp_cdata = ab->b_buf->b_data;
l2hdr->b_hits = 0;

buf_sz = ab->b_size;
ab->b_l2hdr = l2hdr;

list_insert_head(dev->l2ad_buflist, ab);
Expand All @@ -5109,6 +5116,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz,
mutex_exit(hash_lock);

write_sz += buf_sz;
write_asize += buf_a_sz;
}

mutex_exit(list_lock);
Expand All @@ -5130,6 +5138,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz,
* and work backwards, retracing the course of the buffer selector
* loop above.
*/
write_asize = 0;
for (ab = list_prev(dev->l2ad_buflist, head); ab;
ab = list_prev(dev->l2ad_buflist, ab)) {
l2arc_buf_hdr_t *l2hdr;
Expand Down Expand Up @@ -5172,7 +5181,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz,

/* Compression may have squashed the buffer to zero length. */
if (buf_sz != 0) {
uint64_t buf_p_sz;
uint64_t buf_a_sz;

wzio = zio_write_phys(pio, dev->l2ad_vdev,
dev->l2ad_hand, buf_sz, buf_data, ZIO_CHECKSUM_OFF,
Expand All @@ -5183,13 +5192,12 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz,
zio_t *, wzio);
(void) zio_nowait(wzio);

write_asize += buf_sz;
/*
* Keep the clock hand suitably device-aligned.
*/
buf_p_sz = vdev_psize_to_asize(dev->l2ad_vdev, buf_sz);
write_psize += buf_p_sz;
dev->l2ad_hand += buf_p_sz;
buf_a_sz = vdev_psize_to_asize(dev->l2ad_vdev, buf_sz);
write_asize += buf_a_sz;
dev->l2ad_hand += buf_a_sz;
}
}

Expand Down Expand Up @@ -5252,12 +5260,6 @@ l2arc_compress_buf(l2arc_buf_hdr_t *l2hdr)
csize = zio_compress_data(ZIO_COMPRESS_LZ4, l2hdr->b_tmp_cdata,
cdata, l2hdr->b_asize);

rounded = P2ROUNDUP(csize, (size_t)SPA_MINBLOCKSIZE);
if (rounded > csize) {
bzero((char *)cdata + csize, rounded - csize);
csize = rounded;
}

if (csize == 0) {
/* zero block, indicate that there's nothing to write */
zio_data_buf_free(cdata, len);
Expand All @@ -5266,11 +5268,19 @@ l2arc_compress_buf(l2arc_buf_hdr_t *l2hdr)
l2hdr->b_tmp_cdata = NULL;
ARCSTAT_BUMP(arcstat_l2_compress_zeros);
return (B_TRUE);
} else if (csize > 0 && csize < len) {
}

rounded = P2ROUNDUP(csize,
(size_t)1 << l2hdr->b_dev->l2ad_vdev->vdev_ashift);
if (rounded < len) {
/*
* Compression succeeded, we'll keep the cdata around for
* writing and release it afterwards.
*/
if (rounded > csize) {
bzero((char *)cdata + csize, rounded - csize);
csize = rounded;
}
l2hdr->b_compress = ZIO_COMPRESS_LZ4;
l2hdr->b_asize = csize;
l2hdr->b_tmp_cdata = cdata;
Expand Down