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

DAOS-16837 container: Add client-side DFS metrics (#15544) #15640

Merged
merged 3 commits into from
Jan 17, 2025
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 src/client/dfs/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def scons():
libraries = ['daos_common', 'daos', 'uuid', 'gurt']

dfs_src = ['common.c', 'cont.c', 'dir.c', 'file.c', 'io.c', 'lookup.c', 'mnt.c', 'obj.c',
'pipeline.c', 'readdir.c', 'rename.c', 'xattr.c', 'dfs_sys.c']
'pipeline.c', 'readdir.c', 'rename.c', 'xattr.c', 'dfs_sys.c', 'metrics.c']
dfs = denv.d_library('dfs', dfs_src, LIBS=libraries)
denv.Install('$PREFIX/lib64/', dfs)

Expand Down
8 changes: 6 additions & 2 deletions src/client/dfs/common.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2018-2024 Intel Corporation.

Check failure on line 2 in src/client/dfs/common.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -625,6 +625,8 @@
stbuf->st_atim.tv_sec = stbuf->st_mtim.tv_sec;
stbuf->st_atim.tv_nsec = stbuf->st_mtim.tv_nsec;
}

DFS_OP_STAT_INCR(dfs, DOS_STAT);
return 0;
}

Expand Down Expand Up @@ -710,13 +712,14 @@
D_ASSERT(rc == 0);
dir->d.chunk_size = entry->chunk_size;
dir->d.oclass = entry->oclass;
DFS_OP_STAT_INCR(dfs, DOS_MKDIR);
return 0;
}
}

/* Check if parent has the dirname entry */
rc = fetch_entry(dfs->layout_v, parent_oh, DAOS_TX_NONE, dir->name, len, false, &exists,
entry, 0, NULL, NULL, NULL);
rc = fetch_entry(dfs->layout_v, parent_oh, dfs->th, dir->name, len, false, &exists, entry,
0, NULL, NULL, NULL);
if (rc) {
D_DEBUG(DB_TRACE, "fetch_entry %s failed %d.\n", dir->name, rc);
return rc;
Expand All @@ -742,6 +745,7 @@
oid_cp(&dir->oid, entry->oid);
dir->d.chunk_size = entry->chunk_size;
dir->d.oclass = entry->oclass;
DFS_OP_STAT_INCR(dfs, DOS_OPENDIR);
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/client/dfs/cont.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2018-2024 Intel Corporation.

Check failure on line 2 in src/client/dfs/cont.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -1240,14 +1240,14 @@
return EINVAL;

rc =
daos_array_open_with_attr(dfs->coh, oid, DAOS_TX_NONE, DAOS_OO_RO, 1,
daos_array_open_with_attr(dfs->coh, oid, dfs->th, DAOS_OO_RO, 1,
chunk_size ? chunk_size : dfs->attr.da_chunk_size, &oh, NULL);
if (rc != 0) {
D_ERROR("daos_array_open() failed: " DF_RC "\n", DP_RC(rc));
return daos_der2errno(rc);
}

rc = daos_array_get_size(oh, DAOS_TX_NONE, size, NULL);
rc = daos_array_get_size(oh, dfs->th, size, NULL);
if (rc) {
daos_array_close(oh, NULL);
D_ERROR("daos_array_get_size() failed: " DF_RC "\n", DP_RC(rc));
Expand Down
10 changes: 10 additions & 0 deletions src/client/dfs/dfs_internal.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2019-2024 Intel Corporation.

Check failure on line 2 in src/client/dfs/dfs_internal.h

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand All @@ -15,6 +15,8 @@
#include <daos.h>
#include <daos_fs.h>

#include "metrics.h"

/** D-key name of SB metadata */
#define SB_DKEY "DFS_SB_METADATA"

Expand Down Expand Up @@ -105,6 +107,8 @@

/** object struct that is instantiated for a DFS open object */
struct dfs_obj {
/** DFS mount point of object */
dfs_t *dfs;
/** DAOS object ID */
daos_obj_id_t oid;
/** DAOS object open handle */
Expand Down Expand Up @@ -161,6 +165,10 @@
uint32_t coh_refcount;
/** The last oid.hi in the sequence */
uint32_t last_hi;
/** Transaction handle epoch. DAOS_EPOCH_MAX for DAOS_TX_NONE */
daos_epoch_t th_epoch;
/** Transaction handle */
daos_handle_t th;
/** Object ID reserved for this DFS (see oid_gen below) */
daos_obj_id_t oid;
/** superblock object OID */
Expand All @@ -184,6 +192,8 @@
struct dfs_mnt_hdls *cont_hdl;
/** the root dir stat buf */
struct stat root_stbuf;
/** DFS top-level metrics */
struct dfs_metrics *metrics;
};

struct dfs_entry {
Expand Down
4 changes: 3 additions & 1 deletion src/client/dfs/dir.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2018-2024 Intel Corporation.

Check failure on line 2 in src/client/dfs/dir.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -65,6 +65,7 @@
if (rc != 0)
return daos_der2errno(rc);

DFS_OP_STAT_INCR(dfs, DOS_MKDIR);
return rc;
}

Expand Down Expand Up @@ -220,6 +221,7 @@
if (oid)
oid_cp(oid, entry.oid);

DFS_OP_STAT_INCR(dfs, DOS_UNLINK);
out:
rc = check_tx(th, rc);
if (rc == ERESTART)
Expand Down Expand Up @@ -326,6 +328,6 @@
return rc;

d_iov_set(&dkey, (void *)name, len);
rc = daos_obj_key2anchor(obj->oh, DAOS_TX_NONE, &dkey, NULL, anchor, NULL);
rc = daos_obj_key2anchor(obj->oh, obj->dfs->th, &dkey, NULL, anchor, NULL);
return daos_der2errno(rc);
}
2 changes: 1 addition & 1 deletion src/client/dfs/file.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2018-2024 Intel Corporation.

Check failure on line 2 in src/client/dfs/file.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -146,6 +146,6 @@
if (obj == NULL || !S_ISREG(obj->mode))
return EINVAL;

rc = daos_array_get_size(obj->oh, DAOS_TX_NONE, size, NULL);
rc = daos_array_get_size(obj->oh, dfs->th, size, NULL);
return daos_der2errno(rc);
}
50 changes: 45 additions & 5 deletions src/client/dfs/io.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2018-2024 Intel Corporation.

Check failure on line 2 in src/client/dfs/io.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand All @@ -15,7 +15,20 @@

#include "dfs_internal.h"

static void
dfs_update_file_metrics(dfs_t *dfs, daos_size_t read_bytes, daos_size_t write_bytes)
{
if (dfs == NULL || dfs->metrics == NULL)
return;

if (read_bytes > 0)
d_tm_inc_gauge(dfs->metrics->dm_read_bytes, read_bytes);
if (write_bytes > 0)
d_tm_inc_gauge(dfs->metrics->dm_write_bytes, write_bytes);
}

struct dfs_read_params {
dfs_t *dfs;
daos_size_t *read_size;
daos_array_iod_t arr_iod;
daos_range_t rg;
Expand All @@ -35,6 +48,8 @@
D_GOTO(out, rc);
}

DFS_OP_STAT_INCR(params->dfs, DOS_READ);
dfs_update_file_metrics(params->dfs, params->arr_iod.arr_nr_read, 0);
*params->read_size = params->arr_iod.arr_nr_read;
out:
D_FREE(params);
Expand All @@ -61,6 +76,7 @@
if (params == NULL)
D_GOTO(err_task, rc = -DER_NOMEM);

params->dfs = dfs;
params->read_size = read_size;

/** set array location */
Expand All @@ -76,7 +92,7 @@

args = dc_task_get_args(task);
args->oh = obj->oh;
args->th = DAOS_TX_NONE;
args->th = dfs->th;
args->sgl = sgl;
args->iod = &params->arr_iod;

Expand All @@ -90,6 +106,7 @@
* completion cb that frees params in this case, so we can just ignore the rc here.
*/
dc_task_schedule(task, true);

return 0;

err_params:
Expand Down Expand Up @@ -125,6 +142,7 @@
daos_event_launch(ev);
daos_event_complete(ev, 0);
}
DFS_OP_STAT_INCR(dfs, DOS_READ);
return 0;
}

Expand All @@ -140,13 +158,15 @@
rg.rg_idx = off;
iod.arr_rgs = &rg;

rc = daos_array_read(obj->oh, DAOS_TX_NONE, &iod, sgl, NULL);
rc = daos_array_read(obj->oh, dfs->th, &iod, sgl, NULL);
if (rc) {
D_ERROR("daos_array_read() failed, " DF_RC "\n", DP_RC(rc));
return daos_der2errno(rc);
}

DFS_OP_STAT_INCR(dfs, DOS_READ);
*read_size = iod.arr_nr_read;
dfs_update_file_metrics(dfs, iod.arr_nr_read, 0);
return 0;
}

Expand All @@ -173,6 +193,7 @@
daos_event_launch(ev);
daos_event_complete(ev, 0);
}
DFS_OP_STAT_INCR(dfs, DOS_READ);
return 0;
}

Expand All @@ -183,13 +204,15 @@
arr_iod.arr_nr = iod->iod_nr;
arr_iod.arr_rgs = iod->iod_rgs;

rc = daos_array_read(obj->oh, DAOS_TX_NONE, &arr_iod, sgl, ev);
rc = daos_array_read(obj->oh, dfs->th, &arr_iod, sgl, ev);
if (rc) {
D_ERROR("daos_array_read() failed (%d)\n", rc);
return daos_der2errno(rc);
}

DFS_OP_STAT_INCR(dfs, DOS_READ);
*read_size = arr_iod.arr_nr_read;
dfs_update_file_metrics(dfs, arr_iod.arr_nr_read, 0);
return 0;
}

Expand Down Expand Up @@ -223,6 +246,7 @@
daos_event_launch(ev);
daos_event_complete(ev, 0);
}
DFS_OP_STAT_INCR(dfs, DOS_WRITE);
return 0;
}

Expand All @@ -238,8 +262,12 @@
daos_event_errno_rc(ev);

rc = daos_array_write(obj->oh, DAOS_TX_NONE, &iod, sgl, ev);
if (rc)
if (rc == 0) {
DFS_OP_STAT_INCR(dfs, DOS_WRITE);
dfs_update_file_metrics(dfs, 0, buf_size);
} else {
D_ERROR("daos_array_write() failed, " DF_RC "\n", DP_RC(rc));
}

return daos_der2errno(rc);
}
Expand All @@ -248,6 +276,8 @@
dfs_writex(dfs_t *dfs, dfs_obj_t *obj, dfs_iod_t *iod, d_sg_list_t *sgl, daos_event_t *ev)
{
daos_array_iod_t arr_iod;
daos_size_t buf_size;
int i;
int rc;

if (dfs == NULL || !dfs->mounted)
Expand All @@ -266,6 +296,7 @@
daos_event_launch(ev);
daos_event_complete(ev, 0);
}
DFS_OP_STAT_INCR(dfs, DOS_WRITE);
return 0;
}

Expand All @@ -276,9 +307,18 @@
if (ev)
daos_event_errno_rc(ev);

buf_size = 0;
if (dfs->metrics != NULL && sgl != NULL)
for (i = 0; i < sgl->sg_nr; i++)
buf_size += sgl->sg_iovs[i].iov_len;

rc = daos_array_write(obj->oh, DAOS_TX_NONE, &arr_iod, sgl, ev);
if (rc)
if (rc == 0) {
DFS_OP_STAT_INCR(dfs, DOS_WRITE);
dfs_update_file_metrics(dfs, 0, buf_size);
} else {
D_ERROR("daos_array_write() failed (%d)\n", rc);
}

return daos_der2errno(rc);
}
Loading
Loading