]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
authorTimo Sirainen <tss@iki.fi>
Thu, 25 Aug 2011 00:54:50 +0000 (03:54 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 25 Aug 2011 00:54:50 +0000 (03:54 +0300)
src/lib-storage/index/cydir/cydir-mail.c
src/lib-storage/index/dbox-common/dbox-mail.c
src/lib-storage/index/dbox-multi/mdbox-mail.c
src/lib-storage/index/dbox-single/sdbox-mail.c
src/lib-storage/index/index-mail-headers.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-search.c
src/lib-storage/index/istream-mail-stats.c
src/lib-storage/index/maildir/maildir-mail.c
src/lib-storage/index/raw/raw-mail.c
src/lib-storage/mail-storage-private.h

index a4aedbd4bacaec246d2cb2fd7d55ffcea6bff772..112d797ce78644ed1b7e6067fbf631f3b5e29b12 100644 (file)
@@ -25,7 +25,7 @@ static int cydir_mail_stat(struct mail *mail, struct stat *st_r)
        if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE)
                return mail_set_aborted(mail);
 
-       mail->transaction->stats_stat_lookup_count++;
+       mail->transaction->stats.stat_lookup_count++;
        path = cydir_mail_get_path(mail);
        if (stat(path, st_r) < 0) {
                if (errno == ENOENT)
@@ -99,7 +99,7 @@ cydir_mail_get_stream(struct mail *_mail, struct message_size *hdr_size,
        int fd;
 
        if (mail->data.stream == NULL) {
-               _mail->transaction->stats_open_lookup_count++;
+               _mail->transaction->stats.open_lookup_count++;
                path = cydir_mail_get_path(_mail);
                fd = open(path, O_RDONLY);
                if (fd == -1) {
index fc4806dcd40d8448c9e9a9d5890e463fdbfbdfe5..a1e6fd822bd7b21e146928e651864712958d3344 100644 (file)
@@ -145,7 +145,7 @@ int dbox_mail_get_save_date(struct mail *_mail, time_t *date_r)
        if (storage->v.mail_open(mail, &offset, &file) < 0)
                return -1;
 
-       _mail->transaction->stats_fstat_lookup_count++;
+       _mail->transaction->stats.fstat_lookup_count++;
        if (dbox_file_stat(file, &st) < 0) {
                if (errno == ENOENT)
                        mail_set_expunged(_mail);
index b56c240ac344d65cdba8bd4f5d9612f655bb2cb4..b596c0fb378e18a684becfa5a30287ae071e8650 100644 (file)
@@ -126,7 +126,7 @@ int mdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r,
                }
 
                if (!dbox_file_is_open(mail->open_file))
-                       _mail->transaction->stats_open_lookup_count++;
+                       _mail->transaction->stats.open_lookup_count++;
                if (dbox_file_open(mail->open_file, &deleted) <= 0)
                        return -1;
                if (deleted) {
index 5875bae42f36eaf3804b7d827f97debd6ad7e409..10ddb4c5b3242f4f5cf379ea7b8e244f7a7fdd09 100644 (file)
@@ -68,7 +68,7 @@ int sdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r,
 
        if (!sdbox_mail_file_set(mail)) {
                if (!dbox_file_is_open(mail->open_file))
-                       _mail->transaction->stats_open_lookup_count++;
+                       _mail->transaction->stats.open_lookup_count++;
                if (dbox_file_open(mail->open_file, &deleted) <= 0)
                        return -1;
                if (deleted) {
index 410b9851a330f04a3b653a9a772156384c69d089..57091da817717b2fc66fbaa1130b6d64922e89ad 100644 (file)
@@ -625,7 +625,7 @@ index_mail_get_raw_headers(struct index_mail *mail, const char *field,
                *value_r = index_mail_get_parsed_header(mail, field_idx);
                return 0;
        }
-       _mail->transaction->stats_cache_hit_count++;
+       _mail->transaction->stats.cache_hit_count++;
        data = buffer_get_modifiable_data(dest, &len);
 
        if (len == 0) {
@@ -807,7 +807,7 @@ int index_mail_get_header_stream(struct mail *_mail,
        if (mail_cache_lookup_headers(_mail->transaction->cache_view, dest,
                                      _mail->seq, headers->idx,
                                      headers->count) > 0) {
-               _mail->transaction->stats_cache_hit_count++;
+               _mail->transaction->stats.cache_hit_count++;
                if (mail->data.filter_stream != NULL)
                        i_stream_destroy(&mail->data.filter_stream);
                mail->data.filter_stream =
index 1ade73a314395e742acdc656eea5a918e4873f55..26074bce1ece7967f5ebd6bc52fb342a73737c24 100644 (file)
@@ -50,7 +50,7 @@ int index_mail_cache_lookup_field(struct index_mail *mail, buffer_t *buf,
        ret = mail_cache_lookup_field(mail->mail.mail.transaction->cache_view,
                                      buf, mail->data.seq, field_idx);
        if (ret > 0)
-               mail->mail.mail.transaction->stats_cache_hit_count++;
+               mail->mail.mail.transaction->stats.cache_hit_count++;
        return ret;
 }
 
index 8101a645e4d6a8a29670a0cc3ef41182fff436fb..5e4e9ae3b66dbd2a8f911c52f6069abddd546ca2 100644 (file)
@@ -1198,12 +1198,12 @@ int index_storage_search_deinit(struct mail_search_context *_ctx)
 static unsigned long long
 search_get_cost(struct mailbox_transaction_context *trans)
 {
-       return trans->stats_open_lookup_count * SEARCH_COST_DENTRY +
-               trans->stats_stat_lookup_count * SEARCH_COST_DENTRY +
-               trans->stats_fstat_lookup_count * SEARCH_COST_ATTR +
-               trans->stats_cache_hit_count * SEARCH_COST_CACHE +
-               trans->stats_files_read_count * SEARCH_COST_FILES_READ +
-               (trans->stats_files_read_bytes/1024) * SEARCH_COST_KBYTE;
+       return trans->stats.open_lookup_count * SEARCH_COST_DENTRY +
+               trans->stats.stat_lookup_count * SEARCH_COST_DENTRY +
+               trans->stats.fstat_lookup_count * SEARCH_COST_ATTR +
+               trans->stats.cache_hit_count * SEARCH_COST_CACHE +
+               trans->stats.files_read_count * SEARCH_COST_FILES_READ +
+               (trans->stats.files_read_bytes/1024) * SEARCH_COST_KBYTE;
 }
 
 static int search_match_once(struct index_search_context *ctx)
index 9b7b1db08d6c9df60b26d659872b426a74ae6cc9..1a55f8f1cc06949c5b4cfceb2e6c8f480adcf6d9 100644 (file)
@@ -24,10 +24,10 @@ i_stream_mail_stats_read_mail_stats(struct istream_private *stream)
 
        ret = i_stream_read_copy_from_parent(&stream->istream);
        if (ret > 0) {
-               mstream->trans->stats_files_read_bytes += ret;
+               mstream->trans->stats.files_read_bytes += ret;
                if (!mstream->files_read_increased) {
                        mstream->files_read_increased = TRUE;
-                       mstream->trans->stats_files_read_count++;
+                       mstream->trans->stats.files_read_count++;
                }
        }
        return ret;
index 9920e412dda258e4c0e68682c18d46ebf4c7d796..7b83adb8c26233adcd96977867e622a8ec8e918b 100644 (file)
@@ -71,7 +71,7 @@ maildir_open_mail(struct maildir_mailbox *mbox, struct mail *mail,
        ctx.fd = -1;
        ctx.path = NULL;
 
-       mail->transaction->stats_open_lookup_count++;
+       mail->transaction->stats.open_lookup_count++;
        if (!mail->saving) {
                if (maildir_file_do(mbox, mail->uid, do_open, &ctx) < 0)
                        return NULL;
@@ -120,13 +120,13 @@ static int maildir_mail_stat(struct mail *mail, struct stat *st)
        }
 
        if (imail->data.stream != NULL) {
-               mail->transaction->stats_fstat_lookup_count++;
+               mail->transaction->stats.fstat_lookup_count++;
                stp = i_stream_stat(imail->data.stream, FALSE);
                if (stp == NULL)
                        return -1;
                *st = *stp;
        } else if (!mail->saving) {
-               mail->transaction->stats_stat_lookup_count++;
+               mail->transaction->stats.stat_lookup_count++;
                ret = maildir_file_do(mbox, mail->uid, do_stat, st);
                if (ret <= 0) {
                        if (ret == 0)
@@ -134,7 +134,7 @@ static int maildir_mail_stat(struct mail *mail, struct stat *st)
                        return -1;
                }
        } else {
-               mail->transaction->stats_stat_lookup_count++;
+               mail->transaction->stats.stat_lookup_count++;
                path = maildir_save_file_get_path(mail->transaction, mail->seq);
                if (stat(path, st) < 0) {
                        mail_storage_set_critical(mail->box->storage,
index 2b2dd0879af132c2f71a45e4a7f133bfdc2b4f0b..29d403917704de6826e7736a0d843469bf33a820 100644 (file)
@@ -17,7 +17,7 @@ static int raw_mail_stat(struct mail *mail)
        if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE)
                return mail_set_aborted(mail);
 
-       mail->transaction->stats_fstat_lookup_count++;
+       mail->transaction->stats.fstat_lookup_count++;
        st = i_stream_stat(mail->box->input, TRUE);
        if (st == NULL) {
                mail_storage_set_critical(mail->box->storage,
index 400c6e599693bdfc5c081b2c76b934713b351320..75551b5cf27acabc6a1d6aaf62d5e695bba3bb23 100644 (file)
@@ -345,6 +345,18 @@ union mailbox_transaction_module_context {
        struct mail_storage_module_register *reg;
 };
 
+struct mailbox_transaction_stats {
+       unsigned long open_lookup_count;
+       unsigned long stat_lookup_count;
+       unsigned long fstat_lookup_count;
+       /* number of files we've opened and read */
+       unsigned long files_read_count;
+       /* number of bytes we've had to read from files */
+       unsigned long long files_read_bytes;
+       /* number of cache lookup hits */
+       unsigned long cache_hit_count;
+};
+
 struct mailbox_transaction_context {
        struct mailbox *box;
        enum mailbox_transaction_flags flags;
@@ -367,17 +379,7 @@ struct mailbox_transaction_context {
        struct mail_save_context *save_ctx;
 
        /* these statistics are never reset by mail-storage API: */
-
-       unsigned long stats_open_lookup_count;
-       unsigned long stats_stat_lookup_count;
-       unsigned long stats_fstat_lookup_count;
-       /* number of files we've opened and read */
-       unsigned long stats_files_read_count;
-       /* number of bytes we've had to read from files */
-       unsigned long long stats_files_read_bytes;
-       /* number of cache lookup hits */
-       unsigned long stats_cache_hit_count;
-
+       struct mailbox_transaction_stats stats;
        /* Set to TRUE to update stats_* fields */
        unsigned int stats_track:1;
 };