@@ -15,18 +15,15 @@ static inline long io_timer_cmp(io_timer_heap *h,
15
15
16
16
void bch2_io_timer_add (struct io_clock * clock , struct io_timer * timer )
17
17
{
18
- size_t i ;
19
-
20
18
spin_lock (& clock -> timer_lock );
21
19
22
- if (time_after_eq ((unsigned long ) atomic64_read (& clock -> now ),
23
- timer -> expire )) {
20
+ if (time_after_eq64 ((u64 ) atomic64_read (& clock -> now ), timer -> expire )) {
24
21
spin_unlock (& clock -> timer_lock );
25
22
timer -> fn (timer );
26
23
return ;
27
24
}
28
25
29
- for (i = 0 ; i < clock -> timers .used ; i ++ )
26
+ for (size_t i = 0 ; i < clock -> timers .used ; i ++ )
30
27
if (clock -> timers .data [i ] == timer )
31
28
goto out ;
32
29
@@ -37,11 +34,9 @@ void bch2_io_timer_add(struct io_clock *clock, struct io_timer *timer)
37
34
38
35
void bch2_io_timer_del (struct io_clock * clock , struct io_timer * timer )
39
36
{
40
- size_t i ;
41
-
42
37
spin_lock (& clock -> timer_lock );
43
38
44
- for (i = 0 ; i < clock -> timers .used ; i ++ )
39
+ for (size_t i = 0 ; i < clock -> timers .used ; i ++ )
45
40
if (clock -> timers .data [i ] == timer ) {
46
41
heap_del (& clock -> timers , i , io_timer_cmp , NULL );
47
42
break ;
@@ -75,33 +70,31 @@ static void io_clock_cpu_timeout(struct timer_list *timer)
75
70
wake_up_process (wait -> task );
76
71
}
77
72
78
- void bch2_io_clock_schedule_timeout (struct io_clock * clock , unsigned long until )
73
+ void bch2_io_clock_schedule_timeout (struct io_clock * clock , u64 until )
79
74
{
80
- struct io_clock_wait wait ;
75
+ struct io_clock_wait wait = {
76
+ .io_timer .expire = until ,
77
+ .io_timer .fn = io_clock_wait_fn ,
78
+ .io_timer .fn2 = (void * ) _RET_IP_ ,
79
+ .task = current ,
80
+ };
81
81
82
- /* XXX: calculate sleep time rigorously */
83
- wait .io_timer .expire = until ;
84
- wait .io_timer .fn = io_clock_wait_fn ;
85
- wait .task = current ;
86
- wait .expired = 0 ;
87
82
bch2_io_timer_add (clock , & wait .io_timer );
88
-
89
83
schedule ();
90
-
91
84
bch2_io_timer_del (clock , & wait .io_timer );
92
85
}
93
86
94
87
void bch2_kthread_io_clock_wait (struct io_clock * clock ,
95
- unsigned long io_until ,
96
- unsigned long cpu_timeout )
88
+ u64 io_until , unsigned long cpu_timeout )
97
89
{
98
90
bool kthread = (current -> flags & PF_KTHREAD ) != 0 ;
99
- struct io_clock_wait wait ;
91
+ struct io_clock_wait wait = {
92
+ .io_timer .expire = io_until ,
93
+ .io_timer .fn = io_clock_wait_fn ,
94
+ .io_timer .fn2 = (void * ) _RET_IP_ ,
95
+ .task = current ,
96
+ };
100
97
101
- wait .io_timer .expire = io_until ;
102
- wait .io_timer .fn = io_clock_wait_fn ;
103
- wait .task = current ;
104
- wait .expired = 0 ;
105
98
bch2_io_timer_add (clock , & wait .io_timer );
106
99
107
100
timer_setup_on_stack (& wait .cpu_timer , io_clock_cpu_timeout , 0 );
@@ -127,21 +120,20 @@ void bch2_kthread_io_clock_wait(struct io_clock *clock,
127
120
bch2_io_timer_del (clock , & wait .io_timer );
128
121
}
129
122
130
- static struct io_timer * get_expired_timer (struct io_clock * clock ,
131
- unsigned long now )
123
+ static struct io_timer * get_expired_timer (struct io_clock * clock , u64 now )
132
124
{
133
125
struct io_timer * ret = NULL ;
134
126
135
127
if (clock -> timers .used &&
136
- time_after_eq (now , clock -> timers .data [0 ]-> expire ))
128
+ time_after_eq64 (now , clock -> timers .data [0 ]-> expire ))
137
129
heap_pop (& clock -> timers , ret , io_timer_cmp , NULL );
138
130
return ret ;
139
131
}
140
132
141
- void __bch2_increment_clock (struct io_clock * clock , unsigned sectors )
133
+ void __bch2_increment_clock (struct io_clock * clock , u64 sectors )
142
134
{
143
135
struct io_timer * timer ;
144
- unsigned long now = atomic64_add_return (sectors , & clock -> now );
136
+ u64 now = atomic64_add_return (sectors , & clock -> now );
145
137
146
138
spin_lock (& clock -> timer_lock );
147
139
while ((timer = get_expired_timer (clock , now )))
@@ -151,17 +143,18 @@ void __bch2_increment_clock(struct io_clock *clock, unsigned sectors)
151
143
152
144
void bch2_io_timers_to_text (struct printbuf * out , struct io_clock * clock )
153
145
{
154
- unsigned long now ;
155
- unsigned i ;
156
-
157
146
out -> atomic ++ ;
158
147
spin_lock (& clock -> timer_lock );
159
- now = atomic64_read (& clock -> now );
148
+ u64 now = atomic64_read (& clock -> now );
149
+
150
+ printbuf_tabstop_push (out , 40 );
151
+ prt_printf (out , "current time:\t%llu\n" , now );
160
152
161
- for (i = 0 ; i < clock -> timers .used ; i ++ )
162
- prt_printf (out , "%ps:\t%li \n" ,
153
+ for (unsigned i = 0 ; i < clock -> timers .used ; i ++ )
154
+ prt_printf (out , "%ps %ps :\t%llu \n" ,
163
155
clock -> timers .data [i ]-> fn ,
164
- clock -> timers .data [i ]-> expire - now );
156
+ clock -> timers .data [i ]-> fn2 ,
157
+ clock -> timers .data [i ]-> expire );
165
158
spin_unlock (& clock -> timer_lock );
166
159
-- out -> atomic ;
167
160
}
0 commit comments