From 0ab322a7f3a434997051912cec6c77253af5f351 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 11 Apr 2023 17:10:24 -0400 Subject: [PATCH] LU-15515 contrib: Some style fixes for epython scripts tighten formatting, remove spurious if() constructs, add int conversion for shifts Test-Parameters: trivial Change-Id: Id89bc8ca898d0d5870ca6955b185571060eafd58 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50607 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Nathaniel Clark Reviewed-by: Feng Lei Reviewed-by: Oleg Drokin --- contrib/debug_tools/epython_scripts/crashlib/addrlib.py | 2 +- contrib/debug_tools/epython_scripts/ldlm_dumplocks.py | 14 +++++++------- contrib/debug_tools/epython_scripts/obd_devs.py | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/contrib/debug_tools/epython_scripts/crashlib/addrlib.py b/contrib/debug_tools/epython_scripts/crashlib/addrlib.py index 0724ddd..5387f04 100644 --- a/contrib/debug_tools/epython_scripts/crashlib/addrlib.py +++ b/contrib/debug_tools/epython_scripts/crashlib/addrlib.py @@ -15,7 +15,7 @@ def ptov(physaddr): def phys2pfn(physaddr): """Convert a physical address to a page offset.""" - return physaddr >> crashlib.cid.mdtbl.pageshift + return physaddr >> int(crashlib.cid.mdtbl.pageshift) def pfn2phys(pfn): """Convert a page offset into a physical address.""" diff --git a/contrib/debug_tools/epython_scripts/ldlm_dumplocks.py b/contrib/debug_tools/epython_scripts/ldlm_dumplocks.py index 5df8866..e8da915 100644 --- a/contrib/debug_tools/epython_scripts/ldlm_dumplocks.py +++ b/contrib/debug_tools/epython_scripts/ldlm_dumplocks.py @@ -39,7 +39,7 @@ def lockmode2str(mode): def ldlm_dump_lock(lock, pos, lstname): obd = None imp = None - if(lock == None): + if lock == None: print(" NULL LDLM lock") return try: @@ -51,13 +51,13 @@ def ldlm_dump_lock(lock, pos, lstname): print(" -- Lock: (ldlm_lock) %#x/%#x (rc: %d) (pos: %d/%s) (pid: %d)" % \ (Addr(lock), lock.l_handle.h_cookie, refcounter, pos, lstname, lock.l_pid)) - if(lock.l_conn_export): + if lock.l_conn_export: obd = lock.l_conn_export.exp_obd - if(lock.l_export and lock.l_export.exp_connection): + if lock.l_export and lock.l_export.exp_connection: print(" Node: NID %s (remote: %#x) export" % \ (ll.nid2str(lock.l_export.exp_connection.c_peer.nid), lock.l_remote_handle.cookie)) - elif(obd == None): + elif obd == None: print(" Node: local") else: imp = obd.u.cli.cl_import @@ -80,17 +80,17 @@ def ldlm_dump_lock(lock, pos, lstname): lock.l_flags)) lr_type = lock.l_resource.lr_type - if(lr_type == enum_LDLM_EXTENT): + if lr_type == enum_LDLM_EXTENT: print(" Extent: %d -> %d (req %d-%d)" % \ (lock.l_policy_data.l_extent.start, lock.l_policy_data.l_extent.end, lock.l_req_extent.start, lock.l_req_extent.end)) - elif(lr_type == enum_LDLM_FLOCK): + elif lr_type == enum_LDLM_FLOCK: print(" Pid: %d Flock: 0x%x -> 0x%x" % \ (lock.l_policy_data.l_flock.pid, lock.l_policy_data.l_flock.start, lock.l_policy_data.l_flock.end)) - elif(lr_type == enum_LDLM_IBITS): + elif lr_type == enum_LDLM_IBITS: print(" Bits: %#x" % \ (lock.l_policy_data.l_inodebits.bits)) except (crash.error, IndexError): diff --git a/contrib/debug_tools/epython_scripts/obd_devs.py b/contrib/debug_tools/epython_scripts/obd_devs.py index a6610df..20aab0d 100644 --- a/contrib/debug_tools/epython_scripts/obd_devs.py +++ b/contrib/debug_tools/epython_scripts/obd_devs.py @@ -65,12 +65,12 @@ def print_one_device(obd, stats_flag): connect_cnt = 0 inflight=0 if obd.u.cli.cl_import: - impstate=IMP_STATE.get(obd.u.cli.cl_import.imp_state) - index=obd.u.cli.cl_import.imp_state_hist_idx - 1 - if index > 0 and index < 16: - ish_time=obd.u.cli.cl_import.imp_state_hist[index].ish_time - inflight=obd.u.cli.cl_import.imp_inflight.counter - connect_cnt = obd.u.cli.cl_import.imp_conn_cnt + impstate = IMP_STATE.get(obd.u.cli.cl_import.imp_state) + index = obd.u.cli.cl_import.imp_state_hist_idx - 1 + if index > 0 and index < 16: + ish_time = obd.u.cli.cl_import.imp_state_hist[index].ish_time + inflight = obd.u.cli.cl_import.imp_inflight.counter + connect_cnt = obd.u.cli.cl_import.imp_conn_cnt print("0x%-17x %-22s\t%-22s\t 0x%-17x 0x%-17x %-10s %-10d %5d %5d" % \ (Addr(obd), @@ -106,8 +106,8 @@ if __name__ == "__main__": description = "Displays the contents of global 'obd_devs'" parser = argparse.ArgumentParser(description=description) parser.add_argument("obd_device", nargs="?", default = [], type=toint, - help="print obd_device at argument address") + help = "print obd_device at argument address") parser.add_argument("-r", dest="stats_flag", action="count", - help="print the rpc_stats sequence for each client_obd") + help = "print the rpc_stats sequence for each client_obd") args = parser.parse_args() obd_devs(args) -- 1.8.3.1