Skip to content

Commit 53abfdb

Browse files
ahrenssdimitro
authored andcommitted
dbuf command filtering does not work in all invocations (#184)
The dbuf command can select dbufs that match certain parameters (e.g. '-l 1' for level-1 dbufs). This works when `dbuf` is the first command in the pipeline, and when it is used as a locator with a dnode_t* as input. But it doesn't work in other circumstances, for example when it's being used only as a pretty-printer (with the list of dbufs piped in), or when it's used in the middle of a pipeline. This change adds the filter calls to this use cases, and adds corresponding test cases
1 parent 5b72240 commit 53abfdb

File tree

5 files changed

+570
-2
lines changed

5 files changed

+570
-2
lines changed

sdb/commands/zfs/dbuf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def ObjsetName(os: drgn.Object):
8383
def pretty_print(self, dbufs):
8484
print("{:>20} {:>8} {:>4} {:>8} {:>5} {}".format(
8585
"addr", "object", "lvl", "blkid", "holds", "os"))
86-
for dbuf in dbufs:
86+
for dbuf in filter(self.argfilter, dbufs):
8787
print("{:>20} {:>8d} {:>4d} {:>8d} {:>5d} {}".format(
8888
hex(dbuf), int(dbuf.db.db_object), int(dbuf.db_level),
8989
int(dbuf.db_blkid), int(dbuf.db_holds.rc_count),
@@ -115,6 +115,10 @@ def all_dnode_dbufs(self, dn: drgn.Object) -> Iterable[drgn.Object]:
115115
def from_dnode(self, dn: drgn.Object) -> Iterable[drgn.Object]:
116116
yield from filter(self.argfilter, self.all_dnode_dbufs(dn))
117117

118+
@sdb.InputHandler(input_type)
119+
def from_dbuf(self, dbuf: drgn.Object) -> Iterable[drgn.Object]:
120+
yield from filter(self.argfilter, [dbuf])
121+
118122
@staticmethod
119123
def all_dbufs() -> Iterable[drgn.Object]:
120124
hash_map = sdb.get_object("dbuf_hash_table").address_of_()

0 commit comments

Comments
 (0)