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: Marco Zanin <mrczn.bb@gmail.com> Signed-off-by: snnbyyds <snnbyyds@gmail.com> Signed-off-by: Sorayukii <sorayukii69@gmail.com>
This commit is contained in:
parent
72488bd99b
commit
df412d7834
4 changed files with 12 additions and 12 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1430,7 +1430,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;
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,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…
Reference in a new issue