+// SPDX-License-Identifier: GPL-2.0
-#include <libxfs.h>
+#include "libxfs.h"
#include "globals.h"
#include "progress.h"
#include "err_protos.h"
{FMT2, N_("moving disconnected inodes to lost+found"), /* 12 */
&rpt_fmts[FMT2], &rpt_types[TYPE_INODE]},
{FMT1, N_("verify and correct link counts"), /* 13 */
- &rpt_fmts[FMT1], &rpt_types[TYPE_INODE]},
+ &rpt_fmts[FMT1], &rpt_types[TYPE_AG]},
{FMT1, N_("verify link counts"), /* 14 */
- &rpt_fmts[FMT1], &rpt_types[TYPE_INODE]}
+ &rpt_fmts[FMT1], &rpt_types[TYPE_AG]}
};
-pthread_t report_thread;
+static pthread_t report_thread;
typedef struct msg_block_s {
pthread_mutex_t mutex;
progress_rpt_t *format;
- __uint64_t *done;
- __uint64_t *total;
+ uint64_t *done;
+ uint64_t *total;
int count;
int interval;
} msg_block_t;
time_t start;
time_t end;
time_t duration;
- __uint64_t item_counts[4];
+ uint64_t item_counts[4];
} phase_times_t;
static phase_times_t phase_times[8];
static void *progress_rpt_thread(void *);
static int current_phase;
static int running;
-static __uint64_t prog_rpt_total;
+static uint64_t prog_rpt_total;
void
init_progress_rpt (void)
* allocate the done vector
*/
- if ((prog_rpt_done = (__uint64_t *)
- malloc(sizeof(__uint64_t)*glob_agcount)) == NULL ) {
+ if ((prog_rpt_done = (uint64_t *)
+ malloc(sizeof(uint64_t)*glob_agcount)) == NULL) {
do_error(_("cannot malloc pointer to done vector\n"));
}
- bzero(prog_rpt_done, sizeof(__uint64_t)*glob_agcount);
+ bzero(prog_rpt_done, sizeof(uint64_t)*glob_agcount);
/*
* Setup comm block, start the thread
*/
pthread_mutex_init(&global_msgs.mutex, NULL);
+ global_msgs.format = NULL;
global_msgs.count = glob_agcount;
global_msgs.interval = report_interval;
global_msgs.done = prog_rpt_done;
timer_t timerid;
struct itimerspec timespec;
char *msgbuf;
- __uint64_t *donep;
- __uint64_t sum;
+ uint64_t *donep;
+ uint64_t sum;
msg_block_t *msgp = (msg_block_t *)p;
- __uint64_t percent;
+ uint64_t percent;
+
+ /* It's possible to get here very early w/ no progress msg set */
+ if (!msgp->format)
+ return NULL;
if ((msgbuf = (char *)malloc(DURATION_BUF_SIZE)) == NULL)
do_error (_("progress_rpt: cannot malloc progress msg buffer\n"));
* Specify a repeating timer that fires each MSG_INTERVAL seconds.
*/
+ memset(×pec, 0, sizeof(timespec));
timespec.it_value.tv_sec = msgp->interval;
- timespec.it_value.tv_nsec = 0;
timespec.it_interval.tv_sec = msgp->interval;
- timespec.it_interval.tv_nsec = 0;
if (timer_create (CLOCK_REALTIME, NULL, &timerid))
do_error(_("progress_rpt: cannot create timer\n"));
current_phase, duration(elapsed, msgbuf),
(int) (60*sum/(elapsed)), *msgp->format->type);
do_log(
- _("\t- %02d:%02d:%02d: Phase %d: %llu%% done - estimated remaining time %s\n"),
+ _("\t- %02d:%02d:%02d: Phase %d: %" PRIu64 "%% done - estimated remaining time %s\n"),
tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
current_phase, percent,
duration((int) ((*msgp->total - sum) * (elapsed)/sum), msgbuf));
}
int
-set_progress_msg (int report, __uint64_t total)
+set_progress_msg(int report, uint64_t total)
{
if (!ag_stride)
/* reset all the accumulative totals */
if (prog_rpt_done)
- bzero(prog_rpt_done, sizeof(__uint64_t)*glob_agcount);
+ bzero(prog_rpt_done, sizeof(uint64_t)*glob_agcount);
if (pthread_mutex_unlock(&global_msgs.mutex))
do_error(_("set_progress_msg: cannot unlock progress mutex\n"));
return (0);
}
-__uint64_t
+uint64_t
print_final_rpt(void)
{
int i;
struct tm *tmp;
time_t now;
- __uint64_t *donep;
- __uint64_t sum;
+ uint64_t *donep;
+ uint64_t sum;
msg_block_t *msgp = &global_msgs;
char msgbuf[DURATION_BUF_SIZE];
return(sum);
}
-void
+static void
timediff(int phase)
{
phase_times[phase].duration =