-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add iscsi helpers to dump iscsi session information #108
Conversation
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.
Please reorganize the patch, the second commit should be removed, the 3th to 5th should be merged into one commit. Please create a bug and put the bugdb id in the commit log, also for each commit, please brief in the git commit log what the change is for.
Makefile
Outdated
@@ -33,4 +33,4 @@ drgn_tools/_version.py: | |||
.PHONY: rsync | |||
rsync: drgn_tools/_version.py | |||
@if [ -z "$(TARGET)" ]; then echo "error: TARGET unspecified. Either set it in config.mk, or use\nmake TARGET=hostname rsync"; exit 1; fi | |||
rsync -avz --exclude "__pycache__" --exclude ".git" --exclude ".mypy_cache" ./drgn_tools $(TARGET):drgn_tools/ | |||
rsync -avz --exclude "__pycache__" --exclude ".git" --exclude ".mypy_cache" ./drgn_tools $(TARGET) |
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.
Please explain what this change is for.
drgn_tools/dm.py
Outdated
if hc.uuid: | ||
uuid = hc.uuid.string_().decode() | ||
|
||
yield hc.md, hc.name.string_().decode(), uuid |
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.
Please explain what case this uuid can be NULL.
drgn_tools/iscsi.py
Outdated
else: | ||
return list_for_each_entry( | ||
"struct device", devices, "knode_class.n_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.
Is this good program practice for python to mix yield and return?
drgn_tools/iscsi.py
Outdated
dev = dev.parent | ||
|
||
if dev.type and dev.type.name.string_().decode() == "scsi_host": | ||
yield dev |
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.
This doesn't look right, multiple disks can be from same iscsi host, this will return duplcated iscsi host.
drgn_tools/iscsi.py
Outdated
for device_private in list_for_each_entry( | ||
"struct device_private", devices, "knode_class.n_node" | ||
): | ||
yield device_private.device |
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.
In the code path of class_in_private
is not null, it never checks anything for iscsi, why will it be iscsi device?
drgn_tools/iscsi.py
Outdated
@@ -60,7 +65,7 @@ def for_each_iscsi_host_device(prog: Program) -> Iterator[Object]: | |||
yield dev | |||
|
|||
|
|||
def for_each_iscsi_host(prog: Program) -> Iterator[Object]: | |||
def for_each_scsi_host(prog: Program) -> Iterator[Object]: |
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.
for_each_scsi_host
is already defined in scsi.py, just import it.
drgn_tools/iscsi.py
Outdated
|
||
return iscsi_sw_tcp_host.session |
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.
We should do some precheck to make sure this is sw tcp iscsi, if it's not, then leave a message saying it's not supported, otherwise the script will just crash for other iscsi type.
drgn_tools/iscsi.py
Outdated
for h in for_each_iscsi_host(prog): | ||
yield __get_iscsi_session(h) | ||
for h in for_each_scsi_host(prog): | ||
yield __get_iscsi_session(prog, h) |
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.
The system could contain other scsi disk like virtio-scsi, sas or fc disk other than iscsi, here it is iterating scsi host, it will include all other types as well, we should provide a new helper for_each_iscsi_host
which used for_each_scsi_host
and then just return the host which is iscsi type.
drgn_tools/iscsi.py
Outdated
rq = sdev.request_queue | ||
dev = container_of(rq.kobj.parent, "struct device", "kobj") | ||
return dev.kobj.name.string_().decode() | ||
|
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.
shost_for_each_device
and get_dev_name
are generic scsi helpers, should be moved to scsi.py, and also maybe rename it to for_each_scsi_host_device
and get_scsi_device_name
?
drgn_tools/iscsi.py
Outdated
""" | ||
for h in for_each_iscsi_tcp_host(prog): | ||
yield __get_iscsi_sw_tcp_host(prog, h).session | ||
|
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.
As in my following comment, let try to make these helper generic to iscsi drivers, not only to iscsi_tcp driver.
One more comment, please change the commit subject for this patch, probably "Add iscsi helpers to dump iscsi session information" |
be3ae35
to
4dfcd2e
Compare
I noticed that there were test failures reporting a key error for doing 'prog['sesslist']' for ueknext. I tested it locally with 6.11.0-0 as well but didn't observe such error. Maybe could @brenns10 help take a look? Thanks. |
3f1f2f6
to
e395eb3
Compare
drgn_tools/iscsi.py
Outdated
:returns: an iterator of ``struct Scsi_Host *`` | ||
""" | ||
for shost in for_each_scsi_host(prog): | ||
if "iscsi" in host_module_name(shost).lower(): |
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.
Not all iscsi hardware driver has iscsi in its name, please use grep iscsi drivers/iscsi
find the all iscsi driver module names and create a list for matching.
drgn_tools/iscsi.py
Outdated
""" | ||
for scsi_dev in for_each_scsi_host_device(prog, shost): | ||
name = get_scsi_device_name(prog, scsi_dev) | ||
yield scsi_dev, name |
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.
This helper seems not necessary to me, it used in print_iscsi_report
, you can just use for_each_scsi_host_device
and invoke get_scsi_device_name
if name is needed.
drgn_tools/iscsi.py
Outdated
print() | ||
|
||
|
||
class IscsiDump(CorelensModule): |
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.
Let use Iscsi
as the name
drgn_tools/iscsi.py
Outdated
def print_iscsi_report(prog: Program) -> None: | ||
""" | ||
Prints a comprehensive report including iscsi table and session stats. More info can be added later if needed. | ||
""" |
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.
Let make the name print_iscsi_sessions
and update above comments, since this is only for dumping iscsi sessions. If dump other information is needed, we can add new functions.
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.
Please add below code at the beginning of this function, this will make sure the helper bail out if iscsi is not used when invoking this helper directly from drgn shell while not corelen module.
msg = ensure_debuginfo(prog, ["libiscsi", "scsi_transport_iscsi"])
if msg:
print(msg)
return
drgn_tools/scsi.py
Outdated
prog: Program, shost: Object | ||
) -> Iterator[Object]: | ||
""" | ||
Get a list of scsi_devices asscociated with an Scsi_Host |
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.
typo, s/asscociated/associated/ , s/an/one
drgn_tools/scsi.py
Outdated
) -> Iterator[Object]: | ||
""" | ||
Get a list of scsi_devices asscociated with an Scsi_Host | ||
:returns: a iterator of ``struct scsi_device`` |
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.
struct scsi_device *
drgn_tools/scsi.py
Outdated
) | ||
|
||
|
||
def get_scsi_device_name(prog: Program, sdev: Object) -> str: |
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.
Please put module name at the first, scsi_device_name
?
tests/test_iscsi.py
Outdated
for mod in ISCSI_MODS: | ||
km = KernelModule.find(prog, mod) | ||
if not km: | ||
return |
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.
With ensure_debuginfo
in the beginning of print_iscsi_report
, above loading debuginfo code is not needed.
Also the gitlab CI test failed, please fix it. |
e395eb3
to
40a4d0c
Compare
066e731
to
5828281
Compare
Orabug: 37362180 Signed-off-by: Richard Li <[email protected]>
5828281
to
85ef297
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.
Looks good, thank you.
Updated the helper based on feedback from @biger410