Re: arca-1-against-pre-2.1.127-3

Andrea Arcangeli (andrea@e-mind.com)
Wed, 4 Nov 1998 01:18:17 +0100 (CET)


On Wed, 4 Nov 1998, Andrea Arcangeli wrote:

>>Just based on semantic considerations, timer_add()/timer_delete() makes
>>sense but timer_pending() makes races. In fact timer_pending() may just

I looked where I was using timer_pending() (just to be sure for the race
case).

I fixed a bit more the aic7xxx misuse of the timer (I hope it will not
cause fs corruption ;-). Here a fix against pre-2.1.127-3 (to allow people
to comment it without having to download my whole arca-8).

And Gerard, in _most_ of cases doing something if (!timer_pening()),
doesn' t cause a race (because the timer is not set).

Index: aic7xxx.c
===================================================================
RCS file: /var/cvs/linux/drivers/scsi/aic7xxx.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 aic7xxx.c
--- aic7xxx.c 1998/10/24 13:40:46 1.1.1.3
+++ aic7xxx.c 1998/11/03 23:53:40
@@ -3429,10 +3429,7 @@
* here so that we can delay all re-sent commands for this device for the
* 4 seconds and then have our timer routine pick them back up.
*/
- if(p->dev_timer[i].expires)
- {
- del_timer(&p->dev_timer[i]);
- }
+ del_timer(&p->dev_timer[i]);
p->dev_timer[i].expires = jiffies + (4 * HZ);
add_timer(&p->dev_timer[i]);
}
@@ -3481,12 +3478,8 @@
"delayed_scbs queue!\n", p->host_no, channel, i, lun);
scbq_init(&p->delayed_scbs[i]);
}
- if ( (p->delayed_scbs[i].head == NULL) &&
- (p->dev_timer[i].expires) )
- {
+ if ( p->delayed_scbs[i].head == NULL )
del_timer(&p->dev_timer[i]);
- p->dev_timer[i].expires = 0;
- }
}
}

@@ -4007,7 +4000,7 @@
}
if ( (p->dev_active_cmds[tindex] >=
p->dev_temp_queue_depth[tindex]) ||
- (p->dev_last_reset[tindex] >= (jiffies - (4 * HZ))) )
+ time_after_eq(p->dev_last_reset[tindex], jiffies - 4 * HZ) )
{
#ifdef AIC7XXX_VERBOSE_DEBUGGING
if (aic7xxx_verbose > 0xffff)
@@ -4015,7 +4008,7 @@
p->host_no, CTL_OF_SCB(scb));
#endif
scbq_insert_tail(&p->delayed_scbs[tindex], scb);
- if ( !(p->dev_timer[tindex].expires) &&
+ if ( !timer_pending(&p->dev_timer[tindex]) &&
!(p->dev_active_cmds[tindex]) )
{
p->dev_timer[tindex].expires = p->dev_last_reset[tindex] + (4 * HZ);
@@ -4154,15 +4147,8 @@
#endif
for(i=0; i<MAX_TARGETS; i++)
{
- if ( (p->dev_timer[i].expires) &&
- (p->dev_timer[i].expires <= jiffies) )
+ if ( del_timer(&p->dev_timer[i]) )
{
- p->dev_timer[i].expires = 0;
- if ( (p->dev_timer[i].prev != NULL) ||
- (p->dev_timer[i].next != NULL) )
- {
- del_timer(&p->dev_timer[i]);
- }
p->dev_temp_queue_depth[i] = p->dev_max_queue_depth[i];
j = 0;
while ( ((scb = scbq_remove_head(&p->delayed_scbs[i])) != NULL) &&
@@ -4895,7 +4881,7 @@
p->activescbs--;
scb->flags |= SCB_WAITINGQ | SCB_WAS_BUSY;

- if (p->dev_timer[tindex].expires == 0)
+ if ( !timer_pending(&p->dev_timer[tindex]) )
{
if ( p->dev_active_cmds[tindex] )
{
@@ -7462,7 +7448,7 @@
}

p->host = host;
- p->last_reset = 0;
+ p->last_reset = jiffies;
p->host_no = host->host_no;
host->unique_id = p->instance;
p->isr_count = 0;
@@ -7489,7 +7475,7 @@
p->dev_commands_sent[i] = 0;
p->dev_flags[i] = 0;
p->dev_active_cmds[i] = 0;
- p->dev_last_reset[i] = 0;
+ p->dev_last_reset[i] = jiffies;
p->dev_last_queue_full[i] = 0;
p->dev_last_queue_full_count[i] = 0;
p->dev_max_queue_depth[i] = 1;
@@ -7497,7 +7483,6 @@
p->dev_mid_level_queue_depth[i] = 3;
scbq_init(&p->delayed_scbs[i]);
init_timer(&p->dev_timer[i]);
- p->dev_timer[i].expires = 0;
p->dev_timer[i].data = (unsigned long)p;
p->dev_timer[i].function = (void *)aic7xxx_timer;
}

My arca-8 is out and fix the aic this way + rejects the FP_IMPOSSIBLE
logic (but not yet s/KERNEL/USER since I guess I would duplicate Linus's
work doing that now).

Andrea Arcangeli

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/