diff options
author | Scott Urban <scott.urban@isilon.com> | 2009-03-27 17:33:26 -0700 |
---|---|---|
committer | Steven Danneman <steven.danneman@isilon.com> | 2009-03-27 17:33:26 -0700 |
commit | ee22c417f3ae156522151815605300c703eeb664 (patch) | |
tree | b80303f5642d5a2bd0f32bb9a878fc3b7f98916a | |
parent | 21ad907aa01d839d405b10809517d491b72184da (diff) | |
download | samba-ee22c417f3ae156522151815605300c703eeb664.tar.gz samba-ee22c417f3ae156522151815605300c703eeb664.tar.bz2 samba-ee22c417f3ae156522151815605300c703eeb664.zip |
s3: added per-client statistics to onefs perfcount module
* we now track, uid, remote ip, and local ip per CIFS operation
* removed perfcount_set_client() from perfcount interface as it's
unecessary
-rw-r--r-- | source3/include/smb_perfcount.h | 8 | ||||
-rw-r--r-- | source3/modules/perfcount_onefs.c | 52 | ||||
-rw-r--r-- | source3/modules/perfcount_test.c | 9 |
3 files changed, 38 insertions, 31 deletions
diff --git a/source3/include/smb_perfcount.h b/source3/include/smb_perfcount.h index 01a539d508..9c83147d04 100644 --- a/source3/include/smb_perfcount.h +++ b/source3/include/smb_perfcount.h @@ -37,8 +37,6 @@ struct smb_perfcount_handlers { uint64_t in_bytes); void (*perfcount_set_msglen_out) (struct smb_perfcount_data *pcd, uint64_t out_bytes); - void (*perfcount_set_client) (struct smb_perfcount_data *pcd, uid_t uid, - const char *user, const char *domain); void (*perfcount_copy_context) (struct smb_perfcount_data *pcd, struct smb_perfcount_data *new_pcd); void (*perfcount_defer_op) (struct smb_perfcount_data *pcd, @@ -88,12 +86,6 @@ void smb_init_perfcount_data(struct smb_perfcount_data *pcd); (_pcd_)->handlers->perfcount_set_msglen_out((_pcd_), (_out_));\ } while (0) -#define SMB_PERFCOUNT_SET_CLIENT(_pcd_,_uid_, _user_, _domain_) \ - do {if((_pcd_) && (_pcd_)->handlers) \ - (_pcd_)->handlers->perfcount_set_client((_pcd_), (_uid_), \ - (_user_), (_domain_)); \ - } while (0) - #define SMB_PERFCOUNT_COPY_CONTEXT(_pcd_, _new_pcd_) \ do {if((_pcd_) && (_pcd_)->handlers) \ (_pcd_)->handlers->perfcount_copy_context((_pcd_), (_new_pcd_)); \ diff --git a/source3/modules/perfcount_onefs.c b/source3/modules/perfcount_onefs.c index 9b35af699a..066a7f1fe4 100644 --- a/source3/modules/perfcount_onefs.c +++ b/source3/modules/perfcount_onefs.c @@ -20,8 +20,11 @@ #include "includes.h" #include <sys/isi_stats_protocol.h> +#include <sys/isi_stats_client.h> #include <sys/isi_stats_cifs.h> +extern struct current_user current_user; + struct onefs_op_counter { struct isp_op_delta iod; struct onefs_op_counter *next; @@ -282,42 +285,64 @@ static void onefs_smb_statistics_defer_op(struct smb_perfcount_data *pcd, pcd->context = NULL; } -static void onefs_smb_statistics_set_client(struct smb_perfcount_data *pcd, - uid_t uid, const char *user, - const char *domain) -{ - // not implemented... - return; -} - static void onefs_smb_statistics_end(struct smb_perfcount_data *pcd) { struct onefs_stats_context *ctxt = pcd->context; struct onefs_op_counter *tmp; + uint64_t uid; + + static in_addr_t rem_addr = 0; + static in_addr_t loc_addr = 0; /* not enabled */ if (pcd->context == NULL) return; + uid = current_user.ut.uid ? current_user.ut.uid : ISC_UNKNOWN_CLIENT_ID; + + /* get address info once, doesn't change for process */ + if (rem_addr == 0) { + struct sockaddr_storage sa; + socklen_t sa_len; + int fd = smbd_server_fd(); + + sa_len = sizeof sa; + if (getpeername(fd, (struct sockaddr *)&sa, &sa_len) == 0 && + sa.ss_family == AF_INET) + rem_addr = ((struct sockaddr_in *)&sa)->sin_addr.s_addr; + else + rem_addr = ISC_MASKED_ADDR; + + sa_len = sizeof sa; + if (getsockname(fd, (struct sockaddr *)&sa, &sa_len) == 0 && + sa.ss_family == AF_INET) + loc_addr = ((struct sockaddr_in *)&sa)->sin_addr.s_addr; + else + loc_addr = ISC_MASKED_ADDR; + } + /* * bug here - we aren't getting the outlens right, * when dealing w/ chained requests. */ for (tmp = ctxt->ops_chain; tmp; tmp = tmp->next) { tmp->iod.out_bytes = ctxt->iod.out_bytes; + isc_cookie_init(&tmp->iod.cookie, rem_addr, loc_addr, uid); ISP_OP_END(&tmp->iod); #ifdef ONEFS_PERF_DEBUG - DEBUG(0,("******** Finalized CHAIN op %s in:%llu, out:%llu\n", - onefs_stat_debug(&tmp->iod), + DEBUG(0,("******** Finalized CHAIN op %s uid %llu in:%llu" + ", out:%llu\n", + onefs_stat_debug(&tmp->iod), uid, tmp->iod.in_bytes, tmp->iod.out_bytes)); #endif SAFE_FREE(tmp->prev); } - ISP_OP_END(&ctxt->iod); + isc_cookie_init(&ctxt->iod.cookie, rem_addr, loc_addr, uid); + ISP_OP_END(&ctxt->iod); #ifdef ONEFS_PERF_DEBUG - DEBUG(0,("******** Finalized op %s in:%llu, out:%llu\n", - onefs_stat_debug(&ctxt->iod), + DEBUG(0,("******** Finalized op %s uid %llu in:%llu, out:%llu\n", + onefs_stat_debug(&ctxt->iod), uid, ctxt->iod.in_bytes, ctxt->iod.out_bytes)); #endif @@ -338,7 +363,6 @@ static struct smb_perfcount_handlers onefs_pc_handlers = { onefs_smb_statistics_set_ioctl, onefs_smb_statistics_set_msglen_in, onefs_smb_statistics_set_msglen_out, - onefs_smb_statistics_set_client, onefs_smb_statistics_copy_context, onefs_smb_statistics_defer_op, onefs_smb_statistics_end diff --git a/source3/modules/perfcount_test.c b/source3/modules/perfcount_test.c index 418d83ace5..b72ac9f7b5 100644 --- a/source3/modules/perfcount_test.c +++ b/source3/modules/perfcount_test.c @@ -351,14 +351,6 @@ static void perfcount_test_defer_op(struct smb_perfcount_data *pcd, return; } -static void perfcount_test_set_client(struct smb_perfcount_data *pcd, - uid_t uid, const char *user, - const char *domain) -{ - /* WIP */ - return; -} - static void perfcount_test_end(struct smb_perfcount_data *pcd) { struct perfcount_test_context *ctxt = @@ -382,7 +374,6 @@ static struct smb_perfcount_handlers perfcount_test_handlers = { perfcount_test_set_ioctl, perfcount_test_set_msglen_in, perfcount_test_set_msglen_out, - perfcount_test_set_client, perfcount_test_copy_context, perfcount_test_defer_op, perfcount_test_end |