Skip to content
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

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

richl9
Copy link
Contributor

@richl9 richl9 commented Sep 30, 2024

Updated the helper based on feedback from @biger410

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Sep 30, 2024
Copy link
Member

@biger410 biger410 left a 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)
Copy link
Member

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
Copy link
Member

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.

else:
return list_for_each_entry(
"struct device", devices, "knode_class.n_node"
)
Copy link
Member

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?

dev = dev.parent

if dev.type and dev.type.name.string_().decode() == "scsi_host":
yield dev
Copy link
Member

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.

for device_private in list_for_each_entry(
"struct device_private", devices, "knode_class.n_node"
):
yield device_private.device
Copy link
Member

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?

@@ -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]:
Copy link
Member

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.


return iscsi_sw_tcp_host.session
Copy link
Member

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.

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)
Copy link
Member

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 Show resolved Hide resolved
drgn_tools/iscsi.py Show resolved Hide resolved
drgn_tools/iscsi.py Show resolved Hide resolved
rq = sdev.request_queue
dev = container_of(rq.kobj.parent, "struct device", "kobj")
return dev.kobj.name.string_().decode()

Copy link
Member

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?

"""
for h in for_each_iscsi_tcp_host(prog):
yield __get_iscsi_sw_tcp_host(prog, h).session

Copy link
Member

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.

@biger410
Copy link
Member

biger410 commented Dec 9, 2024

One more comment, please change the commit subject for this patch, probably "Add iscsi helpers to dump iscsi session information"

@richl9 richl9 changed the title Richard/iscsi Add iscsi helpers to dump iscsi session information Dec 10, 2024
@richl9
Copy link
Contributor Author

richl9 commented Dec 10, 2024

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.

@richl9 richl9 force-pushed the richard/iscsi branch 3 times, most recently from 3f1f2f6 to e395eb3 Compare December 11, 2024 22:53
:returns: an iterator of ``struct Scsi_Host *``
"""
for shost in for_each_scsi_host(prog):
if "iscsi" in host_module_name(shost).lower():
Copy link
Member

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.

"""
for scsi_dev in for_each_scsi_host_device(prog, shost):
name = get_scsi_device_name(prog, scsi_dev)
yield scsi_dev, name
Copy link
Member

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.

print()


class IscsiDump(CorelensModule):
Copy link
Member

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

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.
"""
Copy link
Member

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.

Copy link
Member

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

prog: Program, shost: Object
) -> Iterator[Object]:
"""
Get a list of scsi_devices asscociated with an Scsi_Host
Copy link
Member

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

) -> Iterator[Object]:
"""
Get a list of scsi_devices asscociated with an Scsi_Host
:returns: a iterator of ``struct scsi_device``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct scsi_device *

)


def get_scsi_device_name(prog: Program, sdev: Object) -> str:
Copy link
Member

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?

drgn_tools/iscsi.py Show resolved Hide resolved
for mod in ISCSI_MODS:
km = KernelModule.find(prog, mod)
if not km:
return
Copy link
Member

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.

@biger410
Copy link
Member

Also the gitlab CI test failed, please fix it.

@richl9 richl9 force-pushed the richard/iscsi branch 2 times, most recently from 066e731 to 5828281 Compare December 18, 2024 21:05
Orabug: 37362180
Signed-off-by: Richard Li <[email protected]>
Copy link
Member

@biger410 biger410 left a 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.

@brenns10 brenns10 merged commit 75f7896 into oracle-samples:main Jan 3, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants