diff --git a/dm-compress/dm-compress.c b/dm-compress/dm-compress.c index a9463d0..a50626f 100644 --- a/dm-compress/dm-compress.c +++ b/dm-compress/dm-compress.c @@ -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;