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

Mirror slog used added in IOCTL #59

Merged
merged 1 commit into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/sys/vdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ extern void vdev_xlate_walk(vdev_t *vd, const range_seg64_t *logical_rs,
vdev_xlate_func_t *func, void *arg);

extern void vdev_get_stats_ex(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx);

extern uint64_t getMirrorSlogUsedSize(vdev_t* vd);
extern metaslab_group_t *vdev_get_mg(vdev_t *vd, metaslab_class_t *mc);

extern void vdev_get_stats(vdev_t *vd, vdev_stat_t *vs);
Expand Down
1 change: 1 addition & 0 deletions include/sys/zfs_ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ typedef struct {
char zpoolHealthState[MAXNAMELEN];
char name[MAXNAMELEN];
unsigned __int64 l2arc_alloc_size;
unsigned __int64 mirror_slog_alloc_size;
}zpool_zfs_metrics;

typedef struct {
Expand Down
8 changes: 4 additions & 4 deletions module/os/windows/zfs/zfs_ioctl_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ zfs_vfs_ref(zfsvfs_t **zfvp)
extern kstat_t* perf_arc_ksp;
NTSTATUS zpool_zfs_get_metrics(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
{
Irp->IoStatus.Information = 0;
if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(zpool_zfs_metrics)) {
Irp->IoStatus.Information = sizeof(zpool_zfs_metrics);
return STATUS_BUFFER_TOO_SMALL;
Expand All @@ -114,7 +113,7 @@ NTSTATUS zpool_zfs_get_metrics(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_
perf->zfs_volSize = 0;
strncpy(perf->zpoolHealthState, "", sizeof(perf->zpoolHealthState));
perf->l2arc_alloc_size = 0;

perf->mirror_slog_alloc_size = 0;
perf->used = getUsedData(perf->name);
perf->compress_ratio = getCompressRatio(perf->name);
perf->available = getAvail(perf->name);
Expand All @@ -126,10 +125,11 @@ NTSTATUS zpool_zfs_get_metrics(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_
mutex_exit(&spa_namespace_lock);
return STATUS_NOT_FOUND;
}

vdev_stat_t vs = { 0 };
vdev_stat_ex_t vsx = { 0 };
spa_config_enter(spa_perf, SCL_ALL, FTAG, RW_READER);
vdev_get_stats_ex(spa_perf->spa_root_vdev, &vs, &vsx);
perf->mirror_slog_alloc_size = getMirrorSlogUsedSize(spa_perf->spa_root_vdev);
vdev_get_stats(spa_perf->spa_root_vdev, &vs);
perf->zpool_dedup_ratio = ddt_get_pool_dedup_ratio(spa_perf);
const char* healthState = spa_state_to_name(spa_perf);
spa_config_exit(spa_perf, SCL_ALL, FTAG);
Expand Down
20 changes: 20 additions & 0 deletions module/zfs/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4437,6 +4437,26 @@ vdev_get_stats_ex_impl(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx)
}
}

/*
* Get mirror slog alloc
*/
static uint64_t
getMirrorSlogUsedSize(vdev_t* vd)
{
if (!vd->vdev_ops->vdev_op_leaf) {
for (int c = 0; c < vd->vdev_children; c++) {
vdev_t* cvd = vd->vdev_child[c];
vdev_stat_t* cvs = &cvd->vdev_stat;
vdev_stat_ex_t* cvsx = &cvd->vdev_stat_ex;

getMirrorSlogUsedSize(cvd);
if (cvd->vdev_islog)
return cvs->vs_alloc;
}
}
return 0;
}

void
vdev_get_stats_ex(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx)
{
Expand Down