6.6: Update bcachefs against 6.6.3 (#852)
Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
This commit is contained in:
@@ -98470,117 +98470,6 @@ index 11fbd0ee1370..f75e0914d40d 100644
|
||||
/*
|
||||
* 64 bit unique kernfs id
|
||||
*/
|
||||
diff --git a/include/linux/generic-radix-tree.h b/include/linux/generic-radix-tree.h
|
||||
index 107613f7d792..847413164738 100644
|
||||
--- a/include/linux/generic-radix-tree.h
|
||||
+++ b/include/linux/generic-radix-tree.h
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <asm/page.h>
|
||||
#include <linux/bug.h>
|
||||
+#include <linux/limits.h>
|
||||
#include <linux/log2.h>
|
||||
#include <linux/math.h>
|
||||
#include <linux/types.h>
|
||||
@@ -116,6 +117,11 @@ static inline size_t __idx_to_offset(size_t idx, size_t obj_size)
|
||||
|
||||
#define __genradix_cast(_radix) (typeof((_radix)->type[0]) *)
|
||||
#define __genradix_obj_size(_radix) sizeof((_radix)->type[0])
|
||||
+#define __genradix_objs_per_page(_radix) \
|
||||
+ (PAGE_SIZE / sizeof((_radix)->type[0]))
|
||||
+#define __genradix_page_remainder(_radix) \
|
||||
+ (PAGE_SIZE % sizeof((_radix)->type[0]))
|
||||
+
|
||||
#define __genradix_idx_to_offset(_radix, _idx) \
|
||||
__idx_to_offset(_idx, __genradix_obj_size(_radix))
|
||||
|
||||
@@ -179,11 +185,35 @@ void *__genradix_iter_peek(struct genradix_iter *, struct __genradix *, size_t);
|
||||
#define genradix_iter_peek(_iter, _radix) \
|
||||
(__genradix_cast(_radix) \
|
||||
__genradix_iter_peek(_iter, &(_radix)->tree, \
|
||||
- PAGE_SIZE / __genradix_obj_size(_radix)))
|
||||
+ __genradix_objs_per_page(_radix)))
|
||||
+
|
||||
+void *__genradix_iter_peek_prev(struct genradix_iter *, struct __genradix *,
|
||||
+ size_t, size_t);
|
||||
+
|
||||
+/**
|
||||
+ * genradix_iter_peek_prev - get first entry at or below iterator's current
|
||||
+ * position
|
||||
+ * @_iter: a genradix_iter
|
||||
+ * @_radix: genradix being iterated over
|
||||
+ *
|
||||
+ * If no more entries exist at or below @_iter's current position, returns NULL
|
||||
+ */
|
||||
+#define genradix_iter_peek_prev(_iter, _radix) \
|
||||
+ (__genradix_cast(_radix) \
|
||||
+ __genradix_iter_peek_prev(_iter, &(_radix)->tree, \
|
||||
+ __genradix_objs_per_page(_radix), \
|
||||
+ __genradix_obj_size(_radix) + \
|
||||
+ __genradix_page_remainder(_radix)))
|
||||
|
||||
static inline void __genradix_iter_advance(struct genradix_iter *iter,
|
||||
size_t obj_size)
|
||||
{
|
||||
+ if (iter->offset + obj_size < iter->offset) {
|
||||
+ iter->offset = SIZE_MAX;
|
||||
+ iter->pos = SIZE_MAX;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
iter->offset += obj_size;
|
||||
|
||||
if (!is_power_of_2(obj_size) &&
|
||||
@@ -196,6 +226,25 @@ static inline void __genradix_iter_advance(struct genradix_iter *iter,
|
||||
#define genradix_iter_advance(_iter, _radix) \
|
||||
__genradix_iter_advance(_iter, __genradix_obj_size(_radix))
|
||||
|
||||
+static inline void __genradix_iter_rewind(struct genradix_iter *iter,
|
||||
+ size_t obj_size)
|
||||
+{
|
||||
+ if (iter->offset == 0 ||
|
||||
+ iter->offset == SIZE_MAX) {
|
||||
+ iter->offset = SIZE_MAX;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if ((iter->offset & (PAGE_SIZE - 1)) == 0)
|
||||
+ iter->offset -= PAGE_SIZE % obj_size;
|
||||
+
|
||||
+ iter->offset -= obj_size;
|
||||
+ iter->pos--;
|
||||
+}
|
||||
+
|
||||
+#define genradix_iter_rewind(_iter, _radix) \
|
||||
+ __genradix_iter_rewind(_iter, __genradix_obj_size(_radix))
|
||||
+
|
||||
#define genradix_for_each_from(_radix, _iter, _p, _start) \
|
||||
for (_iter = genradix_iter_init(_radix, _start); \
|
||||
(_p = genradix_iter_peek(&_iter, _radix)) != NULL; \
|
||||
@@ -213,6 +262,23 @@ static inline void __genradix_iter_advance(struct genradix_iter *iter,
|
||||
#define genradix_for_each(_radix, _iter, _p) \
|
||||
genradix_for_each_from(_radix, _iter, _p, 0)
|
||||
|
||||
+#define genradix_last_pos(_radix) \
|
||||
+ (SIZE_MAX / PAGE_SIZE * __genradix_objs_per_page(_radix) - 1)
|
||||
+
|
||||
+/**
|
||||
+ * genradix_for_each_reverse - iterate over entry in a genradix, reverse order
|
||||
+ * @_radix: genradix to iterate over
|
||||
+ * @_iter: a genradix_iter to track current position
|
||||
+ * @_p: pointer to genradix entry type
|
||||
+ *
|
||||
+ * On every iteration, @_p will point to the current entry, and @_iter.pos
|
||||
+ * will be the current entry's index.
|
||||
+ */
|
||||
+#define genradix_for_each_reverse(_radix, _iter, _p) \
|
||||
+ for (_iter = genradix_iter_init(_radix, genradix_last_pos(_radix));\
|
||||
+ (_p = genradix_iter_peek_prev(&_iter, _radix)) != NULL;\
|
||||
+ genradix_iter_rewind(&_iter, _radix))
|
||||
+
|
||||
int __genradix_prealloc(struct __genradix *, size_t, gfp_t);
|
||||
|
||||
/**
|
||||
diff --git a/include/linux/sched.h b/include/linux/sched.h
|
||||
index 77f01ac385f7..d5951e99706a 100644
|
||||
--- a/include/linux/sched.h
|
||||
@@ -98861,38 +98750,6 @@ index f25eb111c051..41f1bcdc4488 100644
|
||||
#include <linux/export.h>
|
||||
#include <linux/generic-radix-tree.h>
|
||||
#include <linux/gfp.h>
|
||||
@@ -166,6 +167,10 @@ void *__genradix_iter_peek(struct genradix_iter *iter,
|
||||
struct genradix_root *r;
|
||||
struct genradix_node *n;
|
||||
unsigned level, i;
|
||||
+
|
||||
+ if (iter->offset == SIZE_MAX)
|
||||
+ return NULL;
|
||||
+
|
||||
restart:
|
||||
r = READ_ONCE(radix->root);
|
||||
if (!r)
|
||||
@@ -184,10 +189,17 @@ void *__genradix_iter_peek(struct genradix_iter *iter,
|
||||
(GENRADIX_ARY - 1);
|
||||
|
||||
while (!n->children[i]) {
|
||||
+ size_t objs_per_ptr = genradix_depth_size(level);
|
||||
+
|
||||
+ if (iter->offset + objs_per_ptr < iter->offset) {
|
||||
+ iter->offset = SIZE_MAX;
|
||||
+ iter->pos = SIZE_MAX;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
i++;
|
||||
- iter->offset = round_down(iter->offset +
|
||||
- genradix_depth_size(level),
|
||||
- genradix_depth_size(level));
|
||||
+ iter->offset = round_down(iter->offset + objs_per_ptr,
|
||||
+ objs_per_ptr);
|
||||
iter->pos = (iter->offset >> PAGE_SHIFT) *
|
||||
objs_per_page;
|
||||
if (i == GENRADIX_ARY)
|
||||
@@ -201,6 +213,64 @@ void *__genradix_iter_peek(struct genradix_iter *iter,
|
||||
}
|
||||
EXPORT_SYMBOL(__genradix_iter_peek);
|
||||
|
Reference in New Issue
Block a user