From e8a07c9d22afdace966353231d0273d29efe0890 Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 20 Oct 2021 15:45:28 +0100 Subject: fscache: Implement a hash function Implement a function to generate hashes. It needs to be stable over time and endianness-independent as the hashes will appear on disk in future patches. It can assume that its input is a multiple of four bytes in size and alignment. This is borrowed from the VFS and simplified. le32_to_cpu() is added to make it endianness-independent. Changes ======= ver #3: - Read the data being hashed in an endianness-independent way[1]. - Change the size parameter to be in bytes rather than words. Signed-off-by: David Howells Reviewed-by: Jeff Layton cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/CAHk-=whtkzB446+hX0zdLsdcUJsJ=8_-0S1mE_R+YurThfUbLA@mail.gmail.com [1] Link: https://lore.kernel.org/r/163819586113.215744.1699465806130102367.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/163906888735.143852.10944614318596881429.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/163967082342.1823006.8915671045444488742.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/164021493624.640689.9990442668811178628.stgit@warthog.procyon.org.uk/ # v4 --- fs/fscache/internal.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'fs/fscache/internal.h') diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h index ea52f8594a77..f345bdb018ba 100644 --- a/fs/fscache/internal.h +++ b/fs/fscache/internal.h @@ -22,6 +22,8 @@ */ extern unsigned fscache_debug; +extern unsigned int fscache_hash(unsigned int salt, const void *data, size_t len); + /* * proc.c */ -- cgit v1.2.3