Skip to content

Commit

Permalink
Add dedup prefetch/prune support in py-libzfs
Browse files Browse the repository at this point in the history
  • Loading branch information
Qubad786 committed Oct 29, 2024
1 parent cf04e20 commit 85798dd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libzfs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3396,6 +3396,17 @@ cdef class ZFSPool(object):

self.root.write_history('zpool upgrade', self.name)

def prefetch(self):
cdef int ret

with nogil:
ret = libzfs.zpool_prefetch(self.handle, zfs.ZPOOL_PREFETCH_DDT)

if ret != 0:
raise self.root.get_error()

self.root.write_history('zpool prefetch -t ddt', self.name)


cdef class ZFSImportablePool(ZFSPool):
cdef NVList nvlist
Expand Down
3 changes: 3 additions & 0 deletions pxd/libzfs.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ cdef extern from "libzfs.h" nogil:
extern int zmount(const char *, const char *, int, char *, char *, int, char *,
int)

extern int zpool_prefetch(zpool_handle_t *, zfs.zpool_prefetch_type_t);
extern int zpool_ddt_prune(zpool_handle_t *, zfs.zpool_ddt_prune_unit_t, uint64_t)

IF HAVE_ZFS_FOREACH_MOUNTPOINT:
extern void zfs_foreach_mountpoint(
libzfs_handle_t *, zfs_handle_t **, size_t, zfs_iter_f, void*, boolean_t
Expand Down
9 changes: 9 additions & 0 deletions pxd/zfs.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ cdef extern from "sys/fs/zfs.h" nogil:
ZPOOL_WAIT_TRIM,
ZPOOL_WAIT_NUM_ACTIVITIES

ctypedef enum zpool_prefetch_type_t:
ZPOOL_PREFETCH_NONE
ZPOOL_PREFETCH_DDT

ctypedef enum zpool_ddt_prune_unit_t:
ZPOOL_DDT_PRUNE_NONE
ZPOOL_DDT_PRUNE_AGE
ZPOOL_DDT_PRUNE_PERCENTAGE

enum:
ZIO_TYPES
ZFS_NUM_USERQUOTA_PROPS
Expand Down

0 comments on commit 85798dd

Please sign in to comment.