From: Shachar Sharon Date: Thu, 29 May 2025 12:31:46 +0000 (+0300) Subject: profile: reset per-share counters X-Git-Tag: tdb-1.4.14~171 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=51c52fafb2d9605dbddf7ba7b1c418901741fb9d;p=thirdparty%2Fsamba.git profile: reset per-share counters Allow zero-reset dynamic per-share profile counters when sending 'smbcontrol smbd profile flush' to active smbd. Signed-off-by: Shachar Sharon Reviewed-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h index 6bdbf6a2180..0ddf17bb6a8 100644 --- a/source3/include/smbprofile.h +++ b/source3/include/smbprofile.h @@ -750,6 +750,7 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly); void smbprofile_persvc_mkref(int snum, const char *svc, const char *remote); void smbprofile_persvc_unref(int snum); struct profile_stats *smbprofile_persvc_get(int snum); +void smbprofile_persvc_reset(void); int smbprofile_persvc_collect(int (*fn)(const char *key, const struct profile_stats *stats, @@ -905,6 +906,11 @@ static inline struct profile_stats *smbprofile_persvc_get(int snum) return NULL; } +static inline void smbprofile_persvc_reset(void) +{ + return; +} + #endif /* WITH_PROFILE */ #endif diff --git a/source3/profile/profile.c b/source3/profile/profile.c index 0b87d7b7c0b..850b083a1f5 100644 --- a/source3/profile/profile.c +++ b/source3/profile/profile.c @@ -67,6 +67,7 @@ void set_profile_level(int level, const struct server_id *src) break; case 3: /* reset profile values */ ZERO_STRUCT(profile_p->values); + smbprofile_persvc_reset(); tdb_wipe_all(smbprofile_state.internal.db->tdb); DEBUG(1,("INFO: Profiling values cleared from pid %d\n", (int)procid_to_pid(src))); @@ -552,3 +553,25 @@ int smbprofile_persvc_collect(int (*fn)(const char *key, fn, private_data); } + +void smbprofile_persvc_reset(void) +{ + struct profile_stats_persvc *entry = NULL; + size_t i, cap; + + if (!smbprofile_active()) { + return; + } + + if (smbprofile_state.internal.db == NULL) { + return; + } + + cap = talloc_array_length(smbprofile_state.persvc.tbl); + for (i = 0; i < cap; ++i) { + entry = smbprofile_state.persvc.tbl[i]; + if ((entry != NULL) && entry->refcnt) { + ZERO_STRUCT(entry->stats); + } + } +}