#define _LUSTRE_COMPR_H_
#include <linux/crypto.h>
+#define LL_COMPR_GAP 4096
int alloc_compr(const char *obd_name, enum ll_compr_type *type,
unsigned int *lvl, struct crypto_comp **cc, bool decompress);
* The minimum delta between compressed and plain data to
* use the compressed one.
*/
-#define COMP_GAP 4096
int compress_chunk(const char *obd_name, struct crypto_comp *cc,
const unsigned char *in, unsigned int in_len,
unsigned char *out, unsigned int *out_len,
/* the uncompressed data is shorter than the minimum effective
* compressed size, so don't bother compressing
*/
- if (in_len <= COMP_GAP) {
+ if (in_len <= LL_COMPR_GAP) {
*out_len = in_len;
return 0;
}
}
/* round the sizes up to the nearest block before comparing */
- effective_compr_size = round_up(len + sizeof(*llch), COMP_GAP);
- effective_uncompr_size = round_up(in_len, COMP_GAP);
+ effective_compr_size = round_up(len + sizeof(*llch), LL_COMPR_GAP);
+ effective_uncompr_size = round_up(in_len, LL_COMPR_GAP);
if (effective_compr_size >= effective_uncompr_size) {
CDEBUG(D_SEC,
bool chunk_unmergeable = false;
bool compress_this = false;
bool compressed = false;
- int chunk_start = -1;
+ __u64 chunk_len_bytes;
int chunk_len = 1;
+ int chunk_start;
int curr;
/* if this page isn't aligned to chunk start, skip it */
}
/* last page in this chunk (could be == first, that's OK) */
pg_last = pga[chunk_start + chunk_len - 1];
+
+ chunk_len_bytes = PAGE_SIZE * chunk_len;
+
+ if (chunk_len == pages_per_chunk) {
+ compress_this = true;
/* if the write end is equal to KMS, this write - which we
* already verified starts at a chunk boundary - is the
* furthest write to this file and can be compressed
* we check the end for equality. We could do >=, but == should
* always work.)
*/
- if (chunk_len == pages_per_chunk)
- compress_this = true;
- else if (!chunk_unmergeable && pg_last->off + pg_last->count == kms) {
+ } else if (chunk_len_bytes > LL_COMPR_GAP &&
+ !chunk_unmergeable &&
+ pg_last->off + pg_last->count == kms) {
compress_this = true;
CDEBUG(D_SEC,
"Chunk starting at %llu (pages [%d, %d]) matches kms %llu, compressing.\n",
pga[chunk_start]->off, pg_last->off + pg_last->count, kms);
if (compress_this) {
-
CDEBUG(D_SEC,
"compressing chunk from page [%d, %d], off [%llu, %llu]\n",
chunk_start, chunk_start + chunk_len - 1,