@@ -15,18 +15,15 @@ static inline long io_timer_cmp(io_timer_heap *h,
1515
1616void bch2_io_timer_add (struct io_clock * clock , struct io_timer * timer )
1717{
18- size_t i ;
19-
2018 spin_lock (& clock -> timer_lock );
2119
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 )) {
2421 spin_unlock (& clock -> timer_lock );
2522 timer -> fn (timer );
2623 return ;
2724 }
2825
29- for (i = 0 ; i < clock -> timers .used ; i ++ )
26+ for (size_t i = 0 ; i < clock -> timers .used ; i ++ )
3027 if (clock -> timers .data [i ] == timer )
3128 goto out ;
3229
@@ -37,11 +34,9 @@ void bch2_io_timer_add(struct io_clock *clock, struct io_timer *timer)
3734
3835void bch2_io_timer_del (struct io_clock * clock , struct io_timer * timer )
3936{
40- size_t i ;
41-
4237 spin_lock (& clock -> timer_lock );
4338
44- for (i = 0 ; i < clock -> timers .used ; i ++ )
39+ for (size_t i = 0 ; i < clock -> timers .used ; i ++ )
4540 if (clock -> timers .data [i ] == timer ) {
4641 heap_del (& clock -> timers , i , io_timer_cmp , NULL );
4742 break ;
@@ -75,33 +70,31 @@ static void io_clock_cpu_timeout(struct timer_list *timer)
7570 wake_up_process (wait -> task );
7671}
7772
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 )
7974{
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+ };
8181
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 ;
8782 bch2_io_timer_add (clock , & wait .io_timer );
88-
8983 schedule ();
90-
9184 bch2_io_timer_del (clock , & wait .io_timer );
9285}
9386
9487void 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 )
9789{
9890 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+ };
10097
101- wait .io_timer .expire = io_until ;
102- wait .io_timer .fn = io_clock_wait_fn ;
103- wait .task = current ;
104- wait .expired = 0 ;
10598 bch2_io_timer_add (clock , & wait .io_timer );
10699
107100 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,
127120 bch2_io_timer_del (clock , & wait .io_timer );
128121}
129122
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 )
132124{
133125 struct io_timer * ret = NULL ;
134126
135127 if (clock -> timers .used &&
136- time_after_eq (now , clock -> timers .data [0 ]-> expire ))
128+ time_after_eq64 (now , clock -> timers .data [0 ]-> expire ))
137129 heap_pop (& clock -> timers , ret , io_timer_cmp , NULL );
138130 return ret ;
139131}
140132
141- void __bch2_increment_clock (struct io_clock * clock , unsigned sectors )
133+ void __bch2_increment_clock (struct io_clock * clock , u64 sectors )
142134{
143135 struct io_timer * timer ;
144- unsigned long now = atomic64_add_return (sectors , & clock -> now );
136+ u64 now = atomic64_add_return (sectors , & clock -> now );
145137
146138 spin_lock (& clock -> timer_lock );
147139 while ((timer = get_expired_timer (clock , now )))
@@ -151,17 +143,18 @@ void __bch2_increment_clock(struct io_clock *clock, unsigned sectors)
151143
152144void bch2_io_timers_to_text (struct printbuf * out , struct io_clock * clock )
153145{
154- unsigned long now ;
155- unsigned i ;
156-
157146 out -> atomic ++ ;
158147 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 );
160152
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" ,
163155 clock -> timers .data [i ]-> fn ,
164- clock -> timers .data [i ]-> expire - now );
156+ clock -> timers .data [i ]-> fn2 ,
157+ clock -> timers .data [i ]-> expire );
165158 spin_unlock (& clock -> timer_lock );
166159 -- out -> atomic ;
167160}
0 commit comments