Skip to content

Commit

Permalink
Slog used added in IOCTL
Browse files Browse the repository at this point in the history
  • Loading branch information
datacore-skumar committed Jun 16, 2022
1 parent c4da2d6 commit e6e8f7c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
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 mirror_slog_usage(vdev_t* vd, vdev_stat_t* vs);
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 slog_used;
}zpool_zfs_metrics;

typedef struct {
Expand Down
9 changes: 5 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->slog_used = 0;
perf->used = getUsedData(perf->name);
perf->compress_ratio = getCompressRatio(perf->name);
perf->available = getAvail(perf->name);
Expand All @@ -126,10 +125,12 @@ 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->slog_used = mirror_slog_usage(spa_perf->spa_root_vdev, &vs);
bzero(&vs, sizeof(vs));
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
29 changes: 29 additions & 0 deletions module/zfs/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4437,6 +4437,35 @@ vdev_get_stats_ex_impl(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx)
}
}

/*
* Get mirror slog alloc
*/
static uint64_t
mirror_slog_usage(vdev_t* vd, vdev_stat_t* vs)
{
/*
* If we're getting stats on the root vdev, aggregate the I/O counts
* over all top-level vdevs (i.e. the direct children of the root).
*/
if (!vd->vdev_ops->vdev_op_leaf) {
if (vs) {
memset(vs->vs_ops, 0, sizeof(vs->vs_ops));
memset(vs->vs_bytes, 0, sizeof(vs->vs_bytes));
}

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;

mirror_slog_usage(cvd, cvs);
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

0 comments on commit e6e8f7c

Please sign in to comment.