memcmpz -> lblk_is_zeros

This commit is contained in:
Tom Marshall 2019-10-10 15:13:15 -07:00
parent 24401f9a68
commit c1ec406a00
1 changed files with 20 additions and 5 deletions

View File

@ -504,6 +504,25 @@ lblk_alloc_elem_read(struct dm_compress* dc, struct zone_cache* zc, u64 lblk)
* Logical block functions
**************************************/
static inline bool
lblk_is_zeros(struct cbd_params* params, struct zone_cache* zc)
{
#ifdef CBD_DETECT_ZERO_BLOCKS
u32 off;
u32 len = PBLK_SIZE * lblk_per_pblk(params);
for (off = 0; off < len; ++off) {
if (zc->lblk[off]) {
return false;
}
}
return true;
#else
return false;
#endif
}
/*
* Compress dc->lblk into dc->lz4_cbuf
*
@ -569,11 +588,7 @@ lblk_write(struct dm_compress* dc, struct zone_cache* zc)
BUG_ON(zc->lblk_alloc_elem_lblk == LBLK_NONE);
d_len = PBLK_SIZE * lblk_per_pblk(&dc->params);
#ifdef CBD_DETECT_ZERO_BLOCKS
if (memcmpz(zc->lblk, d_len) == 0) {
#else
if (0) {
#endif
if (lblk_is_zeros(&dc->params, zc)) {
c_len = 0;
c_buf = NULL;
zc->lblk_alloc_elem->len = 0;