Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 624158 | Differences between
and this patch

Collapse All | Expand All

(-)cluster-3.2.0.orig/cman/qdisk/disk_util.c (-66 / +1 lines)
Lines 16-89 Link Here
16
#include <sys/time.h>
16
#include <sys/time.h>
17
#include <time.h>
17
#include <time.h>
18
#include <liblogthread.h>
18
#include <liblogthread.h>
19
#include "disk_util.h"
19
20
20
inline void _diff_tv(struct timeval *dest, struct timeval *start, struct timeval *end);
21
inline int get_time(struct timeval *tv, int use_uptime);
22
21
23
inline void
24
_diff_tv(struct timeval *dest, struct timeval *start, struct timeval *end)
25
{
26
	dest->tv_sec = end->tv_sec - start->tv_sec;
27
	dest->tv_usec = end->tv_usec - start->tv_usec;
28
29
	if (dest->tv_usec < 0) {
30
		dest->tv_usec += 1000000;
31
		dest->tv_sec--;
32
	}
33
}
34
35
36
/**
37
 *
38
 * Grab the uptime from /proc/uptime.
39
 * 
40
 * @param tv		Timeval struct to store time in.  The sec
41
 * 			field contains seconds, the usec field 
42
 * 			contains the hundredths-of-seconds (converted
43
 * 			to micro-seconds)
44
 * @return		-1 on failure, 0 on success.
45
 */
46
static inline int
47
getuptime(struct timeval *tv)
48
{
49
	FILE *fp;
50
	struct timeval junk;
51
	int rv;
52
	
53
	fp = fopen("/proc/uptime","r");
54
	if (!fp)
55
		return -1;
56
57
#if defined(__sparc__)
58
	rv = fscanf(fp,"%ld.%d %ld.%d\n", &tv->tv_sec, &tv->tv_usec,
59
		    &junk.tv_sec, &junk.tv_usec);
60
#else
61
	rv = fscanf(fp,"%ld.%ld %ld.%ld\n", &tv->tv_sec, &tv->tv_usec,
62
		    &junk.tv_sec, &junk.tv_usec);
63
#endif
64
	fclose(fp);
65
	
66
	if (rv != 4) {
67
		return -1;
68
	}
69
	
70
	tv->tv_usec *= 10000;
71
	
72
	return 0;
73
}
74
75
76
inline int
77
get_time(struct timeval *tv, int use_uptime)
78
{
79
	if (use_uptime) {
80
		return getuptime(tv);
81
	} else {
82
		return gettimeofday(tv, NULL);
83
	}
84
}
85
86
 
87
/**
22
/**
88
  Update write times and calculate a new average time
23
  Update write times and calculate a new average time
89
 */
24
 */
(-)cluster-3.2.0.orig/cman/qdisk/disk_util.h (+67 lines)
Line 0 Link Here
1
2
static inline void
3
_diff_tv(struct timeval *dest, struct timeval *start, struct timeval *end)
4
{
5
	dest->tv_sec = end->tv_sec - start->tv_sec;
6
	dest->tv_usec = end->tv_usec - start->tv_usec;
7
8
	if (dest->tv_usec < 0) {
9
		dest->tv_usec += 1000000;
10
		dest->tv_sec--;
11
	}
12
}
13
14
15
16
17
/**
18
 *
19
 * Grab the uptime from /proc/uptime.
20
 * 
21
 * @param tv		Timeval struct to store time in.  The sec
22
 * 			field contains seconds, the usec field 
23
 * 			contains the hundredths-of-seconds (converted
24
 * 			to micro-seconds)
25
 * @return		-1 on failure, 0 on success.
26
 */
27
static inline int
28
getuptime(struct timeval *tv)
29
{
30
	FILE *fp;
31
	struct timeval junk;
32
	int rv;
33
	
34
	fp = fopen("/proc/uptime","r");
35
	if (!fp)
36
		return -1;
37
38
#if defined(__sparc__)
39
	rv = fscanf(fp,"%ld.%d %ld.%d\n", &tv->tv_sec, &tv->tv_usec,
40
		    &junk.tv_sec, &junk.tv_usec);
41
#else
42
	rv = fscanf(fp,"%ld.%ld %ld.%ld\n", &tv->tv_sec, &tv->tv_usec,
43
		    &junk.tv_sec, &junk.tv_usec);
44
#endif
45
	fclose(fp);
46
	
47
	if (rv != 4) {
48
		return -1;
49
	}
50
	
51
	tv->tv_usec *= 10000;
52
	
53
	return 0;
54
}
55
56
static inline int
57
get_time(struct timeval *tv, int use_uptime)
58
{
59
	if (use_uptime) {
60
		return getuptime(tv);
61
	} else {
62
		return gettimeofday(tv, NULL);
63
	}
64
}
65
66
 
67
(-)cluster-3.2.0.orig/cman/qdisk/main.c (-5 / +1 lines)
Lines 31-36 Link Here
31
#define LOG_DAEMON_NAME  "qdiskd"
31
#define LOG_DAEMON_NAME  "qdiskd"
32
#define LOG_MODE_DEFAULT LOG_MODE_OUTPUT_SYSLOG|LOG_MODE_OUTPUT_FILE
32
#define LOG_MODE_DEFAULT LOG_MODE_OUTPUT_SYSLOG|LOG_MODE_OUTPUT_FILE
33
#include "iostate.h"
33
#include "iostate.h"
34
#include "disk_util.h"
34
35
35
36
36
/* from main.c */
37
/* from main.c */
Lines 57-67 extern int clear_bit(uint8_t *mask, uint Link Here
57
extern int set_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
58
extern int set_bit(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
58
extern int is_bit_set(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
59
extern int is_bit_set(uint8_t *mask, uint32_t bitidx, uint32_t masklen);
59
60
60
/* From disk_utils.c */
61
extern inline int get_time(struct timeval *tv, int use_uptime);
62
extern inline void _diff_tv(struct timeval *dest, struct timeval *start,
63
		     struct timeval *end);
64
65
static int _running = 1, _reconfig = 0, _cman_shutdown = 0;
61
static int _running = 1, _reconfig = 0, _cman_shutdown = 0;
66
static int _debug = 0, _foreground = 0;
62
static int _debug = 0, _foreground = 0;
67
63

Return to bug 624158