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

NFS Ganesha global stats are now written into shm to be displayed at runtime #11

Open
wants to merge 1 commit into
base: V2.3-mapr
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions src/MainNFSD/nfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@
#include <pthread.h>
#include <signal.h> /* for sigaction */
#include <errno.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "fsal.h"
#include "log.h"
#include "nfs_init.h"
#include "nfs_exports.h"
#include "pnfs_utils.h"
#include "server_stats.h"

/**
* @brief LTTng trace enabling magic
Expand Down Expand Up @@ -480,9 +483,22 @@ int main(int argc, char *argv[])

config_Free(config_struct);

int shmid = global_stats_init();

if (shmid < 0) {
LogEvent(COMPONENT_INIT,
"***shmget failed, key 2049, errno %d\n", shmid);
LogEvent(COMPONENT_INIT, "global stats allocated with malloc");
} else {
LogEvent(COMPONENT_INIT,
"***shmget successful, key 2049, shmid %d\n", shmid);
}

/* Everything seems to be OK! We can now start service threads */
nfs_start(&my_nfs_start_info);

global_stats_free();

return 0;

fatal_die:
Expand Down
177 changes: 177 additions & 0 deletions src/include/server_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,180 @@

#include <sys/types.h>

#ifdef USE_DBUS

struct op_name {
char *name;
};

/* latency stats
*/
struct op_latency {
uint64_t latency;
uint64_t min;
uint64_t max;
};

/* v3 ops
*/
struct nfsv3_ops {
uint64_t op[NFSPROC3_COMMIT+1];
};

/* quota ops
*/
struct qta_ops {
uint64_t op[RQUOTAPROC_SETACTIVEQUOTA+1];
};

/* nlm ops
*/
struct nlm_ops {
uint64_t op[NLMPROC4_FREE_ALL+1];
};

/* mount ops
*/
struct mnt_ops {
uint64_t op[MOUNTPROC3_EXPORT+1];
};

/* v4 ops
*/
struct nfsv4_ops {
uint64_t op[NFS4_OP_LAST_ONE];
};

/* basic op counter
*/

struct proto_op {
uint64_t total; /* total of any kind */
uint64_t errors; /* ! NFS_OK */
uint64_t dups; /* detected dup requests */
struct op_latency latency; /* either executed ops latency */
struct op_latency dup_latency; /* or latency (runtime) to replay */
struct op_latency queue_latency; /* queue wait time */
};

/* basic I/O transfer counter
*/
struct xfer_op {
struct proto_op cmd;
uint64_t requested;
uint64_t transferred;
};

/* pNFS Layout counters
*/

struct layout_op {
uint64_t total; /* total ops */
uint64_t errors; /* ! NFS4_OK && !NFS4ERR_DELAY */
uint64_t delays; /* NFS4ERR_DELAY */
};

/* NFSv3 statistics counters
*/

struct nfsv3_stats {
struct proto_op cmds; /* non-I/O ops = cmds - (read+write) */
struct xfer_op read;
struct xfer_op write;
};

/* Mount statistics counters
*/
struct mnt_stats {
struct proto_op v1_ops;
struct proto_op v3_ops;
};

/* lock manager counters
*/

struct nlmv4_stats {
struct proto_op ops;
};

/* Quota counters
*/

struct rquota_stats {
struct proto_op ops;
struct proto_op ext_ops;
};

/* NFSv4 statistics counters
*/

struct nfsv40_stats {
struct proto_op compounds;
uint64_t ops_per_compound; /* avg = total / ops_per */
struct xfer_op read;
struct xfer_op write;
};

struct nfsv41_stats {
struct proto_op compounds;
uint64_t ops_per_compound; /* for size averaging */
struct xfer_op read;
struct xfer_op write;
struct layout_op getdevinfo;
struct layout_op layout_get;
struct layout_op layout_commit;
struct layout_op layout_return;
struct layout_op recall;
};

struct transport_stats {
uint64_t rx_bytes;
uint64_t rx_pkt;
uint64_t rx_err;
uint64_t tx_bytes;
uint64_t tx_pkt;
uint64_t tx_err;
};

#ifdef _USE_9P
struct _9p_stats {
struct proto_op cmds; /* non-I/O ops */
struct xfer_op read;
struct xfer_op write;
struct transport_stats trans;
struct proto_op *opcodes[_9P_RWSTAT+1];
};
#endif

struct global_stats {
struct nfsv3_stats nfsv3;
struct mnt_stats mnt;
struct nlmv4_stats nlm4;
struct rquota_stats rquota;
struct nfsv40_stats nfsv40;
struct nfsv41_stats nfsv41;
struct nfsv41_stats nfsv42; /* Uses v41 stats */
struct nfsv3_ops v3;
struct nfsv4_ops v4;
struct nlm_ops lm;
struct mnt_ops mn;
struct qta_ops qt;
};

struct deleg_stats {
uint32_t curr_deleg_grants; /* current num of delegations owned by
this client */
uint32_t tot_recalls; /* total num of times client was asked to
recall */
uint32_t failed_recalls; /* times client failed to process recall */
uint32_t num_revokes; /* Num revokes for the client */
};

extern int global_stats_shmid;
extern struct global_stats *global_st;

#endif

void server_stats_nfs_done(request_data_t *reqdata, int rc, bool dup);

#ifdef _USE_9P
Expand All @@ -64,5 +238,8 @@ void inc_revokes(struct gsh_client *client);
void inc_recalls(struct gsh_client *client);
void inc_failed_recalls(struct gsh_client *client);

int global_stats_init(void);
void global_stats_free(void);

#endif /* !SERVER_STATS_H */
/** @} */
13 changes: 13 additions & 0 deletions src/support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ SET(support_STAT_SRCS
export_mgr.c
)

SET(support_DISPLAY_STATS
display_stats.c
)

add_executable(display_stats
${support_DISPLAY_STATS}
${support_STATS_SRCS}
)

target_link_libraries(display_stats
${DBUS_LIBRARIES}
)

if(ERROR_INJECTION)
set(support_STAT_SRCS
${support_STAT_SRCS}
Expand Down
Loading