Skip to content

Commit 4d55112

Browse files
author
Dave Anderson
committed
Commit dd12805ed1db7 in the linux-next kernel repository, titled
"XArray: Remove radix tree compatibility", changes the definition of "radix_tree_root" back to be a struct. However, the content of the new structure differs from the original structure, so without the patch, current linux-next kernels fail during initialization with the error message "radix trees do not exist or have changed their format". Because the new "radix_tree_root" and "xarray" structures have nearly the same layout, the existing functionality for XArrays can be reused. ([email protected])
1 parent 2eadad0 commit 4d55112

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

bpf.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,12 @@ bpf_init(struct bpf_info *bpf)
221221
bpf->idr_type = IDR_ORIG;
222222
do_old_idr(IDR_ORIG_INIT, 0, NULL);
223223
} else if (STREQ(MEMBER_TYPE_NAME("idr", "idr_rt"), "radix_tree_root"))
224-
bpf->idr_type = IDR_RADIX;
224+
if (MEMBER_EXISTS("radix_tree_root", "rnode"))
225+
bpf->idr_type = IDR_RADIX;
226+
else if (MEMBER_EXISTS("radix_tree_root", "xa_head"))
227+
bpf->idr_type = IDR_XARRAY;
228+
else
229+
error(FATAL, "cannot determine IDR list type\n");
225230
else if (STREQ(MEMBER_TYPE_NAME("idr", "idr_rt"), "xarray"))
226231
bpf->idr_type = IDR_XARRAY;
227232
else

filesys.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,9 @@ dump_inode_page_cache_info(ulong inode)
22172217

22182218
xarray = root_rnode = count = 0;
22192219
if (MEMBER_EXISTS("address_space", "i_pages") &&
2220-
STREQ(MEMBER_TYPE_NAME("address_space", "i_pages"), "xarray"))
2220+
(STREQ(MEMBER_TYPE_NAME("address_space", "i_pages"), "xarray") ||
2221+
(STREQ(MEMBER_TYPE_NAME("address_space", "i_pages"), "radix_tree_root") &&
2222+
MEMBER_EXISTS("radix_tree_root", "xa_head"))))
22212223
xarray = i_mapping + OFFSET(address_space_page_tree);
22222224
else
22232225
root_rnode = i_mapping + OFFSET(address_space_page_tree);

ipcs.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,12 @@ ipcs_init(void)
205205
if (VALID_MEMBER(idr_idr_rt)) {
206206
if (STREQ(MEMBER_TYPE_NAME("idr", "idr_rt"), "xarray"))
207207
ipcs_table.init_flags |= IDR_XARRAY;
208-
else
209-
ipcs_table.init_flags |= IDR_RADIX;
208+
else {
209+
if (MEMBER_EXISTS("radix_tree_root", "rnode"))
210+
ipcs_table.init_flags |= IDR_RADIX;
211+
else if (MEMBER_EXISTS("radix_tree_root", "xa_head"))
212+
ipcs_table.init_flags |= IDR_XARRAY;
213+
}
210214
} else
211215
ipcs_table.init_flags |= IDR_ORIG;
212216

kernel.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,14 @@ kernel_init()
534534

535535
if (kernel_symbol_exists("irq_desc_tree")) {
536536
get_symbol_type("irq_desc_tree", NULL, &req);
537-
kt->flags2 |= STREQ(req.type_tag_name, "xarray") ?
538-
IRQ_DESC_TREE_XARRAY : IRQ_DESC_TREE_RADIX;
539-
537+
if (STREQ(req.type_tag_name, "xarray")) {
538+
kt->flags2 |= IRQ_DESC_TREE_XARRAY;
539+
} else {
540+
if (MEMBER_EXISTS("radix_tree_root", "xa_head"))
541+
kt->flags2 |= IRQ_DESC_TREE_XARRAY;
542+
else
543+
kt->flags2 |= IRQ_DESC_TREE_RADIX;
544+
}
540545
}
541546
STRUCT_SIZE_INIT(irq_data, "irq_data");
542547
if (VALID_STRUCT(irq_data)) {

task.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,17 @@ task_init(void)
507507
OFFSET(pid_namespace_idr) + OFFSET(idr_idr_rt);
508508
tt->flags |= PID_XARRAY;
509509
} else if STREQ(MEMBER_TYPE_NAME("idr", "idr_rt"), "radix_tree_root") {
510-
tt->refresh_task_table = refresh_radix_tree_task_table;
511-
tt->pid_radix_tree = symbol_value("init_pid_ns") +
512-
OFFSET(pid_namespace_idr) + OFFSET(idr_idr_rt);
513-
tt->flags |= PID_RADIX_TREE;
510+
if (MEMBER_EXISTS("radix_tree_root", "rnode")) {
511+
tt->refresh_task_table = refresh_radix_tree_task_table;
512+
tt->pid_radix_tree = symbol_value("init_pid_ns") +
513+
OFFSET(pid_namespace_idr) + OFFSET(idr_idr_rt);
514+
tt->flags |= PID_RADIX_TREE;
515+
} else if (MEMBER_EXISTS("radix_tree_root", "xa_head")) {
516+
tt->refresh_task_table = refresh_xarray_task_table;
517+
tt->pid_xarray = symbol_value("init_pid_ns") +
518+
OFFSET(pid_namespace_idr) + OFFSET(idr_idr_rt);
519+
tt->flags |= PID_XARRAY;
520+
}
514521
} else
515522
error(FATAL, "unknown pid_namespace.idr type: %s\n",
516523
MEMBER_TYPE_NAME("idr", "idr_rt"));

tools.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -4241,7 +4241,10 @@ cmd_tree()
42414241
}
42424242

42434243
if (STRNEQ(optarg, "ra"))
4244-
type_flag = RADIXTREE_REQUEST;
4244+
if (MEMBER_EXISTS("radix_tree_root", "xa_head"))
4245+
type_flag = XARRAY_REQUEST;
4246+
else
4247+
type_flag = RADIXTREE_REQUEST;
42454248
else if (STRNEQ(optarg, "rb"))
42464249
type_flag = RBTREE_REQUEST;
42474250
else if (STRNEQ(optarg, "x"))

0 commit comments

Comments
 (0)