]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
profile: reset per-share counters
authorShachar Sharon <ssharon@redhat.com>
Thu, 29 May 2025 12:31:46 +0000 (15:31 +0300)
committerAnoop C S <anoopcs@samba.org>
Mon, 23 Jun 2025 13:04:31 +0000 (13:04 +0000)
Allow zero-reset dynamic per-share profile counters when sending
'smbcontrol smbd profile flush' to active smbd.

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/include/smbprofile.h
source3/profile/profile.c

index 6bdbf6a2180aca5d689ea211e4a207d396b023ea..0ddf17bb6a8bafce8297b15bb2cbc8b30c8fc886 100644 (file)
@@ -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
index 0b87d7b7c0bed1542e5b0d416e9b0c30c3542db8..850b083a1f5bb75b43215c669089576b2b378c7b 100644 (file)
@@ -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);
+               }
+       }
+}