-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
helpers: linux: fs: use mount rbtree instead of list #383
Conversation
Thanks, Johannes! Could you please also keep a fallback for the old kernel version? Lines 1219 to 1232 in 145ac79
CONTRIBUTING.rst also has a Linux Kernel Helpers section.
|
Sure will send an update soon |
Here's another example I just had to do: 718da44. Let me know if you need any more pointers or if you'd like me to take it from here. |
Hi Omar, no there's no problem, I just didn't have time to do the update. I'm stuck debugging a btrfs issue. |
7adaf64
to
43070f0
Compare
Starting with kernel v6.8 the mnt_list int struct mnt_namespace git converted to a rb-tree. Reflect this change in drgn's for_each_mount() helper. Signed-off-by: Johannes Thumshirn <[email protected]>
43070f0
to
72a2cbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just a couple of nits.
try: | ||
mounts = list_for_each_entry("struct mount", ns.list.address_of_(), "mnt_list") | ||
except AttributeError: | ||
mounts = rbtree_inorder_for_each_entry( | ||
"struct mount", ns.mounts.address_of_(), "mnt_node" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of nits documented in CONTRIBUTING.rst
:
- Add a comment documenting the version divergence.
- Put the case for the latest kernel first.
try: | |
mounts = list_for_each_entry("struct mount", ns.list.address_of_(), "mnt_list") | |
except AttributeError: | |
mounts = rbtree_inorder_for_each_entry( | |
"struct mount", ns.mounts.address_of_(), "mnt_node" | |
) | |
# Since Linux kernel commit 2eea9ce4310d ("mounts: keep list of mounts in | |
# an rbtree") (in v6.8), the mounts in a namespace are in a red-black tree. | |
# Before that, they're in a list. | |
try: | |
mounts = rbtree_inorder_for_each_entry( | |
"struct mount", ns.mounts.address_of_(), "mnt_node" | |
) | |
except AttributeError: | |
mounts = list_for_each_entry("struct mount", ns.list.address_of_(), "mnt_list") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately that made the CI unhappy when I tried it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, struct mnt_namespace
previously had a member named mounts
which was the number of mounts, so the AttributeError
doesn't trigger in the try
. Okay, let's just add the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a related fix for path_lookup(), so I'll add the comment on my end. Thanks!
Starting with kernel v6.8 the mnt_list int struct mnt_namespace git converted to a rb-tree.
Reflect this change in drgn's for_each_mount() helper.