path: root/kerncompat.h
diff options
authorNikolay Borisov <>2018-10-01 17:46:16 +0300
committerDavid Sterba <>2018-10-25 16:11:39 +0200
commit8c028efe4a31e15c0d106daf6218dedc373273c6 (patch)
tree58d6efe31920b5112e8b6c4ab5bdcaf334b09626 /kerncompat.h
parenta9ce9286f24b299ea2a8465d89cee659c3f5dcf1 (diff)
btrfs-progs: Pull free space tree related code from kernel
To help implement free space tree checker in user space some kernel function are necessary, namely iterating/deleting/adding freespace items, some internal search functions. Functions to populate a block group based on the extent tree. The code is largely copy/paste from the kernel with locking eliminated (i.e free_space_lock). It supports reading/writing of both bitmap and extent based FST trees. Signed-off-by: Nikolay Borisov <> Signed-off-by: David Sterba <>
Diffstat (limited to 'kerncompat.h')
1 files changed, 6 insertions, 0 deletions
diff --git a/kerncompat.h b/kerncompat.h
index 1a2bc18c..c33e485f 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -263,6 +263,8 @@ static inline int IS_ERR_OR_NULL(const void *ptr)
return !ptr || IS_ERR(ptr);
+#define div_u64(x, y) ((x) / (y))
* swap - swap values of @a and @b
* @a: first value
@@ -297,6 +299,10 @@ static inline int IS_ERR_OR_NULL(const void *ptr)
#define kfree(x) free(x)
#define vmalloc(x) malloc(x)
#define vfree(x) free(x)
+#define kvzalloc(x, y) kzalloc(x,y)
+#define kvfree(x) free(x)
+#define memalloc_nofs_save() (0)
+#define memalloc_nofs_restore(x) ((void)(x))
static inline void assert_trace(const char *assertion, const char *filename,