]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
dm cache: pull out some bitset utility functions for reuse
authorJoe Thornber <ejt@redhat.com>
Fri, 15 May 2015 14:22:02 +0000 (15:22 +0100)
committerMike Snitzer <snitzer@redhat.com>
Fri, 29 May 2015 18:19:05 +0000 (14:19 -0400)
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-cache-policy-internal.h
drivers/md/dm-cache-target.c

index 776c685167e660bb6e37af9ec7a843584f54a44c..9dc05a52369e60cb280c9bebac3985c1ce9b16d1 100644 (file)
@@ -7,6 +7,7 @@
 #ifndef DM_CACHE_POLICY_INTERNAL_H
 #define DM_CACHE_POLICY_INTERNAL_H
 
+#include <linux/vmalloc.h>
 #include "dm-cache-policy.h"
 
 /*----------------------------------------------------------------*/
@@ -106,6 +107,33 @@ static inline int policy_set_config_value(struct dm_cache_policy *p,
 
 /*----------------------------------------------------------------*/
 
+/*
+ * Some utility functions commonly used by policies and the core target.
+ */
+static inline size_t bitset_size_in_bytes(unsigned nr_entries)
+{
+       return sizeof(unsigned long) * dm_div_up(nr_entries, BITS_PER_LONG);
+}
+
+static inline unsigned long *alloc_bitset(unsigned nr_entries)
+{
+       size_t s = bitset_size_in_bytes(nr_entries);
+       return vzalloc(s);
+}
+
+static inline void clear_bitset(void *bitset, unsigned nr_entries)
+{
+       size_t s = bitset_size_in_bytes(nr_entries);
+       memset(bitset, 0, s);
+}
+
+static inline void free_bitset(unsigned long *bits)
+{
+       vfree(bits);
+}
+
+/*----------------------------------------------------------------*/
+
 /*
  * Creates a new cache policy given a policy name, a cache size, an origin size and the block size.
  */
index 5a9cd2c5a359f64d7fea598747f26251558ea4d9..5d3b20b91ba366834b1897541445324efa864e9d 100644 (file)
@@ -111,30 +111,6 @@ static void iot_io_end(struct io_tracker *iot, sector_t len)
 
 /*----------------------------------------------------------------*/
 
-static size_t bitset_size_in_bytes(unsigned nr_entries)
-{
-       return sizeof(unsigned long) * dm_div_up(nr_entries, BITS_PER_LONG);
-}
-
-static unsigned long *alloc_bitset(unsigned nr_entries)
-{
-       size_t s = bitset_size_in_bytes(nr_entries);
-       return vzalloc(s);
-}
-
-static void clear_bitset(void *bitset, unsigned nr_entries)
-{
-       size_t s = bitset_size_in_bytes(nr_entries);
-       memset(bitset, 0, s);
-}
-
-static void free_bitset(unsigned long *bits)
-{
-       vfree(bits);
-}
-
-/*----------------------------------------------------------------*/
-
 /*
  * There are a couple of places where we let a bio run, but want to do some
  * work before calling its endio function.  We do this by temporarily