Hi Huang,
I made some modification upon your v7, could you please check if this
works for you?
I guess this will make folio_xarray_update_off() cleaner, and
less-code-change on do_xarray_iter().
Thanks,
Tao Liu
diff --git a/filesys.c b/filesys.c
index fc672ad..2f2e872 100644
--- a/filesys.c
+++ b/filesys.c
@@ -4277,22 +4277,22 @@ folio_update_count(ulong slot)
}
static uint folio_xarray_update_off(ulong node, uint height, char *path, ulong index,
- ulong slot, uint off, ulong shift, struct xarray_ops *ops)
+ ulong slot, uint off, ulong shift, struct xarray_ops
*ops)
{
- uint order;
-
- if (height > 1) {
- if ((slot & XARRAY_TAG_MASK) == 0) {
- ops->entry(node, slot, path, index | off, ops->private);
- order = folio_order(slot) % XA_CHUNK_SHIFT;
- return 1 << order;
- }
- return 0;
- }
-
- /* The height == 1 */
- order = folio_order(slot) % XA_CHUNK_SHIFT;
- return 1 << order;
+ uint order;
+
+ if (height == 1) {
+ order = folio_order(slot) % XA_CHUNK_SHIFT;
+ return 1 << order;
+ }
+
+ if ((slot & XARRAY_TAG_MASK) == 0) {
+ ops->entry(node, slot, path, index | off, ops->private);
+ order = folio_order(slot) % XA_CHUNK_SHIFT;
+ return 1 << order;
+ }
+
+ return 1;
}
static void do_xarray_count(ulong node, ulong slot, const char *path,
diff --git a/tools.c b/tools.c
index 0302cec..4558e58 100644
--- a/tools.c
+++ b/tools.c
@@ -4755,21 +4755,16 @@ do_xarray_iter(ulong node, uint height, char *path,
if (!slot)
continue;
+ if (ops->update_off)
+ update_off = ops->update_off(node, height, path, index,
+ slot, off, shift, ops);
+
if ((slot & XARRAY_TAG_MASK) == XARRAY_TAG_INTERNAL) {
slot &= ~XARRAY_TAG_INTERNAL;
- } else if (ops->update_off && height > 1) {
- update_off = ops->update_off(node, height, path, index,
- slot, off, shift, ops);
- if (update_off)
- continue;
- update_off = 1;
}
if (height == 1) {
ops->entry(node, slot, path, index | off, ops->private);
- if (ops->update_off)
- update_off = ops->update_off(node, height, path,
index,
- slot, off, shift, ops);
} else {
ulong child_index = index | (off << shift);
char child_path[BUFSIZE];