zram: switch to 64-bit hash for dedup

The original dedup code does not handle collision from the observation
that it practically does not happen.

For additional peace of mind, use a bigger hash size for reducing the
possibility of collision even further.

Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
Signed-off-by: Alexander Winkowski <dereference23@outlook.com>
Change-Id: I4543ce22d69a21b2edcc72a72790d2c55a9e312c
fourteen
Juhyung Park 3 years ago committed by Jenna
parent eaf0a27b4c
commit e87044e4c9
  1. 12
      drivers/block/zram/zram_dedup.c
  2. 8
      drivers/block/zram/zram_dedup.h
  3. 2
      drivers/block/zram/zram_drv.c
  4. 2
      drivers/block/zram/zram_drv.h

@ -28,13 +28,13 @@ u64 zram_dedup_meta_size(struct zram *zram)
return (u64)atomic64_read(&zram->stats.meta_data_size);
}
static u32 zram_dedup_checksum(unsigned char *mem)
static u64 zram_dedup_checksum(unsigned char *mem)
{
return xxhash(mem, PAGE_SIZE, 0);
return xxh64(mem, PAGE_SIZE, 0);
}
void zram_dedup_insert(struct zram *zram, struct zram_entry *new,
u32 checksum)
u64 checksum)
{
struct zram_hash *hash;
struct rb_root *rb_root;
@ -91,7 +91,7 @@ static unsigned long zram_dedup_put(struct zram *zram,
struct zram_entry *entry)
{
struct zram_hash *hash;
u32 checksum;
u64 checksum;
unsigned long val;
checksum = entry->checksum;
@ -156,7 +156,7 @@ again:
}
static struct zram_entry *zram_dedup_get(struct zram *zram,
unsigned char *mem, u32 checksum)
unsigned char *mem, u64 checksum)
{
struct zram_hash *hash;
struct zram_entry *entry;
@ -182,7 +182,7 @@ static struct zram_entry *zram_dedup_get(struct zram *zram,
}
struct zram_entry *zram_dedup_find(struct zram *zram, struct page *page,
u32 *checksum)
u64 *checksum)
{
void *mem;
struct zram_entry *entry;

@ -10,9 +10,9 @@ u64 zram_dedup_dup_size(struct zram *zram);
u64 zram_dedup_meta_size(struct zram *zram);
void zram_dedup_insert(struct zram *zram, struct zram_entry *new,
u32 checksum);
u64 checksum);
struct zram_entry *zram_dedup_find(struct zram *zram, struct page *page,
u32 *checksum);
u64 *checksum);
void zram_dedup_init_entry(struct zram *zram, struct zram_entry *entry,
unsigned long handle, unsigned int len);
@ -26,9 +26,9 @@ static inline u64 zram_dedup_dup_size(struct zram *zram) { return 0; }
static inline u64 zram_dedup_meta_size(struct zram *zram) { return 0; }
static inline void zram_dedup_insert(struct zram *zram, struct zram_entry *new,
u32 checksum) { }
u64 checksum) { }
static inline struct zram_entry *zram_dedup_find(struct zram *zram,
struct page *page, u32 *checksum) { return NULL; }
struct page *page, u64 *checksum) { return NULL; }
static inline void zram_dedup_init_entry(struct zram *zram,
struct zram_entry *entry, unsigned long handle,

@ -3093,7 +3093,7 @@ static int __zram_bvec_write(struct zram *zram, struct bio_vec *bvec,
void *src, *dst, *mem;
struct zcomp_strm *zstrm;
struct page *page = bvec->bv_page;
u32 checksum;
u64 checksum;
unsigned long element = 0;
enum zram_pageflags flags = 0;
#ifdef CONFIG_ZRAM_LRU_WRITEBACK

@ -68,7 +68,7 @@ enum zram_pageflags {
struct zram_entry {
struct rb_node rb_node;
u32 len;
u32 checksum;
u64 checksum;
unsigned long refcount;
unsigned long handle;
};

Loading…
Cancel
Save