4 Utility to display a Lustre cfs_hash table
5 Copyright (c) 2019 Cray Inc. All Rights Reserved.
8 from pykdump.API import *
13 import lustrelib as ll
14 from crashlib.input import toint
16 description_short = "Displays the specified Lustre hash table "
19 RULER = "........................................"
22 'ldlm_res_hop_object': ['struct ldlm_resource', 'lr_hash'],
23 'jobid_object': ['struct jobid_to_pid_map', 'jp_hash'],
24 'lu_obj_hop_object': ['struct lu_object_header', 'loh_hash'],
25 'uuid_export_object': ['struct obd_export', 'export_uuid_hash'],
26 'nid_export_object': ['struct obd_export', 'exp_nid_hash'],
27 'nidstats_object': ['struct nid_stat', 'nid_hash'],
28 'gen_export_object': ['struct obd_export', 'exp_gen_hash'],
29 'oqi_object': ['struct osc_quota_info', 'oqi_hash'],
30 'conn_object': ['struct ptlrpc_connection', 'c_hash']}
32 def get_hash_object(hs, hnode):
33 s = addr2sym(hs.hs_ops.hs_object)
34 if s not in hash_objects:
37 obj_addr = Addr(hnode) - member_offset(obj[0], obj[1])
38 return "%s %x" % (obj[0], obj_addr)
40 def dump_hnodes(hs, hlist, hnode, depth=0, ruler=RULER):
41 while(hnode != hlist & hnode):
42 s = get_hash_object(hs, hnode)
43 print "%*.*shlist_node 0x%x %s" % (depth, depth, ruler, Addr(hnode), s)
46 def dump_hlist(hs, hlist, depth=0, ruler=RULER):
49 print "%*.*shlist_head 0x%x" % (depth, depth, ruler, Addr(hlist))
50 dump_hnodes(hs, hlist, hnode, depth+DEPTH, ruler)
52 def dump_hash_bucket(hs, bd_bkt, depth=0, ruler=RULER):
53 print "%*.*scfs_hash_bucket 0x%x" % (depth, depth, ruler, Addr(bd_bkt))
54 for bd_offset in range(ll.CFS_HASH_BKT_NHLIST(hs)):
55 hlist = ll.cfs_hash_hhead(hs, bd_bkt, bd_offset)
57 dump_hlist(hs, hlist, depth+DEPTH, ruler)
59 def dump_hash_table(hs):
60 print "cfs_hash@0x%x" % Addr(hs)
62 for bd_bkt in ll.cfs_hash_get_buckets(hs):
63 dump_hash_bucket(hs, bd_bkt, DEPTH, RULER)
65 if __name__ == "__main__":
66 description = "Displays the specified Lustre hash table "
67 parser = argparse.ArgumentParser(description=description)
68 parser.add_argument("htable", default=False, type=toint,
69 help="address of a cfs_hash struct")
70 args = parser.parse_args()
72 hs = readSU('struct cfs_hash', args.htable)